From 583c1b8d8105caf57c4ee47e40c60c8bd4c36b63 Mon Sep 17 00:00:00 2001 From: hupeng Date: Wed, 6 Dec 2023 17:14:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E8=AE=A2=E9=98=85=E6=B6=88=E6=81=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/index.js | 2 +- libs/order.js | 47 +++++++++++++++++++-------- pages/order/OrderSubmission/index.vue | 11 +++++-- 3 files changed, 42 insertions(+), 18 deletions(-) diff --git a/config/index.js b/config/index.js index 9eec2c8..4359881 100644 --- a/config/index.js +++ b/config/index.js @@ -1,5 +1,5 @@ // export const VUE_APP_API_URL = 'http://natapp.xinxintuan.co/api'; -// export const VUE_APP_API_URL = 'https://wxapi.yixiang.co/api' +//export const VUE_APP_API_URL = 'https://wxapi.yixiang.co/api' // export const VUE_APP_API_URL = '/h5api' export const VUE_APP_API_URL = 'http://127.0.0.1:8008/api' // export const VUE_APP_API_URL = 'http://192.168.31.223:8008/api' diff --git a/libs/order.js b/libs/order.js index 511f25a..07e0ade 100644 --- a/libs/order.js +++ b/libs/order.js @@ -120,9 +120,13 @@ export async function payOrderHandle(orderId, type, from) { // 处理调用支付接口的逻辑 // @type create(创建订单)||pay(支付订单) -export function handleOrderPayResults(data, type, payType) { +export function handleOrderPayResults(data, type, payType) { + // #ifdef MP-WEIXIN + //subscribeMessage() + // #endif return new Promise((resolve, reject) => { - uni.hideLoading() + uni.hideLoading() + switch (data.status) { // 订单号已存在 case "ORDER_EXIST": @@ -179,7 +183,7 @@ export function handleOrderPayResults(data, type, payType) { goOrderDetails(data.result.orderId, type) }).then(res => { // #ifdef MP-WEIXIN - subscribeMessage() + //subscribeMessage() // #endif }) break; @@ -196,18 +200,33 @@ export function handleOrderPayResults(data, type, payType) { export function subscribeMessage() { // 调用订阅 - console.log('调用订阅') + console.log('调用订阅') + getSubscribeTemplate() - .then(res => { - uni.requestSubscribeMessage({ - tmplIds: res.data, - success(res) { - console.log(res) - }, - fail(error) { - console.log(error) - } - }) + .then(res => { + wx.showModal({ + title: '温馨提示', + content: '为更好的促进您与商家的交流,小程序需要在您成交时向您发送消息', + confirmText: "同意", + cancelText: "拒绝", + success: function(res1) { + if (res1.confirm) { + uni.requestSubscribeMessage({ + tmplIds: res.data, + success(res2) { + console.log('res01:',res2) + }, + fail(error) { + console.log('res02:',error) + } + }) + } else { + //revolve(true) + } + } + }) + + }) .catch(err => {}); } diff --git a/pages/order/OrderSubmission/index.vue b/pages/order/OrderSubmission/index.vue index cb5d341..eb205d7 100644 --- a/pages/order/OrderSubmission/index.vue +++ b/pages/order/OrderSubmission/index.vue @@ -310,7 +310,11 @@ export default { this.computedPrice() }, }, - onLoad: function() { + onLoad: function() { + // #ifdef MP-WEIXIN + + subscribeMessage() + // #endif let that = this this.$store.dispatch('getUser', true) that.getCartInfo() @@ -511,8 +515,9 @@ export default { from.from = 'app' } console.log(this.$deviceType) - // #ifdef MP-WEIXIN - subscribeMessage() + // #ifdef MP-WEIXIN + + // subscribeMessage() // #endif createOrder(this.orderGroupInfo.orderKey, { realName: this.contacts,