暂无描述

inspectionDetail.js 7.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. // pages/work_order_detail/work_order_detail.js
  2. //获取应用实例
  3. const app = getApp();
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. allData: [],
  10. stringsArr: '', //坐标字符串
  11. photoSring: '',
  12. styless: '', //查看工单显示或隐藏
  13. // 地图
  14. longitude: '',
  15. latitude: '',
  16. polyline: {},
  17. markers: '',
  18. polylineArr: [],
  19. points: [],
  20. workesIDs: false,
  21. workesFlag: true,
  22. orderId: '',
  23. endFlag: false,
  24. },
  25. /**
  26. * 生命周期函数--监听页面加载
  27. */
  28. onLoad: function (options) {
  29. ////console.log("options",options)
  30. this.setData({
  31. orderId: options.id,
  32. });
  33. this.getData(options.id);
  34. },
  35. /**
  36. * 生命周期函数--监听页面初次渲染完成
  37. */
  38. onReady: function () {
  39. this.mapCtx = wx.createMapContext('map');
  40. },
  41. getData(id) {
  42. let that = this;
  43. var url = app.globalData.httpsUrlServer + '/lhgyWork/selectPatrolTrackById';
  44. var data = {
  45. id: id,
  46. type: 1,
  47. };
  48. wx.showLoading({
  49. title: '加载中',
  50. mask: true,
  51. });
  52. app.postReq(url, data, (res) => {
  53. console.log('res图片展示', res);
  54. // if (res.data.type == '2') {
  55. // this.setData({ allData: res.data });
  56. // } else {
  57. let mapARRS = res.data.totalCoordinates.split(';');
  58. let arrsi = [];
  59. mapARRS.forEach((item, index) => {
  60. if (item != '') {
  61. arrsi.push(item);
  62. }
  63. });
  64. let arrsis = [];
  65. arrsi.forEach((item, index) => {
  66. arrsis.push({
  67. latitude: item.split(',')[0],
  68. longitude: item.split(',')[1],
  69. });
  70. });
  71. console.log('arrsi', arrsis);
  72. this.setData({
  73. polylineArr: arrsis,
  74. longitude: arrsis[0].longitude,
  75. latitude: arrsis[0].latitude,
  76. workesIDs: res.data.workIds,
  77. polyline: [
  78. {
  79. points: arrsis,
  80. color: '#ff9900',
  81. width: 9,
  82. arrowLine: true,
  83. borderWidth: 1,
  84. borderColor: '#555',
  85. },
  86. ],
  87. markers: [
  88. {
  89. iconPath: '/images/icon/wzEnd.png',
  90. id: 0,
  91. latitude: arrsis[arrsis.length - 1].latitude,
  92. longitude: arrsis[arrsis.length - 1].longitude,
  93. width: 33,
  94. height: 50,
  95. },
  96. {
  97. iconPath: '/images/icon/wzStar.png',
  98. id: 0,
  99. latitude: arrsis[0].latitude,
  100. longitude: arrsis[0].longitude,
  101. width: 26,
  102. height: 40,
  103. },
  104. ],
  105. points: arrsis,
  106. allData: res.data,
  107. stringsArr: res.data.totalCoordinates,
  108. });
  109. // }
  110. // 判断是否去创建工单
  111. if (
  112. res.data.workIds == null &&
  113. res.data.fileListResponse != null &&
  114. res.data.fileListResponse.length > 0 &&
  115. (res.data.fileListResponse[0].fileList || res.data.fileListResponse[0].patrolTrackIssueFileList)
  116. ) {
  117. this.setData({
  118. workesIDs: true,
  119. });
  120. } else if (
  121. res.data.workIds == null &&
  122. res.data.fileListResponse.length == 0
  123. ) {
  124. this.setData({
  125. workesFlag: false,
  126. });
  127. } else {
  128. this.setData({
  129. workesIDs: false,
  130. });
  131. }
  132. wx.hideLoading();
  133. // 图片 end
  134. });
  135. },
  136. // 创建工单
  137. createGD() {
  138. var url = app.globalData.httpsUrlServer + '/lhgyWork/savePatrolTrackWork';
  139. var data = {
  140. id: this.data.orderId,
  141. };
  142. console.log(this.data.allData);
  143. var that = this;
  144. wx.showModal({
  145. title: '提示',
  146. content: '确定创建工单吗?',
  147. success(res) {
  148. if (res.confirm) {
  149. wx.showLoading({
  150. mask: true,
  151. });
  152. app.postReq(url, data, (res) => {
  153. console.log(res);
  154. if (res.status == 200) {
  155. that.getData(that.data.orderId);
  156. wx.hideLoading();
  157. that.setData({
  158. endFlag: true,
  159. });
  160. app.toast('创建成功');
  161. }
  162. });
  163. } else if (res.cancel) {
  164. console.log('用户点击取消');
  165. }
  166. },
  167. });
  168. },
  169. jumpDetails(e) {
  170. ////console.log("跳转路径",e)
  171. let url = e.currentTarget.dataset.url;
  172. let remark = e.currentTarget.dataset.remark;
  173. console.log(e.currentTarget.dataset.images, 'e.currentTarget.dataset.images');
  174. let images = JSON.stringify(e.currentTarget.dataset.images);
  175. const key = 'detailMapInfo';
  176. wx.setStorageSync(key, images)
  177. wx.navigateTo({
  178. url:
  179. // "/packageA/pages/historicalTrackDetailMap/historicalTrackDetailMap?url=" +
  180. '../inspectionDetailMap/inspectionDetailMap?url=' +
  181. url +
  182. '&dates=' +
  183. this.data.stringsArr +
  184. '&remark=' +
  185. remark +
  186. '&images=' +
  187. images,
  188. });
  189. },
  190. // 查看地图
  191. jumpDetailsMap() {
  192. wx.navigateTo({
  193. url:
  194. '../inspectionDetailMap/inspectionDetailMap?dates=' +
  195. this.data.stringsArr,
  196. });
  197. },
  198. formDtealis(e) {
  199. console.log(this.data.allData);
  200. // app.globalData.orderType = 0
  201. // app.globalData.orderState = 0
  202. wx.navigateTo({
  203. url: `/greenland/pages/greenOrderDetails/greenOrderDetails?orderId=${Number(
  204. this.data.allData.workIds
  205. )}&typeFlag=${this.data.allData.state}&deptType=${2}`,
  206. });
  207. },
  208. viewGD(e) {
  209. console.log(e);
  210. let index = e.currentTarget.dataset.index;
  211. let id = this.data.allData.fileListResponse[index].number3;
  212. wx.navigateTo({
  213. url: `/greenland/pages/greenOrderDetails/greenOrderDetails?orderId=${Number(
  214. id
  215. )}&deptType=${2}`,
  216. });
  217. },
  218. goWoek(e){
  219. let index = e.currentTarget.dataset.index;
  220. let id = this.data.allData.patrolTrackIssueList[index].workId;
  221. wx.navigateTo({
  222. url: `/greenland/pages/greenOrderDetails/greenOrderDetails?orderId=${Number(
  223. id
  224. )}&deptType=${2}`,
  225. });
  226. },
  227. // 预览图
  228. viewMoviePostImg: function (e) {
  229. var src = e.currentTarget.dataset.src;
  230. wx.previewImage({
  231. current: src, // 当前显示图片的http链接
  232. urls: [src], // 需要预览的图片http链接列表
  233. });
  234. },
  235. // 回到顶部
  236. scrolltoupper: function (e) {
  237. ////console.log(e)
  238. if (e.detail.scrollTop > 10) {
  239. this.setData({
  240. cangotop: true,
  241. });
  242. } else {
  243. this.setData({
  244. cangotop: false,
  245. });
  246. }
  247. },
  248. // 点击获取地图经纬度
  249. mapclick() {
  250. wx.chooseLocation({
  251. success: (res) => {
  252. console.log('经纬度', res);
  253. // 移动marker
  254. this.mapCtx.moveToLocation();
  255. },
  256. fail: (res) => {
  257. console.log('fail', res);
  258. },
  259. });
  260. },
  261. //回到顶部
  262. goTop: function (e) {
  263. // 一键回到顶部
  264. this.setData({
  265. topNum: 0,
  266. });
  267. },
  268. /**
  269. * 生命周期函数--监听页面显示
  270. */
  271. onShow: function () {},
  272. /**
  273. * 生命周期函数--监听页面隐藏
  274. */
  275. onHide: function () {},
  276. /**
  277. * 生命周期函数--监听页面卸载
  278. */
  279. onUnload: function () {
  280. let pages = getCurrentPages(); //页面栈
  281. let beforePage = '';
  282. beforePage = pages[pages.length - 2];
  283. console.log(beforePage);
  284. if (this.data.endFlag == true) {
  285. beforePage.onPullDownRefresh();
  286. }
  287. },
  288. /**
  289. * 页面相关事件处理函数--监听用户下拉动作
  290. */
  291. onPullDownRefresh: function () {},
  292. /**
  293. * 页面上拉触底事件的处理函数
  294. */
  295. onReachBottom: function () {},
  296. /**
  297. * 用户点击右上角分享
  298. */
  299. onShareAppMessage: function () {},
  300. });