customerCheck.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. const app = getApp()
  2. const util = require("../../../utils/util");
  3. const api = require('../../../api/api.js');
  4. const user = require('../../../utils/user.js');
  5. const map = require('../../../utils/map');
  6. import moment from 'moment'
  7. Page({
  8. data: {
  9. detailId: '',
  10. qrCodeUrl: '',
  11. status: '',
  12. latlng: '',
  13. finishImg: '',
  14. channelId: ''
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: function (options) {
  20. if (options.serviceId) {
  21. this.setData({
  22. serviceId: options.serviceId,
  23. detailServantId: options.detailServantId,
  24. channelId: options.channelId
  25. });
  26. // this.getQrCode()
  27. }
  28. let that = this;
  29. wx.getLocation({
  30. type: 'wgs84',
  31. success(res) {
  32. console.log(res);
  33. that.setData({
  34. latlng: res.longitude + ',' + res.latitude
  35. })
  36. // const latitude = res.latitude
  37. // const longitude = res.longitude
  38. },
  39. fail(res) {
  40. wx.showToast({
  41. title: "请点击右上角打开位置授权",
  42. icon: 'none'
  43. })
  44. }
  45. })
  46. },
  47. chooseImg(e) {
  48. var that = this;
  49. wx.chooseMedia({
  50. count: 1,
  51. mediaType: ['image'],
  52. sourceType: ['camera'],
  53. camera: 'back',
  54. sizeType: ['original', 'compressed'],
  55. success: function (res) {
  56. let file = res.tempFiles[0].tempFilePath
  57. // that.upload(file);
  58. wx.compressImage({
  59. src: file, // 图片路径
  60. quality: 75, // 压缩质量
  61. success(res) {
  62. console.log(res);
  63. that.upload(res.tempFilePath);
  64. },
  65. fail: (err) => {
  66. console.error(err);
  67. wx.showToast({
  68. title: '微信压缩图片失败:' + err,
  69. icon: 'none'
  70. })
  71. }
  72. })
  73. }
  74. })
  75. },
  76. upload: function (path) {
  77. var that = this;
  78. const uploadTask = wx.uploadFile({
  79. url: api.StorageUpload(),
  80. filePath: path, //res.tempFilePaths[0],
  81. name: 'file',
  82. success: function (res) {
  83. var _res = JSON.parse(res.data);
  84. if (_res.errno === 0) {
  85. var url = _res.data.fileUrl
  86. that.setData({
  87. finishImg: url,
  88. });
  89. }
  90. }
  91. })
  92. },
  93. /**
  94. * 生命周期函数--监听页面初次渲染完成
  95. */
  96. onReady: function () {
  97. },
  98. /**
  99. * 生命周期函数--监听页面显示
  100. */
  101. onShow: function () {
  102. this.getQrCode()
  103. },
  104. goBack() {
  105. wx.navigateBack();
  106. },
  107. getQrCode() {
  108. wx.showLoading({
  109. title: '加载中...',
  110. });
  111. util.request(api.serviceOrderAcceptanceCheck, {
  112. serviceId: this.data.serviceId
  113. }, 'GET').then(res => {
  114. wx.hideLoading();
  115. if (res.errno === 0) {
  116. this.setData({
  117. qrCodeUrl: res.data.qrCodeUrl,
  118. status: res.data.status
  119. });
  120. }
  121. }).catch(err => {
  122. wx.hideLoading();
  123. });
  124. },
  125. sendFinish() {
  126. this.finishOrder();
  127. // this.sendSms();
  128. },
  129. checkFinish() {
  130. this.finishOrder(true);
  131. },
  132. finishOrder(flag) {
  133. console.log(flag);
  134. let that = this;
  135. if (this.data.channelId == 112) { //花王渠道
  136. if (this.data.finishImg == '') {
  137. wx.showToast({
  138. title: '花王工单,需上传工具包整理照片',
  139. icon: 'none'
  140. });
  141. return;
  142. }
  143. }
  144. util.request(api.finishServiceOrder, {
  145. serviceId: that.data.serviceId,
  146. detailServantId: that.data.detailServantId,
  147. latlng: that.data.latlng,
  148. address: '',
  149. finishImg: that.data.finishImg
  150. }, 'GET').then(res2 => {
  151. console.log(res2);
  152. wx.hideLoading();
  153. if (res2.errno == 0) {
  154. wx.showToast({
  155. title: '操作成功',
  156. icon: 'none',
  157. });
  158. if (flag) {
  159. wx.navigateTo({
  160. url: '/pages/problem/list/list?bookTradeNo=' + that.data.serviceId,
  161. })
  162. } else {
  163. this.sendSms();
  164. }
  165. } else {
  166. wx.showToast({
  167. title: res2.errmsg + ',' + res2.data,
  168. icon: 'none',
  169. });
  170. }
  171. }).catch(err => {
  172. wx.hideLoading();
  173. });
  174. // map.getLocation().then((res)=>{
  175. // console.log(res);
  176. // }).catch((res)=>{
  177. // console.log('fail' + JSON.stringify(res))
  178. // });
  179. },
  180. sendSms() {
  181. // wx.showLoading({
  182. // title: '加载中...',
  183. // });
  184. util.request(api.smsEvaluate, {
  185. serviceId: this.data.serviceId
  186. }, 'GET').then(res => {
  187. // wx.hideLoading();
  188. if (res.errno === 0) {
  189. }
  190. }).catch(err => {
  191. wx.hideLoading();
  192. });
  193. },
  194. onHide: function () {
  195. },
  196. onUnload: function () {
  197. },
  198. /**
  199. * 页面相关事件处理函数--监听用户下拉动作
  200. */
  201. onPullDownRefresh: function () {
  202. },
  203. /**
  204. * 页面上拉触底事件的处理函数
  205. */
  206. onReachBottom: function () {
  207. },
  208. /**
  209. * 用户点击右上角分享
  210. */
  211. onShareAppMessage: function () {
  212. },
  213. })