| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313 |
- // 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 () {},
- });
|