From 0e13744df225ece886456e38f190e623d340818b Mon Sep 17 00:00:00 2001 From: donqi Date: Tue, 26 Jul 2022 22:31:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BE=85=E4=B8=8A=E9=97=A8?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E5=89=8D=E8=AE=A2=E5=8D=95=E7=9A=84=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E8=AE=A2=E5=8D=95=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/js/request.js | 15 ++++++++++++++- pages/my/my-address.vue | 2 +- pages/my/my-order.vue | 26 ++++++++++++++++---------- pages/my/serv-detail.vue | 35 +++++++++++++++++++++++++++++------ 4 files changed, 60 insertions(+), 18 deletions(-) diff --git a/common/js/request.js b/common/js/request.js index 59d9c04..58e50a4 100644 --- a/common/js/request.js +++ b/common/js/request.js @@ -13,7 +13,7 @@ export default { args.url = 'https://www.opsoul.com' + args.url; // args.url = 'http://120.79.136.57' + args.url; // args.url = 'http://127.0.0.1:80' + args.url; - if (args.data) { + if (args.data && Object.prototype && Object.prototype.toString.call(args.data) === '[object Object]') { args.data.deptId = globalData.deptId; args.data.from = globalData.from; } @@ -457,6 +457,19 @@ export default { data: params }) return res[1].data; + }, + async cancelMasterOrder(params = {}) { + let res = await uni.request({ + url: '/order/master/cancel', + method: 'POST', + data: { + orderMasterId: params.orderMasterId + }, + header: { + 'content-type': 'application/x-www-form-urlencoded' + } + }) + return res[1].data; }, async getHotGoods(params = {}) { let res = await uni.request({ diff --git a/pages/my/my-address.vue b/pages/my/my-address.vue index 30e5074..69abe12 100644 --- a/pages/my/my-address.vue +++ b/pages/my/my-address.vue @@ -98,12 +98,12 @@ async delAddress() { let res = await this.$request.delAddressList(this.delAddressInfo.customerAddressId); if (res.code === 0) { + this.loadData(); uni.showToast({ title: '删除成功', icon: 'success', mask: true }) - this.loadData(); } else { uni.showToast({ title: '删除失败', diff --git a/pages/my/my-order.vue b/pages/my/my-order.vue index 9ae9ebc..9a67397 100644 --- a/pages/my/my-order.vue +++ b/pages/my/my-order.vue @@ -43,16 +43,16 @@ - + - + - + @@ -220,7 +220,8 @@ if (ifRollback) { uni.showToast({ title: '订单已回滚至服务中状态,请联系师傅', - icon: 'none' + icon: 'none', + duration: 3000 }) } } @@ -238,16 +239,21 @@ this.curOrder = null; }, async cancelOrder() { - let res = await this.$request.updateOrder({ - id: this.curOrder.orderMasterId, - orderStatus: 6 + let res = await this.$request.cancelMasterOrder({ + orderMasterId: this.curOrder.orderMasterId }); - if (res.code === 0) { + if (res && res.code === 0) { + this.reloadOrderPage(); uni.showToast({ title: '取消成功', - icon: 'success' + icon: 'success', + duration: 2000 + }) + } else { + uni.showToast({ + title: '取消失败', + icon: 'error' }) - this.reloadOrderPage(); } }, async wxpay(curOrder) { diff --git a/pages/my/serv-detail.vue b/pages/my/serv-detail.vue index 9f4d62f..0d17265 100644 --- a/pages/my/serv-detail.vue +++ b/pages/my/serv-detail.vue @@ -34,6 +34,7 @@ {{servDetail.goodsName}} 服务中 待上门 + 已取消 - + 订单管理 @@ -189,10 +190,16 @@ this.ifShowPageMeta = e.show; }, togglePopup(e) { - if (this.ifShowPageMeta) { - this.$refs[e.currentTarget.dataset.popup].close(); + let targetPopup = null; + if (typeof e === 'string') { + targetPopup = e; } else { - this.$refs[e.currentTarget.dataset.popup].open(); + targetPopup = e.currentTarget.dataset.popup; + } + if (this.ifShowPageMeta) { + this.$refs[targetPopup].close(); + } else { + this.$refs[targetPopup].open(); } }, showModal(e) { @@ -207,8 +214,24 @@ decideIfCancelOrder() { this.$refs.confirmModal.showModal(); }, - cancelOrder() { - console.log("取消订单") + async cancelOrder(e) { + let res = await this.$request.cancelMasterOrder({ + orderMasterId: this.servDetail.orderMasterId + }); + if (res && res.code === 0) { + this.togglePopup('orderManage'); + this.loadData(this.servDetail.orderMasterId); + uni.showToast({ + title: '取消成功', + icon: 'success', + duration: 2000 + }) + } else { + uni.showToast({ + title: '取消失败', + icon: 'error' + }) + } } } }