tanghaolin
2022-07-27 fd4d1d9296ba620de15b47bd1d58383d46ecb626
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
 var Constant = require('../../utils/constant.js');
 var app = getApp();
 import Request  from "../../utils/api"
 Page({
   data: {
     currentCorpID: 1,
     currentEmployeeID: 1, //当前用户ID
 
     imagesList: [], //报修图片
 
     requestFormId: 0,
     taskFormId: 0,
     RequestEntity: {},
     TaskEntity: {},
 
     longitude: 0, //经纬度
     latitude: 0,
     userLocAddress: "", //定位的地址(可能不是报修地址)
 
     isShowConfirmDlg: false,
     operateNote: '' //信息
   },
   onLoad: function (options) {
     console.log(options)
     if (options.requestformid == '' || options.requestformid == undefined)
       return;
     if (options.taskformid == '' || options.taskformid == undefined)
       return;
     var that = this;
 
     var userInfo = app.globalData.userInfo;
 
     var requestformid = options.requestformid;
     var taskformid = options.taskformid;
     that.setData({
       taskFormId: taskformid,
       requestFormId: requestformid,
       currentCorpID: userInfo.CorpID,
       currentEmployeeID: userInfo.EmployeeID
     });
 
 
     //获取当前经纬度
     setTimeout(function () {
       that.getCurrentLocation();
     }, 1000);
 
     //初始化表单信息
     that.initialFormInfo();
   },
   onShareAppMessage: function () {
     return Constant.Share;
   },
   //初始化表单信息
   initialFormInfo: function () {
     var that = this;
     var requestformid = this.data.requestFormId;
     var taskformid = this.data.taskFormId;
     Request({
       url: Constant.BASE_SERVER_URL + "Repair/RepairTaskForm/Mobile/GetMyProgressDetailByID@V1.0",
       method: 'GET',
       data: {
         CorpID: this.data.currentCorpID,
         ID: requestformid,
       },
       header: {
         'content-type': 'application/json'
       },
       fail: function (err) {
         // wx.showModal({
         //   title: '',
         //   content: '通讯失败',
         // })
       }, //请求失败
       success: function (res) {
          console.log(res.data,"进行中详细")
         var result = res.data;
         if (result.Code != 0) {
           wx.showModal({
             title: '',
             content: result.message,
           });
           return;
         }
         var RequestEntity = result.Data.RequestForm;
         var imagesList = [];
         if (RequestEntity.FileList != null && RequestEntity.FileList.length > 0) {
           for (var i = 0; i < RequestEntity.FileList.length; i++) {
             var big_image_name = Constant.BASE_SERVER_URL + RequestEntity.FileList[i].StorageUrl;
          
             var m = {};
             m.OriginPath = big_image_name;
             m.ThumbPath = big_image_name;
             imagesList.push(m);
           }
         }
         //console.log(imagesList)
         that.setData({
           RequestEntity: RequestEntity,
           TaskEntity: result.Data,
           imagesList: imagesList
         })
       }
     });
   },
 
   //查看图片
   previewImage: function (e) {
     var that = this;
     var imagesList = [];
     var current = e.target.dataset.src.OriginPath;
     var images = that.data.imagesList;
     for (var i = 0; i < images.length; i++) {
       imagesList.push(images[i].OriginPath)
     }
     //  console.log(current, imagesList, "bigPicture:大图", "smallPicture:小图")
     wx.previewImage({
       current: current,
       urls: imagesList
     })
   },
 
   //加载定位
   getCurrentLocation: function () {
     var that = this;
     wx.getLocation({
       type: 'gcj02', // 默认为 wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标
       success(resLoc) {
         //console.log("getCurrentLocation", resLoc);
         if (resLoc.longitude == 0 || resLoc.latitude == 0) { //当前位置信号较弱,请换个位置尝试
           return;
         }
 
         //
         that.setData({
           longitude: resLoc.longitude,
           latitude: resLoc.latitude,
         })
         //发送请求通过经纬度反查地址信息  
         var getAddressUrl = "https://apis.map.qq.com/ws/geocoder/v1/?location=" + resLoc.latitude + "," + resLoc.longitude + "&key=GFDBZ-D3NKX-LNL4Z-TSWGU-RYCE3-4HB3I";
         wx.request({
           url: getAddressUrl,
           success: function (result) {
             //console.log("getAddressUrl", result);
             that.setData({
               userLocAddress: result.data.result.address
             });
           }
         });
       }
     });
   },
   //显示确认对话框
   tapShowConfirmDlg: function () {
     if (this.data.longitude == 0 || this.data.latitude == 0) {
       this.getCurrentLocation(); //获取当前经纬度
     }
 
     this.setData({
       isShowConfirmDlg: true
     });
   },
   // 
   inputOperateNote: function (e) {
     this.setData({
       operateNote: e.detail.value
     })
   },
   /*** 弹出框蒙层截断touchmove事件*/
   preventTouchMove: function () {},
   /*** 隐藏模态对话框 */
   hideConfirmDlg: function () {
     this.setData({
       isShowConfirmDlg: false
     })
   },
   /*** 对话框取消按钮点击事件*/
   onCancel: function () {
     this.hideConfirmDlg()
   },
   /***确认*/
   onConfirm: function () {
     //console.log(this.data.operateNote);
     var that = this;
     Request({
       url: Constant.BASE_SERVER_URL + "Repair/RepairTaskForm/Mobile/Start@V1.0",
       method: 'POST',
       data: {
         CorpID: Constant.CorpID,
         ID: that.data.requestFormId,
         Note:that.data.operateNote
       },
       header: {
        'content-type': 'application/x-www-form-urlencoded'
       },
       fail: function (err) {
         // wx.showModal({
         //   title: '',
         //   content: '通讯失败',
         // })
       }, //请求失败
       success: function (res) {
         console.log(res.data,"已开工");
         var result = res.data;
         if (result.Code != 0) {
           wx.showModal({
             title: '',
             content: result.Message,
           });
           return;
         }
 
         wx.showToast({
           title: '已开工',
           icon: 'success',
           duration: 2000
         });
 
 
         var pages = getCurrentPages();
         if (pages.length >= 2) {
           //var currPage = pages[pages.length - 1];   //当前页面
           var prevPage = pages[pages.length - 2]; //上一个页面
           //console.log(prevPage.route)
           if (prevPage) {
             var fn = prevPage.refreshRepairInfo;
             if (typeof fn == "function")
               fn(that.data.taskFormId, "startWork");
             wx.navigateBack({
               delta: 1
             });
           } else {
             wx.navigateBack({
               delta: 1
             });
           }
         } else {
           wx.navigateBack({
             delta: 1
           });
         }
 
         //that.hideModal();
         //wx.redirectTo({
         //  url: '/repair/myTask/index',
         //});
 
       }
     });
 
   },
 
   onReady: function () {},
   onShow: function () {},
   onHide: function () {},
   onUnload: function () {},
   onPullDownRefresh: function () {},
   onReachBottom: function () {},
   onShareAppMessage: function () {}
 })