orderDetail.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  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. }else{
  93. util.showErrorToast(res.errmsg);
  94. }
  95. })
  96. },
  97. goCancelBook(e) { //取消工单预约
  98. this.setData({
  99. cancelDetailId: e.currentTarget.dataset.id,
  100. cancelShow: true
  101. })
  102. },
  103. cancelItemSelect(e) {
  104. this.setData({
  105. cancelReason: e.currentTarget.dataset.id
  106. })
  107. },
  108. onCancelPopupClose() {
  109. this.setData({
  110. cancelShow: false
  111. })
  112. },
  113. onCancelClick() {
  114. //无实际意义 防止冒泡
  115. },
  116. cancelTicketTips() {
  117. this.setData({
  118. ticketTips: false,
  119. })
  120. },
  121. showMsg() {
  122. this.setData({
  123. msgShow: true
  124. })
  125. },
  126. onMsgClose() {
  127. this.setData({
  128. msgShow: false
  129. })
  130. },
  131. confirmMsg() {
  132. if (this.data.message == '') {
  133. util.showErrorToast("请输入备注");
  134. return;
  135. }
  136. let that = this;
  137. wx.showLoading({
  138. title: '提交中'
  139. });
  140. util.request(api.OrderMsg, {
  141. orderId: that.data.orderId,
  142. message: that.data.message
  143. }, "POST").then(function (res) {
  144. wx.hideLoading();
  145. if (res.errno === 0) {
  146. wx.showToast({
  147. title: "提交成功"
  148. });
  149. //赋值给所有工单
  150. let dyDetails = that.data.dyDetails;
  151. dyDetails.forEach(item => {
  152. item.customerRemark = that.data.message
  153. })
  154. that.setData({
  155. msgShow: false,
  156. dyDetails: dyDetails
  157. })
  158. }
  159. })
  160. },
  161. bindMsgInput(e) {
  162. this.setData({
  163. message: e.detail.value
  164. });
  165. },
  166. showTicketTips(e) {
  167. let ticketId = parseInt(e.currentTarget.dataset.id);
  168. this.setData({
  169. ticketTips: true,
  170. ticketId: ticketId
  171. })
  172. },
  173. selectTicketValue(e) { //点击星号
  174. let id = parseInt(e.currentTarget.dataset.id);
  175. this.setData({
  176. satisfaction: id
  177. })
  178. let tips = this.data.satisfactionLow;
  179. if (id >= 3 && id < 5)
  180. tips = this.data.satisfactionMid
  181. else if (id == 5)
  182. tips = this.data.satisfactionHigh
  183. this.setData({
  184. satisfactionTips: tips
  185. })
  186. },
  187. confTicketTips() {
  188. if (this.data.satisfaction == 0) {
  189. util.showErrorToast("请选择满意度");
  190. return;
  191. }
  192. let that = this;
  193. wx.showLoading({
  194. title: '提交中'
  195. });
  196. util.request(api.TicketSatisfaction, {
  197. id: that.data.ticketId,
  198. satisfaction: that.data.satisfaction
  199. }, "POST").then(function (res) {
  200. if (res.errno === 0) {
  201. wx.hideLoading();
  202. //隐藏弹框并设置工单为已评论过
  203. let dyDetails = that.data.dyDetails;
  204. dyDetails.forEach(detail => {
  205. if (detail.ticketVo && detail.ticketVo.ticketId == that.data.ticketId) {
  206. detail.ticketVo.isSatisfaction = false;
  207. console.info("进入")
  208. console.info(detail)
  209. }
  210. });
  211. that.setData({
  212. ticketTips: false,
  213. dyDetails: dyDetails
  214. });
  215. wx.showToast({
  216. title: that.data.satisfactionTips.notice,
  217. icon: 'none',
  218. duration: 2000
  219. });
  220. }
  221. });
  222. },
  223. onLoad: function (options) {
  224. // 页面初始化 options为页面跳转所带来的参数
  225. this.setData({
  226. orderId: options.id,
  227. orderType: options.orderType
  228. });
  229. // this.getOrderDetail();
  230. },
  231. onShow: function () {
  232. // 页面显示
  233. this.getOrderDetail();
  234. },
  235. onPullDownRefresh() {
  236. wx.showNavigationBarLoading(); //在标题栏中显示加载
  237. this.getOrderDetail();
  238. wx.hideNavigationBarLoading(); //完成停止加载
  239. wx.stopPullDownRefresh(); //停止下拉刷新
  240. },
  241. expandDetail: function () {
  242. let that = this;
  243. this.setData({
  244. flag: !that.data.flag
  245. });
  246. },
  247. getOrderDetail: function () {
  248. wx.showLoading({
  249. title: '加载中'
  250. });
  251. setTimeout(function () {
  252. wx.hideLoading();
  253. }, 2000);
  254. let that = this;
  255. util.request(api.OrderDetail, {
  256. orderId: that.data.orderId
  257. }).then(function (res) {
  258. if (res.errno === 0) {
  259. wx.hideLoading();
  260. console.log(11)
  261. //获取预约开始时间
  262. res.data.dyDetails.forEach(item => {
  263. if (item.bookTime)
  264. item.bookStartTime = item.bookTime.substring(0, 16);
  265. });
  266. that.setData({
  267. orderInfo: res.data,
  268. dyDetails: res.data.dyDetails,
  269. afterSale: res.data.afterSale,
  270. payOverTime: res.data.payOverTime,
  271. remainTimes: res.data.serviceTimes - res.data.servedTimes,
  272. message: res.data.message
  273. // orderGoods: res.data.orderGoods,
  274. // handleOption: res.data.orderInfo.handleOption,
  275. // expressInfo: res.data.expressInfo
  276. });
  277. //是否为按台服务的商品--按台服务商品 展示服务内容 通过关键字:空调、油烟机、洗衣机、冰箱
  278. if (res.data.goodsName.indexOf('空调') >= 0 || res.data.goodsName.indexOf('油烟机') >= 0 ||
  279. res.data.goodsName.indexOf('洗衣机') >= 0 || res.data.goodsName.indexOf('冰箱') >= 0) {
  280. that.setData({
  281. isShowPL: true
  282. })
  283. }
  284. if (that.data.payOverTime > 0) {
  285. let timer = setInterval(() => {
  286. let newTime = that.data.payOverTime - 1;
  287. if (newTime >= 0) {
  288. that.setData({
  289. payOverTime: newTime
  290. });
  291. } else {
  292. clearInterval(that.data.timer);
  293. }
  294. }, 1000);
  295. that.setData({
  296. timer: timer
  297. });
  298. }
  299. }
  300. // let excludeAxb = res.data.orderGoods.every(item => {
  301. // return item.goodsSn != '1036016';
  302. // });
  303. // that.setData({
  304. // excludeAxb: excludeAxb
  305. // });
  306. });
  307. },
  308. // “去付款”按钮点击效果
  309. payOrder: function () {
  310. let that = this;
  311. util.request(api.OrderPayCheck, {
  312. orderId: that.data.orderInfo.id
  313. }, 'POST').then(function (res) {
  314. if (res.errno === 0) {
  315. const outOrderNo = res.data;
  316. console.log(res);
  317. wx.continueToPay({
  318. // orderId: this.data.orderId, // 内部订单号
  319. outOrderNo: outOrderNo, // 外部订单号 2个订单号必填一个
  320. success: res => {
  321. console.log(res);
  322. const {
  323. orderId,
  324. outOrderNo
  325. } = res;
  326. console.log('success res', res);
  327. console.log('orderId', orderId, 'outOrderNo', outOrderNo);
  328. wx.redirectTo({
  329. url: '/pages/ucenter/order/order'
  330. });
  331. },
  332. fail: res => {
  333. console.log(res);
  334. const {
  335. orderId,
  336. outOrderNo,
  337. errNo,
  338. errMsg,
  339. errLogId
  340. } = res;
  341. if (errLogId) {
  342. console.log('查询订单信息失败', errNo, errMsg, errLogId);
  343. }
  344. if (orderId || outOrderNo) {
  345. console.log('支付失败', errNo, errMsg, orderId, outOrderNo);
  346. }
  347. util.showErrorToast('支付失败');
  348. },
  349. });
  350. }
  351. });
  352. },
  353. payOrder() {
  354. let that = this;
  355. util.request(api.OrderPrepay, {
  356. orderId: this.data.orderId
  357. }, 'POST').then(function (res) {
  358. if (res.errno === 0) {
  359. const payParam = res.data;
  360. console.log("支付过程开始")
  361. wx.requestPayment({
  362. 'timeStamp': payParam.timeStamp,
  363. 'nonceStr': payParam.nonceStr,
  364. 'package': payParam.packageValue,
  365. 'signType': payParam.signType,
  366. 'paySign': payParam.paySign,
  367. 'success': function (res) {
  368. console.log("支付过程成功")
  369. that.getOrderDetail();
  370. },
  371. 'fail': function (res) {
  372. console.log("支付过程失败")
  373. util.showErrorToast('支付失败');
  374. },
  375. 'complete': function (res) {
  376. console.log("支付过程结束")
  377. }
  378. });
  379. }else{
  380. wx.showToast({
  381. title: res.errmsg,
  382. icon: 'none'
  383. });
  384. }
  385. });
  386. },
  387. // “取消订单”点击效果
  388. cancelOrder: function () {
  389. let that = this;
  390. let orderInfo = that.data.orderInfo;
  391. wx.showModal({
  392. title: '',
  393. content: '确定要取消此订单?',
  394. success: function (res) {
  395. if (res.confirm) {
  396. util.request(api.OrderCancel, {
  397. orderId: orderInfo.id
  398. }, 'POST').then(function (res) {
  399. if (res.errno === 0) {
  400. wx.showToast({
  401. title: '取消订单成功'
  402. });
  403. util.redirect('/pages/ucenter/order/order');
  404. } else {
  405. util.showErrorToast(res.errmsg);
  406. }
  407. });
  408. }
  409. }
  410. });
  411. },
  412. // “取消订单并退款”点击效果
  413. refundOrder: function () {
  414. let that = this;
  415. let orderInfo = that.data.orderInfo;
  416. wx.showModal({
  417. title: '',
  418. content: '确定要取消此订单?',
  419. success: function (res) {
  420. if (res.confirm) {
  421. util.request(api.OrderRefund, {
  422. orderId: orderInfo.id
  423. }, 'POST').then(function (res) {
  424. if (res.errno === 0) {
  425. wx.showToast({
  426. title: '取消订单成功'
  427. });
  428. util.redirect('/pages/ucenter/order/order');
  429. } else {
  430. util.showErrorToast(res.errmsg);
  431. }
  432. });
  433. }
  434. }
  435. });
  436. },
  437. // “删除”点击效果
  438. deleteOrder: function () {
  439. let that = this;
  440. let orderInfo = that.data.orderInfo;
  441. wx.showModal({
  442. title: '',
  443. content: '确定要删除此订单?',
  444. success: function (res) {
  445. if (res.confirm) {
  446. util.request(api.OrderDelete, {
  447. orderId: orderInfo.id
  448. }, 'POST').then(function (res) {
  449. if (res.errno === 0) {
  450. wx.showToast({
  451. title: '删除订单成功'
  452. });
  453. util.redirect('/pages/ucenter/order/order');
  454. } else {
  455. util.showErrorToast(res.errmsg);
  456. }
  457. });
  458. }
  459. }
  460. });
  461. },
  462. // “待上门”点击效果
  463. confirmOrder: function () {
  464. let that = this;
  465. let orderInfo = that.data.orderInfo;
  466. wx.showModal({
  467. title: '',
  468. content: '确认上门服务?',
  469. success: function (res) {
  470. if (res.confirm) {
  471. util.request(api.OrderConfirm, {
  472. orderId: orderInfo.id
  473. }, 'POST').then(function (res) {
  474. if (res.errno === 0) {
  475. wx.showToast({
  476. title: '确认上门成功!'
  477. });
  478. util.redirect('/pages/ucenter/order/order');
  479. } else {
  480. util.showErrorToast(res.errmsg);
  481. }
  482. });
  483. }
  484. }
  485. });
  486. },
  487. // “申请售后”点击效果
  488. aftersaleOrder: function () {
  489. wx.navigateTo({
  490. url: '/pages/ucenter/applyRefund/applyRefund?id=' + this.data.orderId,
  491. });
  492. // 0没申请 1申请没审核 2 客服审核通过 3 退款成功 4审核拒绝 5 用户取消 6退款中
  493. // util.redirect('/pages/ucenter/aftersale/aftersale?id=' + this.data.orderId);
  494. // if (this.data.orderInfo.afterSaleStatus === 0||this.data.orderInfo.afterSaleStatus === 4) {
  495. // wx.navigateTo({
  496. // url:'/pages/ucenter/applyRefund/applyRefund?id=' + this.data.orderId ,
  497. // });
  498. // } else {
  499. // util.redirect('/pages/ucenter/aftersaleDetail/aftersaleDetail?id=' + this.data.orderId);
  500. // }
  501. },
  502. viewService() {
  503. wx.navigateTo({
  504. url: '../serviceDetail/serviceDetail?orderId=' + this.data.orderId
  505. });
  506. },
  507. buyAgain(e) {
  508. let id = e.currentTarget.dataset.id;
  509. wx.navigateTo({
  510. url: '/pages/goods/goods?id=' + id,
  511. });
  512. },
  513. copyOrder() {
  514. wx.setClipboardData({
  515. data: this.data.orderInfo.orderSn,
  516. success: function (res) {
  517. wx.getClipboardData({
  518. success: function (res) {
  519. wx.showToast({
  520. title: '订单编号复制成功',
  521. icon: 'success',
  522. duration: 2000
  523. });
  524. }
  525. });
  526. }
  527. });
  528. },
  529. onReady: function () {
  530. // 页面渲染完成
  531. },
  532. onHide: function () {
  533. console.log('onHide');
  534. // clearInterval(this.data.timer);
  535. },
  536. onUnload: function () {
  537. console.log('onunload');
  538. clearInterval(this.data.timer);
  539. },
  540. cancelRefund() {
  541. let that = this;
  542. let afterSale = that.data.afterSale;
  543. wx.showModal({
  544. title: '',
  545. content: '确认取消退款?',
  546. success: function (res) {
  547. if (res.confirm) {
  548. util.request(api.AftersaleCancel, {
  549. orderId: afterSale.orderId,
  550. id: afterSale.id
  551. }, 'POST').then(function (res) {
  552. if (res.errno === 0) {
  553. wx.showToast({
  554. title: '操作成功!'
  555. });
  556. that.getOrderDetail();
  557. } else {
  558. util.showErrorToast(res.errmsg);
  559. }
  560. });
  561. }
  562. }
  563. });
  564. },
  565. goReVisit(e) {
  566. let id = e.currentTarget.dataset.id;
  567. wx.navigateTo({
  568. url: '/pages/extra/newRevisit/newRevisit?id=' + id,
  569. success: (res) => {
  570. },
  571. fail: (res) => {
  572. },
  573. });
  574. },
  575. goComplain(e) {
  576. let phone = e.currentTarget.dataset.phone;
  577. this.setData({
  578. shopPhone: phone,
  579. complainTips: true
  580. })
  581. },
  582. cancelComplain() {
  583. this.setData({
  584. complainTips: false
  585. })
  586. },
  587. confComplain() {
  588. wx.makePhoneCall({
  589. phoneNumber: this.data.shopPhone
  590. });
  591. },
  592. goEditAppoint(e) {
  593. let id = e.currentTarget.dataset.id;
  594. let status = e.currentTarget.dataset.status;
  595. // if (status == 1) {
  596. // let time = e.currentTarget.dataset.time;
  597. // let str = time.substr(0, 16).replace(/-/g, '/');
  598. // let isNear = new Date(str).getTime() - new Date().getTime() - 2 * 60 * 60 * 1000;
  599. // console.log(isNear);
  600. // if (isNear < 0) {
  601. // wx.showToast({
  602. // title: '服务时间小于2小时,不能修改预约',
  603. // icon: 'none',
  604. // duration: 2000
  605. // });
  606. // return false;
  607. // }
  608. // }
  609. wx.navigateTo({
  610. url: '/pages/ucenter/appointOrder/appointOrder?serviceId=' + id + '&orderId=' + this.data.orderInfo.id,
  611. success: (res) => {
  612. },
  613. fail: (res) => {
  614. },
  615. });
  616. },
  617. // goAppoint() {
  618. // console.log(this.data.orderId );
  619. // wx.navigateTo({
  620. // url: '/pages/ucenter/appointOrder/appointOrder?orderId=' + this.data.orderId + '&serviceId=' + this.data.orderId,
  621. // });
  622. // },
  623. makeStorePhone(e) {
  624. wx.makePhoneCall({
  625. phoneNumber: e.currentTarget.dataset.phone
  626. });
  627. },
  628. goAppoint(e) {
  629. let id = e.currentTarget.dataset.id;
  630. let detailId = e.currentTarget.dataset.detail;
  631. wx.navigateTo({
  632. url: '/pages/ucenter/appointOrder/appointOrder?orderId=' + this.data.orderId + '&serviceId=' + detailId
  633. })
  634. },
  635. goIm(){
  636. wx.navigateTo({
  637. url: '/pages/im/im'
  638. });
  639. },
  640. });