增加扫码支付页面
This commit is contained in:
parent
2882a50828
commit
dbf6a61ac7
|
|
@ -98,3 +98,13 @@ export function queryOrderStatus(data, urlType = 'order') {
|
|||
}
|
||||
})
|
||||
}
|
||||
// 分销员开通支付
|
||||
export function mchRecharge(data, urlType = 'order') {
|
||||
return request({
|
||||
url: `${urlType}/pay/distribution/mchRecharge`,
|
||||
method: "POST",
|
||||
data: {
|
||||
...data
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -107,6 +107,7 @@
|
|||
<up-switch
|
||||
:activeValue="1"
|
||||
:inactiveValue="0"
|
||||
:disabled="true"
|
||||
v-model="form.discountShare"
|
||||
size="18"
|
||||
></up-switch>
|
||||
|
|
@ -114,15 +115,16 @@
|
|||
<view class="u-flex u-m-t-32 u-col-center u-row-between">
|
||||
<view>
|
||||
<view class="color-333 u-font-28 font-bold"
|
||||
>与会员价/会员折扣同享</view
|
||||
>与会员价同享</view
|
||||
>
|
||||
<view class="color-666 u-font-24 u-m-t-16"
|
||||
>开启后,计算门槛时将会按照会员价/会员折扣价计算</view
|
||||
>开启后,计算门槛时将会按照会员价价计算</view
|
||||
>
|
||||
</view>
|
||||
<up-switch
|
||||
:activeValue="1"
|
||||
:inactiveValue="0"
|
||||
:disabled="true"
|
||||
v-model="form.vipPriceShare"
|
||||
size="18"
|
||||
></up-switch>
|
||||
|
|
|
|||
|
|
@ -92,6 +92,14 @@
|
|||
{
|
||||
"navigationBarTitleText" : "营销中心"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path" : "pages/pay",
|
||||
"pageId": "PAGES_PAY",
|
||||
"style" :
|
||||
{
|
||||
"navigationBarTitleText" : "支付"
|
||||
}
|
||||
}
|
||||
],
|
||||
"subPackages": [{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,121 @@
|
|||
<template>
|
||||
<view> </view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { mchRecharge } from "@/http/api/pay";
|
||||
import { onMounted, ref, reactive } from "vue";
|
||||
import { onLoad } from "@dcloudio/uni-app";
|
||||
const options = ref({});
|
||||
|
||||
function parseQueryString(queryString) {
|
||||
const queryParams = queryString.split("&").map((param) => param.split("="));
|
||||
const params = {};
|
||||
for (const [key, value] of queryParams) {
|
||||
params[key] = value;
|
||||
}
|
||||
return params;
|
||||
}
|
||||
onLoad((opt) => {
|
||||
console.log(opt);
|
||||
if (opt.q) {
|
||||
const q = decodeURIComponent(opt.q);
|
||||
const params = parseQueryString(q.split("?")[1]);
|
||||
Object.assign(options.value, params);
|
||||
} else {
|
||||
Object.assign(options.value, opt);
|
||||
}
|
||||
console.log(options.value);
|
||||
init();
|
||||
});
|
||||
|
||||
function wxlogin() {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.login({
|
||||
success: (res) => {
|
||||
if (res.code) {
|
||||
resolve(res.code);
|
||||
} else {
|
||||
reject(res.errMsg);
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
reject(err.errMsg);
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const pay = (res) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
uni.requestPayment({
|
||||
// #ifdef MP-WEIXIN
|
||||
provider: "wxpay", //支付类型-固定值
|
||||
partnerid: res.appId, // 微信支付商户号
|
||||
timeStamp: res.timeStamp, // 时间戳(单位:秒)
|
||||
nonceStr: res.nonceStr, // 随机字符串
|
||||
package: res.package, // 固定值
|
||||
signType: res.signType, //固定值
|
||||
paySign: res.paySign, //签名
|
||||
// #endif
|
||||
// #ifdef MP-ALIPAY
|
||||
provider: "alipay", //支付类型-固定值
|
||||
orderInfo: res.tradeNo, // 微信支付商户号
|
||||
// #endif
|
||||
success: (res) => {
|
||||
console.log("pay");
|
||||
console.log(res);
|
||||
// #ifdef MP-WEIXIN
|
||||
uni.showToast({
|
||||
title: "支付成功",
|
||||
icon: "none",
|
||||
});
|
||||
console.log("支付成功");
|
||||
resolve(true);
|
||||
// #endif
|
||||
// #ifdef MP-ALIPAY
|
||||
if (res.resultCode == "9000") {
|
||||
uni.showToast({
|
||||
title: "支付成功",
|
||||
icon: "none",
|
||||
});
|
||||
resolve(true);
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: "支付失败",
|
||||
icon: "none",
|
||||
});
|
||||
reject(false);
|
||||
}
|
||||
// #endif
|
||||
},
|
||||
fail: (res) => {
|
||||
setTimeout(() => {
|
||||
uni.hideLoading();
|
||||
}, 1000);
|
||||
reject(false);
|
||||
},
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
async function init() {
|
||||
const code = await wxlogin();
|
||||
const res = await mchRecharge({
|
||||
...options.value,
|
||||
code,
|
||||
payType: options.value.payType || "wechatPay",
|
||||
});
|
||||
if(res){
|
||||
const paySuccess= await pay(res);
|
||||
if(paySuccess){
|
||||
uni.showToast({
|
||||
title: "支付成功",
|
||||
icon: "none",
|
||||
});
|
||||
}
|
||||
}
|
||||
console.log(res);
|
||||
}
|
||||
</script>
|
||||
Loading…
Reference in New Issue