fix: 接入抖音原生支付并修复App支付服务缺失
This commit is contained in:
@@ -218,10 +218,13 @@
|
||||
<image v-if="item.type == 'alipay'" src="https://static.tbmall.xin/static/new/zfb.png"></image>
|
||||
<image v-if="item.type == 'balance'" src="https://static.tbmall.xin/static/new/bank.png"></image>
|
||||
<image v-if="item.type == 'redpacket'" src="https://static.tbmall.xin/static/new/jf.png"></image>
|
||||
<image v-if="item.type == 'douyin'" src="https://static.tbmall.xin/static/new/jf.png"></image>
|
||||
|
||||
<text v-if="item.type == 'wechat' || item.type == 'alipay'" class="text-32 text-zu"
|
||||
style="margin-left: 20rpx">{{ item.name }}</text>
|
||||
<text v-if="item.type == 'douyin'" aria-hidden="true" style="display: inline-flex; align-items: center; justify-content: center; width: 48rpx; height: 48rpx; border-radius: 50%; background: #161823; color: #fff; font-size: 32rpx; flex-shrink: 0;">♪</text>
|
||||
<text v-if="item.type == 'wechat' || item.type == 'alipay' || item.type == 'douyin'" class="text-32 text-zu"
|
||||
style="margin-left: 20rpx">{{ item.name }}
|
||||
<!-- #ifdef H5 -->
|
||||
<text v-if="item.type == 'douyin'" style="font-size: 24rpx; color: #777; margin-left: 12rpx;">仅 App 支持</text>
|
||||
<!-- #endif -->
|
||||
</text>
|
||||
<text v-else style="margin-left: 20rpx" class="text-32 text-zu">{{ item.name }}
|
||||
<text style="color: #999; margin: 0 10rpx">可用:</text>
|
||||
{{ item.balance }}
|
||||
@@ -317,6 +320,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { appDypayFun, prepareDouyinPay, douyinPayTypes, filterDouyinPayWays } from '@/utils/douyin-pay.js';
|
||||
import Address from "@/components/address.vue";
|
||||
import { getGoodsDetail } from "@/api/product.js";
|
||||
import { getAddress } from "@/api/address.js";
|
||||
@@ -340,7 +344,6 @@ import { getUserInfo } from "@/api/auth.js";
|
||||
import {
|
||||
appWxpayFun,
|
||||
zfbPayFun,
|
||||
douyinPayFun,
|
||||
jumpWayOk,
|
||||
jumpWayError,
|
||||
} from "@/utils/payUtils.js";
|
||||
@@ -609,9 +612,10 @@ export default {
|
||||
|
||||
|
||||
|
||||
parmas.types = douyinPayTypes(parmas.types);
|
||||
const result = await getSupportPay(parmas);
|
||||
if (result && result.bizcode === 100) {
|
||||
const data = result.data || [];
|
||||
const data = filterDouyinPayWays(result.data);
|
||||
// const amount = this.orderInfo.amount;
|
||||
// let flag = data.some((item) =>
|
||||
// ["wechat", "alipay"].includes(item.type)
|
||||
@@ -978,6 +982,10 @@ export default {
|
||||
}
|
||||
},
|
||||
async passPay() {
|
||||
if (this._paySubmitting) return;
|
||||
this._paySubmitting = true;
|
||||
try {
|
||||
if (!await prepareDouyinPay(this.orderInfo.paymentMethod)) return;
|
||||
let params = {
|
||||
addrId: this.orderInfo.address.id, // 收货地址ID
|
||||
//结算的购物车ID,多个以逗号分割,ALL表示全选
|
||||
@@ -1069,7 +1077,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 &&
|
||||
@@ -1077,10 +1087,6 @@ export default {
|
||||
item.alipay
|
||||
) {
|
||||
this.zfbPay(item.alipay, item.orderId, item.orderNum);
|
||||
} else if (item.douyin &&
|
||||
Object.keys(item.douyin).length !== 0 &&
|
||||
item.douyin) {
|
||||
this.appDouying(item.douyin, item.orderId, item.orderNum);
|
||||
} else {
|
||||
this.$refs.uToastRef.show({
|
||||
type: "error",
|
||||
@@ -1093,20 +1099,10 @@ export default {
|
||||
} else {
|
||||
this.getOrder();
|
||||
}
|
||||
},
|
||||
|
||||
// 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 {
|
||||
|
||||
@@ -215,8 +215,13 @@
|
||||
<image v-if="item.type == 'alipay'" src="https://static.tbmall.xin/static/new/zfb.png"></image>
|
||||
<image v-if="item.type == 'balance'" src="https://static.tbmall.xin/static/new/bank.png"></image>
|
||||
<image v-if="item.type == 'redpacket'" src="https://static.tbmall.xin/static/new/jf.png"></image>
|
||||
<text v-if="item.type == 'wechat' || item.type == 'alipay'" class="text-32 text-zu"
|
||||
style="margin-left: 20rpx">{{ item.name }}</text>
|
||||
<text v-if="item.type == 'douyin'" aria-hidden="true" style="display: inline-flex; align-items: center; justify-content: center; width: 48rpx; height: 48rpx; border-radius: 50%; background: #161823; color: #fff; font-size: 32rpx; flex-shrink: 0;">♪</text>
|
||||
<text v-if="item.type == 'wechat' || item.type == 'alipay' || item.type == 'douyin'" class="text-32 text-zu"
|
||||
style="margin-left: 20rpx">{{ item.name }}
|
||||
<!-- #ifdef H5 -->
|
||||
<text v-if="item.type == 'douyin'" style="font-size: 24rpx; color: #777; margin-left: 12rpx;">仅 App 支持</text>
|
||||
<!-- #endif -->
|
||||
</text>
|
||||
<text v-else style="margin-left: 20rpx" class="text-32 text-zu">{{ item.name }}
|
||||
<text style="color: #999; margin: 0 10rpx">可用:</text>
|
||||
{{ item.balance }}
|
||||
@@ -309,7 +314,8 @@
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script>
|
||||
import { appDypayFun, prepareDouyinPay, douyinPayTypes, filterDouyinPayWays } from '@/utils/douyin-pay.js';
|
||||
import Address from "@/components/address.vue";
|
||||
import { getGoodsDetail } from "@/api/product.js";
|
||||
import { getAddress } from "@/api/address.js";
|
||||
@@ -597,9 +603,10 @@ export default {
|
||||
|
||||
|
||||
|
||||
const result = await getSupportPay(parmas);
|
||||
parmas.types = douyinPayTypes(parmas.types);
|
||||
const result = await getSupportPay(parmas);
|
||||
if (result && result.bizcode === 100) {
|
||||
const data = result.data || [];
|
||||
const data = filterDouyinPayWays(result.data);
|
||||
// const amount = this.orderInfo.amount;
|
||||
// let flag = data.some((item) =>
|
||||
// ["wechat", "alipay"].includes(item.type)
|
||||
@@ -943,7 +950,11 @@ export default {
|
||||
this.passPay();
|
||||
}
|
||||
},
|
||||
async passPay() {
|
||||
async passPay() {
|
||||
if (this._paySubmitting) return;
|
||||
this._paySubmitting = true;
|
||||
try {
|
||||
if (!await prepareDouyinPay(this.orderInfo.paymentMethod)) return;
|
||||
let params = {
|
||||
addrId: this.orderInfo.address.id, // 收货地址ID
|
||||
//结算的购物车ID,多个以逗号分割,ALL表示全选
|
||||
@@ -1034,7 +1045,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 &&
|
||||
@@ -1054,8 +1067,11 @@ export default {
|
||||
} else {
|
||||
this.getOrder();
|
||||
}
|
||||
},
|
||||
// app 微信支付
|
||||
} catch (error) {
|
||||
uni.showToast({ title: error.message || error.msg || '支付请求失败,请查看订单后重试', icon: 'none' });
|
||||
} finally { this._paySubmitting = false; }
|
||||
},
|
||||
// app 微信支付
|
||||
async appWxpay(alipay, orderId, orderNum) {
|
||||
try {
|
||||
const result = await appWxpayFun(alipay, orderId, orderNum);
|
||||
@@ -1509,4 +1525,4 @@ export default {
|
||||
align-items: baseline;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user