支付增加订阅功能,增加海报生成传递from类型
This commit is contained in:
@ -81,7 +81,7 @@ export async function payOrderHandle(orderId, type, from) {
|
||||
});
|
||||
payOrder(orderId, type, from)
|
||||
.then(async res => {
|
||||
await handleOrderPayResults(res.data)
|
||||
await handleOrderPayResults(res.data, type)
|
||||
resolve()
|
||||
})
|
||||
.catch(err => {
|
||||
@ -98,7 +98,9 @@ export async function payOrderHandle(orderId, type, from) {
|
||||
|
||||
// 处理调用支付接口的逻辑
|
||||
// @type create(创建订单)||pay(支付订单)
|
||||
export function handleOrderPayResults(data, type) {
|
||||
export function handleOrderPayResults(data, type, payType) {
|
||||
console.log(data, type, payType)
|
||||
|
||||
console.log(data, type)
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.hideLoading()
|
||||
@ -156,19 +158,37 @@ export function handleOrderPayResults(data, type) {
|
||||
weappPay(data.result.jsConfig).finally(() => {
|
||||
resolve()
|
||||
goOrderDetails(data.result.orderId, type)
|
||||
});
|
||||
}).then(res => {
|
||||
// #ifdef MP-WEIXIN
|
||||
subscribeMessage()
|
||||
// #endif
|
||||
})
|
||||
break;
|
||||
// APP支付
|
||||
case "WECHAT_APP_PAY":
|
||||
weappPay(data.result.jsConfig).finally(() => {
|
||||
resolve()
|
||||
goOrderDetails(data.result.orderId, type)
|
||||
});
|
||||
})
|
||||
break;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function subscribeMessage() {
|
||||
// 调用订阅
|
||||
console.log('调用订阅')
|
||||
uni.requestSubscribeMessage({
|
||||
tmplIds: ['W5r2c2kzhbq8uxStkPAVx_sk-5aapMFCqe7b7KU5jXI', '2CB_1UyQrbnlyjJa5syraqJ3cfztPPDOAHe3DEXpMjg', 'vuztugw9VbKbKJDAAVePkjqPpT5mdoREpd4Aq7EGPRU'],
|
||||
success(res) {
|
||||
console.log(res)
|
||||
},
|
||||
fail(error){
|
||||
console.log(error)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
export function goOrderDetails(id, type) {
|
||||
// 创建订单时跳转到详情
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { subscribeMessage } from "@/libs/order";
|
||||
import { getProvider } from "@/utils";
|
||||
import WechatJSSDK from "wechat-jssdk/dist/client.umd";
|
||||
import { getWechatConfig, wechatAuth } from "@/api/public";
|
||||
@ -9,7 +10,6 @@ import dayjs from "dayjs";
|
||||
// 支付模块
|
||||
export const weappPay = (option) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
console.log(option)
|
||||
if (store.state.$deviceType == 'weixinh5') {
|
||||
setTimeout(() => {
|
||||
location.href = option.mweb_url;
|
||||
@ -59,11 +59,16 @@ export const weappPay = (option) => {
|
||||
clearTimeout(time)
|
||||
resolve(success)
|
||||
}, 3000)
|
||||
// #ifdef MP-WEIXIN
|
||||
subscribeMessage()
|
||||
// #endif
|
||||
},
|
||||
fail: (error) => {
|
||||
console.log(error)
|
||||
if (error.errMsg == 'requestPayment:fail cancel') {
|
||||
uni.showToast({ title: '已取消支付', icon: 'none', duration: 5000 });
|
||||
} else {
|
||||
uni.showToast({ title: error || error.msg, icon: 'none', duration: 5000 });
|
||||
}
|
||||
reject(error)
|
||||
}
|
||||
@ -344,12 +349,20 @@ export function wxShowLocation() {
|
||||
cancel() {
|
||||
cookie.remove(LATITUDE);
|
||||
cookie.remove(LONGITUDE);
|
||||
this.$dialog.error("取消获取位置");
|
||||
uni.showToast({
|
||||
title: "取消获取位置",
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
});
|
||||
},
|
||||
fail() {
|
||||
cookie.remove(LATITUDE);
|
||||
cookie.remove(LONGITUDE);
|
||||
this.$dialog.error("授权失败");
|
||||
uni.showToast({
|
||||
title: "授权失败",
|
||||
icon: "none",
|
||||
duration: 2000,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user