fix: 接入抖音原生支付并修复App支付服务缺失
This commit is contained in:
@@ -268,6 +268,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { appDypayFun, prepareDouyinPay, douyinPayTypes, filterDouyinPayWays } from '@/utils/douyin-pay.js';
|
||||
import { ORDER_TYPE, ORDER_STATUS, getValue, LOGISTICS_STATUS_UPDATE } from "@/utils/enumUtils.js";
|
||||
import QrcodePreview from "@/components/qrcode-preview.vue";
|
||||
import {
|
||||
@@ -285,7 +286,6 @@ import {
|
||||
import {
|
||||
appWxpayFun,
|
||||
zfbPayFun,
|
||||
douyinPayFun,
|
||||
jumpWayOk,
|
||||
jumpWayError,
|
||||
} from "@/utils/payUtils.js";
|
||||
@@ -357,7 +357,7 @@ export default {
|
||||
async getWayOption() {
|
||||
console.log("orderInfo", this.orderInfo);
|
||||
let params = {
|
||||
types: "1,2,3",
|
||||
types: douyinPayTypes("1,2,3"),
|
||||
};
|
||||
// #ifdef APP-PLUS
|
||||
params.types = "1,2,3,6"
|
||||
@@ -365,10 +365,10 @@ export default {
|
||||
|
||||
const result = await getSupportPay(params);
|
||||
if (result && result.bizcode === 100) {
|
||||
const data = result.data || [];
|
||||
const data = filterDouyinPayWays(result.data);
|
||||
const amount = this.orderInfo.sumAmount;
|
||||
let flag = data.some((item) =>
|
||||
["wechat", "alipay"].includes(item.type)
|
||||
["wechat", "alipay", "douyin"].includes(item.type)
|
||||
);
|
||||
// 没有支付宝和微信支付
|
||||
if (flag) {
|
||||
@@ -410,6 +410,9 @@ export default {
|
||||
},
|
||||
// 去支付
|
||||
async goPay() {
|
||||
if (this._paySubmitting) return;
|
||||
this._paySubmitting = true;
|
||||
try {
|
||||
const payway = this.wayForm.payway;
|
||||
if (!payway || payway === 0) {
|
||||
this.$refs.uToastRef.show({
|
||||
@@ -422,6 +425,7 @@ export default {
|
||||
id: this.orderInfo.id,
|
||||
payway,
|
||||
};
|
||||
if (!await prepareDouyinPay(payway)) return;
|
||||
const resp = await payment(params);
|
||||
// 提交订单成功,就唤起支付
|
||||
if (resp && resp.bizcode === 100) {
|
||||
@@ -430,7 +434,9 @@ export default {
|
||||
jumpWayOk();
|
||||
return;
|
||||
}
|
||||
if (item.wechat && Object.keys(item.wechat).length !== 0) {
|
||||
if (item.douyin) {
|
||||
await appDypayFun(item);
|
||||
} else if (item.wechat && Object.keys(item.wechat).length !== 0) {
|
||||
this.appWxpay(item.wechat, item.orderId, item.orderNum);
|
||||
} else if (
|
||||
item.alipay &&
|
||||
@@ -438,9 +444,6 @@ export default {
|
||||
item.alipay
|
||||
) {
|
||||
this.zfbPay(item.alipay, item.orderId, item.orderNum);
|
||||
} else if (item.douyin && Object.keys(item.douyin).length !== 0) {
|
||||
// 抖音支付
|
||||
this.appDouying(item.douyin, item.orderId, item.orderNum);
|
||||
} else {
|
||||
this.$refs.uToastRef.show({
|
||||
type: "error",
|
||||
@@ -453,19 +456,10 @@ export default {
|
||||
} else {
|
||||
this.getOrderInfo();
|
||||
}
|
||||
},
|
||||
// app 抖音支付
|
||||
async appDouying(douyin, orderId, orderNum) {
|
||||
try {
|
||||
const result = await douyinPayFun(douyin, orderId, orderNum);
|
||||
console.log("抖音支付发起成功", result);
|
||||
// 处理支付发起成功后的逻辑
|
||||
} catch (error) {
|
||||
console.error("抖音支付失败", error);
|
||||
// 处理支付失败后的逻辑
|
||||
}
|
||||
uni.showToast({ title: error.message || error.msg || '支付请求失败,请查看订单后重试', icon: 'none' });
|
||||
} finally { this._paySubmitting = false; }
|
||||
},
|
||||
|
||||
// app 微信支付
|
||||
async appWxpay(alipay, orderId, orderNum) {
|
||||
try {
|
||||
@@ -888,4 +882,4 @@ export default {
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user