功能完善
This commit is contained in:
@@ -111,7 +111,7 @@
|
||||
:merchant_name='buildSqbParams.merchant_name'
|
||||
:notify_url='buildSqbParams.notify_url'
|
||||
:sign='buildSqbParams.sign'>
|
||||
<button class='confirm-order' @click='payment'>确认订单</button>
|
||||
<button class='confirm-order' @click='createOrder'>确认订单</button>
|
||||
</sqb-pay>
|
||||
</view>
|
||||
</view>
|
||||
@@ -146,6 +146,7 @@ const orderBean = ref<OrderBean>();
|
||||
|
||||
onLoad((e) => {
|
||||
orderBean.value = JSON.parse(decodeURIComponent(e?.orderBean));
|
||||
createOrder();
|
||||
});
|
||||
|
||||
const buildSqbParams = computed(() => {
|
||||
@@ -178,18 +179,18 @@ const confirmCoupon = (item: CouponBean) => {
|
||||
checkedCoupon.value = item;
|
||||
};
|
||||
const navigateTo = (e: any) => {
|
||||
console.log('--------------_>>>>>>navigateTo ', e);
|
||||
handlePayResult(orderBean.value?.id, e, {
|
||||
onSuccess: () => {
|
||||
// pay({
|
||||
// 'orderId': orderBean.value?.order.id,
|
||||
// 'result': 'xxx'
|
||||
// });
|
||||
console.log('pay success');
|
||||
payment();
|
||||
},
|
||||
onFailure: () => {
|
||||
console.error('pay onFailure');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const payment = async () => {
|
||||
const createOrder = async () => {
|
||||
await uni.showLoading();
|
||||
const params = {
|
||||
// 'discount': 0,
|
||||
@@ -200,7 +201,7 @@ const payment = async () => {
|
||||
// 'allowIntegral': 0,
|
||||
// 'produceIntegralNumber': 0,
|
||||
'remark': orderBean.value?.remark,
|
||||
'address': JSON.stringify(deliveryAddress.value),
|
||||
// 'address': JSON.stringify(deliveryAddress.value),
|
||||
'orderGoods': orderBean?.value?.orderGoods?.map(item => (
|
||||
{
|
||||
'goodsId': item.id,
|
||||
@@ -217,12 +218,14 @@ const payment = async () => {
|
||||
}
|
||||
))
|
||||
};
|
||||
console.log('----------->>>>>params ', buildSqbParams.value);
|
||||
|
||||
const result = await orderCreate(params);
|
||||
orderBean.value!.id = result.id;
|
||||
uni.hideLoading();
|
||||
};
|
||||
|
||||
const payment = async () => {
|
||||
await uni.showLoading();
|
||||
const paymentList = await getPaymentList(orderBean.value?.id || '');
|
||||
console.log('----------->>>>>orderBean.value ', orderBean.value);
|
||||
const paymentParams = {
|
||||
orderId: orderBean?.value?.id,
|
||||
produceIntegralNumber: Math.round((orderBean?.value?.totalPrice || 0) + (orderBean?.value?.useGold || 0)),
|
||||
@@ -238,7 +241,6 @@ const payment = async () => {
|
||||
};
|
||||
await overPayment(paymentParams);
|
||||
uni.hideLoading();
|
||||
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@@ -37,7 +37,7 @@
|
||||
:merchant_name='buildSqbParams.merchant_name'
|
||||
:notify_url='buildSqbParams.notify_url'
|
||||
:sign='buildSqbParams.sign'>
|
||||
<button class='primary-button' @click='goRecharge'>充值</button>
|
||||
<button class='primary-button'>充值</button>
|
||||
</sqb-pay>
|
||||
<!-- </payment-button>-->
|
||||
</view>
|
||||
@@ -68,7 +68,7 @@ const preRechargeOrderId = ref();
|
||||
onLoad(async () => {
|
||||
const { ruleitems } = await getRechargeList();
|
||||
rechargeItems.value = ruleitems;
|
||||
change(0);
|
||||
await change(0);
|
||||
});
|
||||
|
||||
const change = async (index: number) => {
|
||||
@@ -96,10 +96,17 @@ const buildSqbParams = computed(() => {
|
||||
});
|
||||
|
||||
const navigateTo = (e: any) => {
|
||||
console.log('--------------_>>>>>>navigateTo ', e);
|
||||
handlePayResult(preRechargeOrderId.value, e, {
|
||||
onSuccess: () => {
|
||||
onSuccess: async () => {
|
||||
console.log('---------->>> recharge success ');
|
||||
await goRecharge();
|
||||
await userState.setUserInfo({
|
||||
...userInfo.value,
|
||||
balance: Number(userInfo.value.balance) + Number(rechargeItems.value[currentIndex.value].rechargeamount) + Number(rechargeItems.value[currentIndex.value]?.rewardamount)
|
||||
});
|
||||
},
|
||||
onFailure: () => {
|
||||
console.log('---------->>> recharge failure ');
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -109,7 +116,7 @@ const goRecharge = async () => {
|
||||
const result = await recharge({
|
||||
itemid: rechargeItems.value[currentIndex.value].itemid
|
||||
});
|
||||
console.log('---------->>> recharge result ', result);
|
||||
console.log('platform recharge result ', result);
|
||||
|
||||
await rechargeVerify({
|
||||
payid: preRechargeOrderId.value
|
||||
|
Reference in New Issue
Block a user