info.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // pages/car/info.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. info: {},
  9. fileList:[]
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad: function (options) {
  15. var pages = getCurrentPages();
  16. var prevPage = pages[pages.length - 2];
  17. let getInfo = prevPage.data.resData[options.index]
  18. //船舶证书 certificatePathList
  19. let certificatePathList = []
  20. if(getInfo.shipCertificatePath){
  21. let unloadImgArr = getInfo.shipCertificatePath.split(',')
  22. unloadImgArr.forEach(element => {
  23. certificatePathList.push({
  24. url : app.host.BASEIMG_URL+element,
  25. imgUrl : element,
  26. isImage : true
  27. })
  28. });
  29. }
  30. //安全环保合同 contractPathList
  31. let contractPathList = []
  32. if(getInfo.contractPath){
  33. let unloadImgArr = getInfo.contractPath.split(',')
  34. unloadImgArr.forEach(element => {
  35. contractPathList.push({
  36. url : app.host.BASEIMG_URL+element,
  37. imgUrl : element,
  38. isImage : true
  39. })
  40. });
  41. }
  42. this.setData({
  43. info : getInfo,
  44. certificatePathList : certificatePathList,
  45. contractPathList : contractPathList
  46. })
  47. //获取船主
  48. app.request.GET({
  49. url: app.API.userDetail,
  50. page: this,
  51. params: {
  52. 'id': getInfo.shipId
  53. },
  54. successFun: true
  55. }).then(res => {
  56. let getInfo = res.data.data;
  57. this.setData({
  58. shipIdName : getInfo.name,
  59. shipMobile : getInfo.phone
  60. })
  61. })
  62. },
  63. //查询详情
  64. getInfo: function (id) {
  65. //详情
  66. app.request.requestGetApi(app.API.api.carDetail, {
  67. 'id': id
  68. }, this, function (res, _that) {
  69. let data = res.data.data;
  70. let getPhotoArr = data.certificateNoImage.split(',');
  71. let getfileListArr = []
  72. for(let i=0;i<getPhotoArr.length;i++){
  73. getfileListArr.push({
  74. url:getPhotoArr[i]
  75. })
  76. }
  77. _that.setData({
  78. info: data,
  79. "fileList":getfileListArr
  80. })
  81. })
  82. }
  83. })