work-order-detail.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. // pagesPublic/pages/work-order-detail/work-order-detail.js
  2. import {
  3. imgUrl
  4. } from "../api/request"
  5. import {
  6. baseUrl,
  7. request
  8. } from "../../../pages/api/canteen-request.js"
  9. Page({
  10. /**
  11. * 页面的初始数据
  12. */
  13. data: {
  14. imgUrl: imgUrl,
  15. isUser: true,
  16. colorComplete: '#508FF4',
  17. colorIncomplete: '#999999',
  18. complete: true,
  19. statusText2: '待审核',
  20. statusText3: '待上门',
  21. statusText4: '待确认',
  22. tempFileList: []
  23. },
  24. /**
  25. * 生命周期函数--监听页面加载
  26. */
  27. onLoad(options) {
  28. console.info(options);
  29. this.setData({
  30. isUser: options.isuser
  31. });
  32. request({
  33. url: '/mini/worker/orderInfo',
  34. method: 'GET',
  35. data: {
  36. 'id': options.id
  37. }
  38. }).then(res => {
  39. console.info(res)
  40. let data = res.data;
  41. this.setData({
  42. type: data.repairType,
  43. address: data.maintenanceAddress,
  44. phone: data.phoneNum,
  45. arriveTime: data.appointmentTime,
  46. description: data.userDescription
  47. });
  48. request({
  49. url: '/food/getFoodPicByPicId',
  50. method: 'GET',
  51. data: {
  52. 'picId': data.repairPic
  53. }
  54. }).then(re => {
  55. console.info(re)
  56. if (re.data && re.data.length > 0) {
  57. let arr = [];
  58. for (let i in re.data) {
  59. arr.push(baseUrl + '/' + re.data[i].path);
  60. }
  61. this.setData({
  62. image: arr
  63. });
  64. }
  65. });
  66. if (data.status == 0) {
  67. this.setData({
  68. checked2: '',
  69. checked3: '',
  70. checked4: '',
  71. });
  72. } else if (data.status == 1) {
  73. this.setData({
  74. checked2: 'checked',
  75. checked3: '',
  76. checked4: '',
  77. statusText2: '已审核'
  78. });
  79. } else if (data.status == 2) {
  80. this.setData({
  81. checked2: 'checked',
  82. checked3: 'checked',
  83. checked4: '',
  84. statusText2: '已审核',
  85. statusText3: '已上门'
  86. });
  87. } else if (data.status == 3) {
  88. this.setData({
  89. checked2: 'checked',
  90. checked3: 'checked',
  91. checked4: 'checked',
  92. statusText2: '已审核',
  93. statusText3: '已上门',
  94. statusText4: '已确认'
  95. });
  96. } else {
  97. this.setData({
  98. checked2: 'checked',
  99. checked3: 'checked',
  100. checked4: 'checked',
  101. statusText2: '已审核',
  102. statusText3: '已上门',
  103. statusText4: '已确认'
  104. });
  105. }
  106. });
  107. },
  108. /**
  109. * 生命周期函数--监听页面初次渲染完成
  110. */
  111. onReady() {
  112. },
  113. /**
  114. * 生命周期函数--监听页面显示
  115. */
  116. onShow() {
  117. },
  118. /**
  119. * 生命周期函数--监听页面隐藏
  120. */
  121. onHide() {
  122. },
  123. /**
  124. * 生命周期函数--监听页面卸载
  125. */
  126. onUnload() {
  127. },
  128. /**
  129. * 点击返回上一层页面
  130. */
  131. backTap() {
  132. wx.navigateBack();
  133. },
  134. radioChange(e) {
  135. console.info(e)
  136. // e.detail.value
  137. if (e.detail.value == '已完成') {
  138. this.setData({
  139. colorComplete: '#508FF4',
  140. colorIncomplete: '#999999',
  141. complete: true
  142. });
  143. } else {
  144. this.setData({
  145. colorComplete: '#999999',
  146. colorIncomplete: '#508FF4',
  147. complete: false
  148. });
  149. }
  150. },
  151. /**
  152. * 上传报修结果图片
  153. */
  154. uploadImage() {
  155. wx.chooseMedia({
  156. success(res) {
  157. console.info(res);
  158. if (res.errMsg == 'chooseMedia:ok') {
  159. let tempList = this.data.tempFileList;
  160. for (let i in res.tempFiles) {
  161. tempList.push(res.tempFiles[i].tempFilePath);
  162. }
  163. this.setData({
  164. tempFileList: tempList
  165. });
  166. }
  167. }
  168. });
  169. },
  170. submitReport(e) {
  171. console.info(e)
  172. let complete = this.data.complete;
  173. if (!complete && !e.detail.value.reason) {
  174. wx.showToast({
  175. title: '请填写失败原因',
  176. icon: 'error'
  177. });
  178. return;
  179. }
  180. let formData = new FormData();
  181. if (complete) {
  182. formData.append('status', 3);
  183. } else {
  184. formData.append('status', -1);
  185. }
  186. formData.append('workerDescription', e.detail.value.reason);
  187. // formData.append('userId', wx.getStorageSync('userid'));
  188. for (let i in tempList) {
  189. formData.appendFile('files', tempList[i]);
  190. }
  191. let data = formData.getData();
  192. request({
  193. url: '/mini/worker/closeOrder',
  194. method: 'POST',
  195. data: data.buffer,
  196. contentType: data.contentType
  197. }).then(res => {
  198. console.info(res)
  199. if (res.result) {
  200. wx.showToast({
  201. title: '提交成功',
  202. icon: 'success',
  203. mask: true,
  204. });
  205. setTimeout(() => {
  206. wx.navigateBack();
  207. }, 1500);
  208. } else {
  209. wx.showToast({
  210. title: '提交失败',
  211. icon: 'error',
  212. mask: true
  213. });
  214. }
  215. });
  216. },
  217. })