orderDetail.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. var util = require('../../../utils/util.js');
  2. var api = require('../../../config/api.js');
  3. Page({
  4. data: {
  5. excludeAxb: '',
  6. //订单不包含安心包,才可以退款
  7. orderId: 0,
  8. payOverTime: 0,
  9. timer: '',
  10. remainTimes: '',
  11. orderInfo: {},
  12. dyDetails: [],
  13. afterSale: null,
  14. orderGoods: [],
  15. expressInfo: {},
  16. flag: false,
  17. handleOption: {},
  18. orderType: 0, //如果是1表示从引荐人的订单列表过来的,需要隐藏操作按钮
  19. shopPhone: '',
  20. complainTips: false,
  21. ticketTips: false, //投诉工单 处理结果回收
  22. ticketId: '', //投诉id
  23. satisfaction: 0, //投诉处理满意度
  24. satisfactionTips: {},
  25. satisfactionLow: {
  26. tips: '非常抱歉,我们会立即安排专属客服跟进了解具体问题!',
  27. notice: '您的评价是对我们最大的鼓励和鞭策,感谢您的评价。'
  28. },
  29. satisfactionMid: {
  30. tips: '我们会持续了解问题,为您提供更好的服务',
  31. notice: '感谢您的评价,我们会持续收集顾客的建议,优化服务!'
  32. },
  33. satisfactionHigh: {
  34. tips: '感谢您的认可,我们将为您持续提供优质服务',
  35. notice: '感谢您的认可,我们将持续为您提供更加优质的服务!'
  36. },
  37. star: '/static/images/new/star.png',
  38. starYellow: '/static/images/new/star_yellow.png',
  39. starRed: '/static/images/new/star_red.png',
  40. msgShow: false, //客户追加备注
  41. message: '', //备注信息
  42. cancelList: [{
  43. id: 19,
  44. value: "临时有事,暂时不预约"
  45. },
  46. {
  47. id: 20,
  48. value: "先屯着后面预约"
  49. },
  50. {
  51. id: 21,
  52. value: "服务商原因,保洁师无法上门"
  53. }
  54. ], //取消页面
  55. cancelShow: false,
  56. cancelDetailId: '',
  57. cancelReason: '', //选中的取消原因项
  58. isShowPL: false //是否台数的商品 直接显示上门时间和服务内容
  59. },
  60. cancelItemConfirm() {
  61. let that = this;
  62. if (that.data.cancelReason == '') {
  63. util.showErrorToast("请选择取消原因");
  64. return;
  65. }
  66. wx.showLoading({
  67. title: '提交中'
  68. });
  69. util.request(api.OrderBookCancel, {
  70. detailId: that.data.cancelDetailId,
  71. cancelReason: that.data.cancelReason
  72. }, "POST").then(res => {
  73. wx.hideLoading();
  74. if (res.errno === 0) {
  75. wx.showToast({
  76. title: "提交成功"
  77. });
  78. let items = that.data.dyDetails;
  79. items.forEach(item => {
  80. if (item.id == that.data.cancelDetailId) {
  81. item.isCancel = false;
  82. item.statusVal = "已取消";
  83. item.status = 6;
  84. }
  85. })
  86. this.setData({
  87. cancelShow: false,
  88. dyDetails: items,
  89. 'orderInfo.handleOption.book': true,
  90. 'orderInfo.detailId': res.data
  91. })
  92. }
  93. })
  94. },
  95. goCancelBook(e) { //取消工单预约
  96. this.setData({
  97. cancelDetailId: e.currentTarget.dataset.id,
  98. cancelShow: true
  99. })
  100. },
  101. cancelItemSelect(e) {
  102. this.setData({
  103. cancelReason: e.currentTarget.dataset.id
  104. })
  105. },
  106. onCancelPopupClose() {
  107. this.setData({
  108. cancelShow: false
  109. })
  110. },
  111. onCancelClick() {
  112. //无实际意义 防止冒泡
  113. },
  114. cancelTicketTips() {
  115. this.setData({
  116. ticketTips: false,
  117. })
  118. },
  119. showMsg() {
  120. this.setData({
  121. msgShow: true
  122. })
  123. },
  124. onMsgClose() {
  125. this.setData({
  126. msgShow: false
  127. })
  128. },
  129. confirmMsg() {
  130. if (this.data.message == '') {
  131. util.showErrorToast("请输入备注");
  132. return;
  133. }
  134. let that = this;
  135. wx.showLoading({
  136. title: '提交中'
  137. });
  138. util.request(api.OrderMsg, {
  139. orderId: that.data.orderId,
  140. message: that.data.message
  141. }, "POST").then(function (res) {
  142. wx.hideLoading();
  143. if (res.errno === 0) {
  144. wx.showToast({
  145. title: "提交成功"
  146. });
  147. //赋值给所有工单
  148. let dyDetails = that.data.dyDetails;
  149. dyDetails.forEach(item => {
  150. item.customerRemark = that.data.message
  151. })
  152. that.setData({
  153. msgShow: false,
  154. dyDetails: dyDetails
  155. })
  156. }
  157. })
  158. },
  159. bindMsgInput(e) {
  160. this.setData({
  161. message: e.detail.value
  162. });
  163. },
  164. showTicketTips(e) {
  165. let ticketId = parseInt(e.currentTarget.dataset.id);
  166. this.setData({
  167. ticketTips: true,
  168. ticketId: ticketId
  169. })
  170. },
  171. selectTicketValue(e) { //点击星号
  172. let id = parseInt(e.currentTarget.dataset.id);
  173. this.setData({
  174. satisfaction: id
  175. })
  176. let tips = this.data.satisfactionLow;
  177. if (id >= 3 && id < 5)
  178. tips = this.data.satisfactionMid
  179. else if (id == 5)
  180. tips = this.data.satisfactionHigh
  181. this.setData({
  182. satisfactionTips: tips
  183. })
  184. },
  185. confTicketTips() {
  186. if (this.data.satisfaction == 0) {
  187. util.showErrorToast("请选择满意度");
  188. return;
  189. }
  190. let that = this;
  191. wx.showLoading({
  192. title: '提交中'
  193. });
  194. util.request(api.TicketSatisfaction, {
  195. id: that.data.ticketId,
  196. satisfaction: that.data.satisfaction
  197. }, "POST").then(function (res) {
  198. if (res.errno === 0) {
  199. wx.hideLoading();
  200. //隐藏弹框并设置工单为已评论过
  201. let dyDetails = that.data.dyDetails;
  202. dyDetails.forEach(detail => {
  203. if (detail.ticketVo && detail.ticketVo.ticketId == that.data.ticketId) {
  204. detail.ticketVo.isSatisfaction = false;
  205. console.info("进入")
  206. console.info(detail)
  207. }
  208. });
  209. that.setData({
  210. ticketTips: false,
  211. dyDetails: dyDetails
  212. });
  213. wx.showToast({
  214. title: that.data.satisfactionTips.notice,
  215. icon: 'none',
  216. duration: 2000
  217. });
  218. }
  219. });
  220. },
  221. onLoad: function (options) {
  222. // 页面初始化 options为页面跳转所带来的参数
  223. this.setData({
  224. orderId: options.id,
  225. orderType: options.orderType
  226. });
  227. // this.getOrderDetail();
  228. },
  229. onShow: function () {
  230. // 页面显示
  231. this.getOrderDetail();
  232. },
  233. onPullDownRefresh() {
  234. wx.showNavigationBarLoading(); //在标题栏中显示加载
  235. this.getOrderDetail();
  236. wx.hideNavigationBarLoading(); //完成停止加载
  237. wx.stopPullDownRefresh(); //停止下拉刷新
  238. },
  239. expandDetail: function () {
  240. let that = this;
  241. this.setData({
  242. flag: !that.data.flag
  243. });
  244. },
  245. getOrderDetail: function () {
  246. wx.showLoading({
  247. title: '加载中'
  248. });
  249. setTimeout(function () {
  250. wx.hideLoading();
  251. }, 2000);
  252. let that = this;
  253. util.request(api.OrderDetail, {
  254. orderId: that.data.orderId
  255. }).then(function (res) {
  256. if (res.errno === 0) {
  257. wx.hideLoading();
  258. console.log(11)
  259. //获取预约开始时间
  260. res.data.dyDetails.forEach(item => {
  261. if (item.bookTime)
  262. item.bookStartTime = item.bookTime.substring(0, 16);
  263. });
  264. that.setData({
  265. orderInfo: res.data,
  266. dyDetails: res.data.dyDetails,
  267. afterSale: res.data.afterSale,
  268. payOverTime: res.data.payOverTime,
  269. remainTimes: res.data.serviceTimes - res.data.servedTimes,
  270. message: res.data.message
  271. // orderGoods: res.data.orderGoods,
  272. // handleOption: res.data.orderInfo.handleOption,
  273. // expressInfo: res.data.expressInfo
  274. });
  275. //是否为按台服务的商品--按台服务商品 展示服务内容 通过关键字:空调、油烟机、洗衣机、冰箱
  276. if (res.data.goodsName.indexOf('空调') >= 0 || res.data.goodsName.indexOf('油烟机') >= 0 ||
  277. res.data.goodsName.indexOf('洗衣机') >= 0 || res.data.goodsName.indexOf('冰箱') >= 0) {
  278. that.setData({
  279. isShowPL: true
  280. })
  281. }
  282. if (that.data.payOverTime > 0) {
  283. let timer = setInterval(() => {
  284. let newTime = that.data.payOverTime - 1;
  285. if (newTime >= 0) {
  286. that.setData({
  287. payOverTime: newTime
  288. });
  289. } else {
  290. clearInterval(that.data.timer);
  291. }
  292. }, 1000);
  293. that.setData({
  294. timer: timer
  295. });
  296. }
  297. }
  298. // let excludeAxb = res.data.orderGoods.every(item => {
  299. // return item.goodsSn != '1036016';
  300. // });
  301. // that.setData({
  302. // excludeAxb: excludeAxb
  303. // });
  304. });
  305. },
  306. // “去付款”按钮点击效果
  307. payOrder: function () {
  308. let that = this;
  309. util.request(api.OrderPayCheck, {
  310. orderId: that.data.orderInfo.id
  311. }, 'POST').then(function (res) {
  312. if (res.errno === 0) {
  313. const outOrderNo = res.data;
  314. console.log(res);
  315. wx.continueToPay({
  316. // orderId: this.data.orderId, // 内部订单号
  317. outOrderNo: outOrderNo, // 外部订单号 2个订单号必填一个
  318. success: res => {
  319. console.log(res);
  320. const {
  321. orderId,
  322. outOrderNo
  323. } = res;
  324. console.log('success res', res);
  325. console.log('orderId', orderId, 'outOrderNo', outOrderNo);
  326. wx.redirectTo({
  327. url: '/pages/ucenter/order/order'
  328. });
  329. },
  330. fail: res => {
  331. console.log(res);
  332. const {
  333. orderId,
  334. outOrderNo,
  335. errNo,
  336. errMsg,
  337. errLogId
  338. } = res;
  339. if (errLogId) {
  340. console.log('查询订单信息失败', errNo, errMsg, errLogId);
  341. }
  342. if (orderId || outOrderNo) {
  343. console.log('支付失败', errNo, errMsg, orderId, outOrderNo);
  344. }
  345. util.showErrorToast('支付失败');
  346. },
  347. });
  348. }
  349. });
  350. },
  351. // “取消订单”点击效果
  352. cancelOrder: function () {
  353. let that = this;
  354. let orderInfo = that.data.orderInfo;
  355. wx.showModal({
  356. title: '',
  357. content: '确定要取消此订单?',
  358. success: function (res) {
  359. if (res.confirm) {
  360. util.request(api.OrderCancel, {
  361. orderId: orderInfo.id
  362. }, 'POST').then(function (res) {
  363. if (res.errno === 0) {
  364. wx.showToast({
  365. title: '取消订单成功'
  366. });
  367. util.redirect('/pages/ucenter/order/order');
  368. } else {
  369. util.showErrorToast(res.errmsg);
  370. }
  371. });
  372. }
  373. }
  374. });
  375. },
  376. // “取消订单并退款”点击效果
  377. refundOrder: function () {
  378. let that = this;
  379. let orderInfo = that.data.orderInfo;
  380. wx.showModal({
  381. title: '',
  382. content: '确定要取消此订单?',
  383. success: function (res) {
  384. if (res.confirm) {
  385. util.request(api.OrderRefund, {
  386. orderId: orderInfo.id
  387. }, 'POST').then(function (res) {
  388. if (res.errno === 0) {
  389. wx.showToast({
  390. title: '取消订单成功'
  391. });
  392. util.redirect('/pages/ucenter/order/order');
  393. } else {
  394. util.showErrorToast(res.errmsg);
  395. }
  396. });
  397. }
  398. }
  399. });
  400. },
  401. // “删除”点击效果
  402. deleteOrder: function () {
  403. let that = this;
  404. let orderInfo = that.data.orderInfo;
  405. wx.showModal({
  406. title: '',
  407. content: '确定要删除此订单?',
  408. success: function (res) {
  409. if (res.confirm) {
  410. util.request(api.OrderDelete, {
  411. orderId: orderInfo.id
  412. }, 'POST').then(function (res) {
  413. if (res.errno === 0) {
  414. wx.showToast({
  415. title: '删除订单成功'
  416. });
  417. util.redirect('/pages/ucenter/order/order');
  418. } else {
  419. util.showErrorToast(res.errmsg);
  420. }
  421. });
  422. }
  423. }
  424. });
  425. },
  426. // “待上门”点击效果
  427. confirmOrder: function () {
  428. let that = this;
  429. let orderInfo = that.data.orderInfo;
  430. wx.showModal({
  431. title: '',
  432. content: '确认上门服务?',
  433. success: function (res) {
  434. if (res.confirm) {
  435. util.request(api.OrderConfirm, {
  436. orderId: orderInfo.id
  437. }, 'POST').then(function (res) {
  438. if (res.errno === 0) {
  439. wx.showToast({
  440. title: '确认上门成功!'
  441. });
  442. util.redirect('/pages/ucenter/order/order');
  443. } else {
  444. util.showErrorToast(res.errmsg);
  445. }
  446. });
  447. }
  448. }
  449. });
  450. },
  451. // “申请售后”点击效果
  452. aftersaleOrder: function () {
  453. wx.navigateTo({
  454. url: '/pages/ucenter/applyRefund/applyRefund?id=' + this.data.orderId,
  455. });
  456. // 0没申请 1申请没审核 2 客服审核通过 3 退款成功 4审核拒绝 5 用户取消 6退款中
  457. // util.redirect('/pages/ucenter/aftersale/aftersale?id=' + this.data.orderId);
  458. // if (this.data.orderInfo.afterSaleStatus === 0||this.data.orderInfo.afterSaleStatus === 4) {
  459. // wx.navigateTo({
  460. // url:'/pages/ucenter/applyRefund/applyRefund?id=' + this.data.orderId ,
  461. // });
  462. // } else {
  463. // util.redirect('/pages/ucenter/aftersaleDetail/aftersaleDetail?id=' + this.data.orderId);
  464. // }
  465. },
  466. viewService() {
  467. wx.navigateTo({
  468. url: '../serviceDetail/serviceDetail?orderId=' + this.data.orderId
  469. });
  470. },
  471. buyAgain(e) {
  472. let id = e.currentTarget.dataset.id;
  473. wx.navigateTo({
  474. url: '/pages/goods/goods?id=' + id,
  475. });
  476. },
  477. copyOrder() {
  478. wx.setClipboardData({
  479. data: this.data.orderInfo.orderSn,
  480. success: function (res) {
  481. wx.getClipboardData({
  482. success: function (res) {
  483. wx.showToast({
  484. title: '订单编号复制成功',
  485. icon: 'success',
  486. duration: 2000
  487. });
  488. }
  489. });
  490. }
  491. });
  492. },
  493. onReady: function () {
  494. // 页面渲染完成
  495. },
  496. onHide: function () {
  497. console.log('onHide');
  498. // clearInterval(this.data.timer);
  499. },
  500. onUnload: function () {
  501. console.log('onunload');
  502. clearInterval(this.data.timer);
  503. },
  504. cancelRefund() {
  505. let that = this;
  506. let afterSale = that.data.afterSale;
  507. wx.showModal({
  508. title: '',
  509. content: '确认取消退款?',
  510. success: function (res) {
  511. if (res.confirm) {
  512. util.request(api.AftersaleCancel, {
  513. orderId: afterSale.orderId,
  514. id: afterSale.id
  515. }, 'POST').then(function (res) {
  516. if (res.errno === 0) {
  517. wx.showToast({
  518. title: '操作成功!'
  519. });
  520. that.getOrderDetail();
  521. } else {
  522. util.showErrorToast(res.errmsg);
  523. }
  524. });
  525. }
  526. }
  527. });
  528. },
  529. goReVisit(e) {
  530. let id = e.currentTarget.dataset.id;
  531. wx.navigateTo({
  532. url: '/pages/extra/newRevisit/newRevisit?id=' + id,
  533. success: (res) => {
  534. },
  535. fail: (res) => {
  536. },
  537. });
  538. },
  539. goComplain(e) {
  540. let phone = e.currentTarget.dataset.phone;
  541. this.setData({
  542. shopPhone: phone,
  543. complainTips: true
  544. })
  545. },
  546. cancelComplain() {
  547. this.setData({
  548. complainTips: false
  549. })
  550. },
  551. confComplain() {
  552. wx.makePhoneCall({
  553. phoneNumber: this.data.shopPhone
  554. });
  555. },
  556. goEditAppoint(e) {
  557. let id = e.currentTarget.dataset.id;
  558. let status = e.currentTarget.dataset.status;
  559. // if (status == 1) {
  560. // let time = e.currentTarget.dataset.time;
  561. // let str = time.substr(0, 16).replace(/-/g, '/');
  562. // let isNear = new Date(str).getTime() - new Date().getTime() - 2 * 60 * 60 * 1000;
  563. // console.log(isNear);
  564. // if (isNear < 0) {
  565. // wx.showToast({
  566. // title: '服务时间小于2小时,不能修改预约',
  567. // icon: 'none',
  568. // duration: 2000
  569. // });
  570. // return false;
  571. // }
  572. // }
  573. wx.navigateTo({
  574. url: '/pages/ucenter/appointOrder/appointOrder?serviceId=' + id + '&orderId=' + this.data.orderInfo.id,
  575. success: (res) => {
  576. },
  577. fail: (res) => {
  578. },
  579. });
  580. },
  581. // goAppoint() {
  582. // console.log(this.data.orderId );
  583. // wx.navigateTo({
  584. // url: '/pages/ucenter/appointOrder/appointOrder?orderId=' + this.data.orderId + '&serviceId=' + this.data.orderId,
  585. // });
  586. // },
  587. makeStorePhone(e) {
  588. wx.makePhoneCall({
  589. phoneNumber: e.currentTarget.dataset.phone
  590. });
  591. },
  592. goAppoint(e) {
  593. let id = e.currentTarget.dataset.id;
  594. let detailId = e.currentTarget.dataset.detail;
  595. wx.navigateTo({
  596. url: '/pages/ucenter/appointOrder/appointOrder?orderId=' + this.data.orderId + '&serviceId=' + detailId
  597. })
  598. },
  599. });