// pages/work_order_detail/work_order_detail.js //获取应用实例 const app = getApp(); Page({ /** * 页面的初始数据 */ data: { allData: [], stringsArr: '', //坐标字符串 photoSring: '', styless: '', //查看工单显示或隐藏 // 地图 longitude: '', latitude: '', polyline: {}, markers: '', polylineArr: [], points: [], workesIDs: false, workesFlag: true, orderId: '', endFlag: false, }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { ////console.log("options",options) this.setData({ orderId: options.id, }); this.getData(options.id); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { this.mapCtx = wx.createMapContext('map'); }, getData(id) { let that = this; var url = app.globalData.httpsUrlServer + '/lhgyWork/selectPatrolTrackById'; var data = { id: id, type: 1, }; wx.showLoading({ title: '加载中', mask: true, }); app.postReq(url, data, (res) => { console.log('res图片展示', res); // if (res.data.type == '2') { // this.setData({ allData: res.data }); // } else { let mapARRS = res.data.totalCoordinates.split(';'); let arrsi = []; mapARRS.forEach((item, index) => { if (item != '') { arrsi.push(item); } }); let arrsis = []; arrsi.forEach((item, index) => { arrsis.push({ latitude: item.split(',')[0], longitude: item.split(',')[1], }); }); console.log('arrsi', arrsis); this.setData({ polylineArr: arrsis, longitude: arrsis[0].longitude, latitude: arrsis[0].latitude, workesIDs: res.data.workIds, polyline: [ { points: arrsis, color: '#ff9900', width: 9, arrowLine: true, borderWidth: 1, borderColor: '#555', }, ], markers: [ { iconPath: '/images/icon/wzEnd.png', id: 0, latitude: arrsis[arrsis.length - 1].latitude, longitude: arrsis[arrsis.length - 1].longitude, width: 33, height: 50, }, { iconPath: '/images/icon/wzStar.png', id: 0, latitude: arrsis[0].latitude, longitude: arrsis[0].longitude, width: 26, height: 40, }, ], points: arrsis, allData: res.data, stringsArr: res.data.totalCoordinates, }); // } // 判断是否去创建工单 if ( res.data.workIds == null && res.data.fileListResponse != null && res.data.fileListResponse.length > 0 && (res.data.fileListResponse[0].fileList || res.data.fileListResponse[0].patrolTrackIssueFileList) ) { this.setData({ workesIDs: true, }); } else if ( res.data.workIds == null && res.data.fileListResponse.length == 0 ) { this.setData({ workesFlag: false, }); } else { this.setData({ workesIDs: false, }); } wx.hideLoading(); // 图片 end }); }, // 创建工单 createGD() { var url = app.globalData.httpsUrlServer + '/lhgyWork/savePatrolTrackWork'; var data = { id: this.data.orderId, }; console.log(this.data.allData); var that = this; wx.showModal({ title: '提示', content: '确定创建工单吗?', success(res) { if (res.confirm) { wx.showLoading({ mask: true, }); app.postReq(url, data, (res) => { console.log(res); if (res.status == 200) { that.getData(that.data.orderId); wx.hideLoading(); that.setData({ endFlag: true, }); app.toast('创建成功'); } }); } else if (res.cancel) { console.log('用户点击取消'); } }, }); }, jumpDetails(e) { ////console.log("跳转路径",e) let url = e.currentTarget.dataset.url; let remark = e.currentTarget.dataset.remark; console.log(e.currentTarget.dataset.images, 'e.currentTarget.dataset.images'); let images = JSON.stringify(e.currentTarget.dataset.images); const key = 'detailMapInfo'; wx.setStorageSync(key, images) wx.navigateTo({ url: // "/packageA/pages/historicalTrackDetailMap/historicalTrackDetailMap?url=" + '../inspectionDetailMap/inspectionDetailMap?url=' + url + '&dates=' + this.data.stringsArr + '&remark=' + remark + '&images=' + images, }); }, // 查看地图 jumpDetailsMap() { wx.navigateTo({ url: '../inspectionDetailMap/inspectionDetailMap?dates=' + this.data.stringsArr, }); }, formDtealis(e) { console.log(this.data.allData); // app.globalData.orderType = 0 // app.globalData.orderState = 0 wx.navigateTo({ url: `/greenland/pages/greenOrderDetails/greenOrderDetails?orderId=${Number( this.data.allData.workIds )}&typeFlag=${this.data.allData.state}&deptType=${2}`, }); }, viewGD(e) { console.log(e); let index = e.currentTarget.dataset.index; let id = this.data.allData.fileListResponse[index].number3; wx.navigateTo({ url: `/greenland/pages/greenOrderDetails/greenOrderDetails?orderId=${Number( id )}&deptType=${2}`, }); }, goWoek(e){ let index = e.currentTarget.dataset.index; let id = this.data.allData.patrolTrackIssueList[index].workId; wx.navigateTo({ url: `/greenland/pages/greenOrderDetails/greenOrderDetails?orderId=${Number( id )}&deptType=${2}`, }); }, // 预览图 viewMoviePostImg: function (e) { var src = e.currentTarget.dataset.src; wx.previewImage({ current: src, // 当前显示图片的http链接 urls: [src], // 需要预览的图片http链接列表 }); }, // 回到顶部 scrolltoupper: function (e) { ////console.log(e) if (e.detail.scrollTop > 10) { this.setData({ cangotop: true, }); } else { this.setData({ cangotop: false, }); } }, // 点击获取地图经纬度 mapclick() { wx.chooseLocation({ success: (res) => { console.log('经纬度', res); // 移动marker this.mapCtx.moveToLocation(); }, fail: (res) => { console.log('fail', res); }, }); }, //回到顶部 goTop: function (e) { // 一键回到顶部 this.setData({ topNum: 0, }); }, /** * 生命周期函数--监听页面显示 */ onShow: function () {}, /** * 生命周期函数--监听页面隐藏 */ onHide: function () {}, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { let pages = getCurrentPages(); //页面栈 let beforePage = ''; beforePage = pages[pages.length - 2]; console.log(beforePage); if (this.data.endFlag == true) { beforePage.onPullDownRefresh(); } }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () {}, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () {}, /** * 用户点击右上角分享 */ onShareAppMessage: function () {}, });