H5支持微信支付
This commit is contained in:
@ -141,6 +141,7 @@ export function handleOrderPayResults(data, type) {
|
||||
break;
|
||||
// APP支付
|
||||
case "WECHAT_APP_PAY":
|
||||
|
||||
weappPay(data.result.jsConfig).finally(() => {
|
||||
goOrderDetails(data.result.orderId, type)
|
||||
});
|
||||
|
@ -1,8 +1,38 @@
|
||||
import { getProvider } from "@/utils";
|
||||
import WechatJSSDK from "wechat-jssdk/dist/client.umd";
|
||||
import { getWechatConfig, wechatAuth } from "@/api/public";
|
||||
import { parseQuery } from "@/utils";
|
||||
import cookie from "@/utils/store/cookie";
|
||||
import store from "@/store";
|
||||
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;
|
||||
}, 100);
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
if (store.state.$deviceType == 'weixin') {
|
||||
pay(option).then(() => {
|
||||
uni.showToast({
|
||||
title: '支付成功', icon: 'success', duration: 5000,
|
||||
});
|
||||
resolve()
|
||||
})
|
||||
.finally(res => {
|
||||
//if(typeof(res) == "undefined") return
|
||||
})
|
||||
.catch(function () {
|
||||
uni.showToast({ title: '支付失败', icon: 'none', duration: 5000 });
|
||||
reject()
|
||||
});
|
||||
return
|
||||
}
|
||||
// 吊起微信支付
|
||||
// getProvider('payment').then(provider => {
|
||||
let orderInfo = {
|
||||
@ -44,13 +74,6 @@ export const weappPay = (option) => {
|
||||
|
||||
|
||||
|
||||
import WechatJSSDK from "wechat-jssdk/dist/client.umd";
|
||||
import { getWechatConfig, wechatAuth } from "@/api/public";
|
||||
import { parseQuery } from "@/utils";
|
||||
import cookie from "@/utils/store/cookie";
|
||||
import store from "@/store";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
const STATE_KEY = "wx_authorize_state";
|
||||
const WX_AUTH = "wx_auth";
|
||||
const BACK_URL = "login_back_url";
|
||||
@ -178,6 +201,7 @@ function toPromise(fn, config = {}) {
|
||||
}
|
||||
|
||||
export function pay(config) {
|
||||
console.log(instance)
|
||||
return toPromise(instance.chooseWXPay, config);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user