From 7d3cbde1af81e077d07dcc5dd20439bb4f5c05f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?TOP=E7=B3=AF=E7=B1=B3?= <1130395124@qq.com> Date: Tue, 14 Mar 2023 20:52:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=B4=A7=E8=BF=90=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E5=90=8E=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/apis.js | 48 ++++++++++++++---------- src/core/models/service.js | 46 ++++++++++++++++++++--- src/pages/service/other/distribution.vue | 11 +++++- 3 files changed, 80 insertions(+), 25 deletions(-) diff --git a/src/core/apis.js b/src/core/apis.js index d7d4bdf..bc5e5a5 100644 --- a/src/core/apis.js +++ b/src/core/apis.js @@ -128,29 +128,39 @@ export default { carType: { url: "/wxapp/index/getallcar" }, - submit: { - url: "/wxapp/project/distribution", - auth: true, - }, - pay: { - url: "/wxapp/wxpay/payorderd", - auth: true, - } } }, order: { + create: { + t1: { + url: "/wxapp/order/submitordera", + auth: true, + }, + t2: { + url: "/wxapp/orderb/addorder", + auth: true, + }, + t3: { + url: "/wxapp/project/distribution", + auth: true, + } + }, pay: { - url: "/wxapp/wxpay/payordera", - showLoading: true, - auth: true, - }, - createOrder: { - url: "/wxapp/order/submitordera", - auth: true, - }, - createDemandOrder: { - url: "/wxapp/orderb/addorder", - auth: true, + t1: { + url: "/wxapp/wxpay/payordera", + showLoading: true, + auth: true, + }, + t2: { + url: "/wxapp/wxpay/payorderc", + showLoading: true, + auth: true, + }, + t3: { + url: "/wxapp/wxpay/payorderd", + showLoading: true, + auth: true, + } }, list: { // 购买订单 diff --git a/src/core/models/service.js b/src/core/models/service.js index c29951e..97ffaac 100644 --- a/src/core/models/service.js +++ b/src/core/models/service.js @@ -151,7 +151,7 @@ export default { data: data, }).then(response => { if (response.code == 1) { - return resolve(response.data); + return resolve(response); } return reject(response.msg); }).catch(e => { }); @@ -200,7 +200,7 @@ export default { createDistributionOrder(data) { return new Promise((resolve, reject) => { prototype.$request({ - api: "service.distribution.submit", + api: "order.create.t3", data: data, }).then(response => { if (response.code == 1) { @@ -210,21 +210,57 @@ export default { }).catch(e => { }); }); }, + /** + * 支付需求订单 + */ + payDemandOrder(id) { + return new Promise((resolve, reject) => { + prototype.$request({ + api: "order.pay.t2", + data: { + id: id + } + }).then(response => { + if (response.code == 1) { + uni.requestPayment({ + ...response.data, + provider: "wxpay", + success() { + resolve(); + }, + fail() { + reject(); + } + }); + } + }).catch(e => { + throw e + }); + }); + }, /** * 支付货运订单 */ payDistributionOrder(id) { return new Promise((resolve, reject) => { prototype.$request({ - api: "service.distribution.pay", + api: "order.pay.t3", data: { id: id, } }).then(response => { if (response.code == 1) { - return resolve(response.data); + uni.requestPayment({ + ...response.data, + provider: "wxpay", + success() { + resolve(); + }, + fail() { + reject(); + } + }); } - return reject(response.msg); }).catch(e => { }); }); } diff --git a/src/pages/service/other/distribution.vue b/src/pages/service/other/distribution.vue index 752b311..fb7836c 100644 --- a/src/pages/service/other/distribution.vue +++ b/src/pages/service/other/distribution.vue @@ -207,7 +207,16 @@ export default { distance: this.distance, }) .then((data) => { - this.$models.service.payDistributionOrder(data.id); + this.$models.service + .payDistributionOrder(data.id) + .then((response) => { + this.$utils.toast(response.msg).then(() => { + this.$utils.toPage("/pages/order/order", {}, "switch"); + }); + }) + .catch(() => { + this.$utils.toPage("/pages/order/order", {}, "switch"); + }); }) .catch((e) => { this.$utils.toast(e);