orderDetail.js 18 KB

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