修复购买微信团购券不到帐问题
This commit is contained in:
@@ -29,3 +29,5 @@ export const progress = (data: any) => post<any>({ url: 'wechat/coupons/group/pa
|
||||
|
||||
export const pay = (data: any) => post<any>({ url: 'wechat/coupons/group/pay', data });
|
||||
|
||||
export const couponPay = (data: any) => post<any>({ url: 'wechat/coupons/pay', data });
|
||||
|
||||
|
@@ -8,7 +8,7 @@
|
||||
</swiper>
|
||||
<view class='indicator'>
|
||||
<text>{{ swiperIndex + 1 }}</text>
|
||||
<text>/{{ bannerList.length }}</text>
|
||||
<text>/{{ bannerList?.length || 0 }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class='countdown c-flex-row'>
|
||||
@@ -112,7 +112,7 @@
|
||||
</view>
|
||||
|
||||
<!-- 商品详情跟团记录 -->
|
||||
<view class='card-view record-container' v-if='recordList&&recordList.length>0'>
|
||||
<view class='card-view record-container' v-if='recordList&&(recordList?.length||0)>0'>
|
||||
<text class='card-view-title'>跟团记录</text>
|
||||
<u-list :list='recordList' :border='false' @scrolltolower='loadMore'>
|
||||
<u-list-item v-for='(item,index) in recordList' :key='index'>
|
||||
@@ -241,7 +241,7 @@ const isEnded = () => {
|
||||
const getStockColorCount = computed(() => {
|
||||
const list = Array.from(new Set(groupBuyBean.value?.goods?.stocks?.map(item => item.colorName)))
|
||||
.map(colorName => groupBuyBean.value?.goods?.stocks?.find(item => item.colorName === colorName)!);
|
||||
return list.length;
|
||||
return (list?.length)||0;
|
||||
});
|
||||
|
||||
const fetchRecommendList = async () => {
|
||||
|
@@ -80,7 +80,7 @@ const buildSqbParams = computed(() => {
|
||||
|
||||
const navigateTo = (e: any) => {
|
||||
handlePayResult(orderBean.value?.id, e, {
|
||||
onSuccess: () => {
|
||||
onSuccess: (options:any) => {
|
||||
showToast('支付成功', {
|
||||
icon: 'success',
|
||||
complete: () => {
|
||||
|
@@ -2,7 +2,7 @@
|
||||
<view class='content'>
|
||||
<view class='card-view' style='justify-content: flex-start'>
|
||||
<view class='c-flex-row' style='align-items: center;flex: 1'>
|
||||
<image class='goods-image' :src='imageList[0]||defaultImage' />
|
||||
<image class='goods-image' :src='imageList?.length>0?imageList[0]:defaultImage' />
|
||||
<view class='c-flex-column' style='margin-left: 10rpx;flex: 1'>
|
||||
<text class='goods-name'>{{ groupBuyBean?.name || groupBuyBean?.title }}</text>
|
||||
<text class='date'>{{ groupBuyBean?.startDate }}至{{ groupBuyBean?.endDate }}</text>
|
||||
@@ -49,7 +49,7 @@
|
||||
</template>
|
||||
|
||||
<script lang='ts' setup>
|
||||
import { preOrder } from '@/api/groupbuy';
|
||||
import { couponPay, preOrder } from '@/api/groupbuy';
|
||||
import { OrderBean } from '@/api/order/types';
|
||||
import { parseParameter, showToast, sortASCII } from '@/utils';
|
||||
import { hexMD5 } from '@/utils/common/md5';
|
||||
@@ -67,10 +67,22 @@ const orderBean = ref<OrderBean>();
|
||||
const goodsCount = ref(1);
|
||||
|
||||
onLoad((e: any) => {
|
||||
groupBuyBean.value = JSON.parse(decodeURIComponent(e?.bean));
|
||||
imageList.value = groupBuyBean.value?.image?.split(',');
|
||||
getApp().globalData?.logger?.info('order-coupon-confirm ', e);
|
||||
try {
|
||||
groupBuyBean.value = JSON.parse(decodeURIComponent(e?.bean));
|
||||
getApp().globalData?.logger?.info('order-coupon-confirm: groupBuyBean', groupBuyBean.value);
|
||||
if(groupBuyBean.value) {
|
||||
imageList.value = groupBuyBean.value?.image?.split(',');
|
||||
getApp().globalData?.logger?.info('order-coupon-confirm: imageList', imageList.value);
|
||||
}
|
||||
|
||||
createOrder();
|
||||
getApp().globalData?.logger?.info('order-coupon-confirm: userInfo', userInfo.value);
|
||||
getApp().globalData?.logger?.info('order-coupon-confirm: terminalInfo', terminalInfo.value);
|
||||
|
||||
createOrder();
|
||||
} catch (e) {
|
||||
getApp().globalData?.logger?.error('order-coupon-confirm: exception ', e);
|
||||
}
|
||||
});
|
||||
|
||||
const countChange = (isPlus: boolean) => {
|
||||
@@ -96,25 +108,33 @@ const buildSqbParams = computed(() => {
|
||||
client_sn: orderBean.value?.id || '',
|
||||
return_url: '/pages/common/payresult/index',
|
||||
total_amount: Number(((totalPrice.value || 0) * 100).toFixed(2)),
|
||||
terminal_sn: terminalInfo.value.terminalSn,
|
||||
subject: '商品团购券',
|
||||
subject_img: imageList.value[0] || '',
|
||||
merchant_name: terminalInfo.value.companyName,
|
||||
terminal_sn: terminalInfo.value?.terminalSn,
|
||||
subject: groupBuyBean.value?.name || '商品团购券',
|
||||
subject_img: (imageList.value?.length > 0 && imageList.value[0]) || '',
|
||||
merchant_name: terminalInfo.value?.companyName,
|
||||
notify_url: 'https://www.baidu.com'
|
||||
}, true);
|
||||
|
||||
return {
|
||||
...params,
|
||||
sign: hexMD5(parseParameter(params) + '&key=' + terminalInfo.value.terminalKey).toUpperCase()
|
||||
sign: hexMD5(parseParameter(params) + '&key=' + terminalInfo.value?.terminalKey).toUpperCase()
|
||||
};
|
||||
});
|
||||
|
||||
const navigateTo = (e: any) => {
|
||||
handlePayResult(orderBean.value?.id, e, {
|
||||
onSuccess: () => {
|
||||
onSuccess: (options: any) => {
|
||||
showToast('支付成功', {
|
||||
icon: 'success',
|
||||
complete: () => {
|
||||
// delete orderBean.value && orderBean.value!.createTime;
|
||||
couponPay({
|
||||
...orderBean.value,
|
||||
payResult: JSON.stringify(options),
|
||||
status: 2
|
||||
}).then(res => {
|
||||
uni.navigateBack();
|
||||
});
|
||||
uni.navigateBack();
|
||||
}
|
||||
});
|
||||
@@ -129,19 +149,24 @@ const createOrder = () => {
|
||||
num: goodsCount.value,
|
||||
memberId: userInfo.value.id,
|
||||
payBo: {
|
||||
terminal_sn: terminalInfo.value.terminalSn,
|
||||
terminal_key: terminalInfo.value.terminalKey,
|
||||
terminal_sn: terminalInfo.value?.terminalSn,
|
||||
terminal_key: terminalInfo.value?.terminalKey,
|
||||
merchant_name: userInfo.value.companyName,
|
||||
total_amount: totalPrice.value,
|
||||
subject: groupBuyBean.value?.name || '微信团购券',
|
||||
description: groupBuyBean.value?.title || '微信团购券',
|
||||
subject_img: imageList.value[0] || '',
|
||||
subject_img: (imageList.value?.length > 0 && imageList.value[0]) || '',
|
||||
device_id: groupBuyBean.value?.creatorId,
|
||||
return_url: '/pages/payResult/index'
|
||||
}
|
||||
};
|
||||
preOrder(params).then(res => {
|
||||
orderBean.value = res as any;
|
||||
if(orderBean.value) {
|
||||
orderBean.value!.clientSn = res?.id;
|
||||
}
|
||||
}).catch(err => {
|
||||
getApp().globalData?.logger?.error('order-coupon-confirm: preOrder exception ', err);
|
||||
});
|
||||
};
|
||||
|
||||
|
@@ -87,7 +87,7 @@ const submenuList = [
|
||||
icon: assetsUrl('ic_register_gift2.png'),
|
||||
path: '/pages/common/register/reward'
|
||||
// path: '/pages/common/groupbuy/detail?shareId=1797548579864748033'
|
||||
// path: '/pages/coupons/ticketsBuy/ticketsBuy?couponsId=1746159008308854786'
|
||||
// path: '/pages/coupons/ticketsBuy/ticketsBuy?couponsId=1800381015472513026'
|
||||
//1799264392762138626
|
||||
},
|
||||
{
|
||||
|
@@ -188,12 +188,12 @@ const confirmCoupon = (item: CouponBean) => {
|
||||
};
|
||||
const navigateTo = (e: any) => {
|
||||
handlePayResult(orderBean.value?.id, e, {
|
||||
onSuccess: () => {
|
||||
onSuccess: (options:any) => {
|
||||
console.log('pay success');
|
||||
payment();
|
||||
},
|
||||
onFailure: () => {
|
||||
console.error('pay onFailure');
|
||||
onFailure: (e:any) => {
|
||||
console.error('pay onFailure ',e);
|
||||
if(orderBean.value?.id) {
|
||||
orderBean.value.id = '';
|
||||
}
|
||||
|
@@ -80,7 +80,7 @@ defineProps({
|
||||
position: relative;
|
||||
flex: 1;
|
||||
justify-content: center;
|
||||
margin-left: 60rpx;
|
||||
margin-left: 70rpx;
|
||||
|
||||
text:nth-of-type(1) {
|
||||
font-size: 30rpx;
|
||||
|
@@ -178,7 +178,7 @@ const buildSqbParams = computed(() => {
|
||||
|
||||
const navigateTo = (e: any) => {
|
||||
handlePayResult(orderBean.value?.order.id, e, {
|
||||
onSuccess: () => {
|
||||
onSuccess: (options:any) => {
|
||||
fetchData(orderBean.value?.order.id || '');
|
||||
}
|
||||
});
|
||||
|
@@ -120,7 +120,7 @@ const buildSqbParams = computed(() => {
|
||||
|
||||
const navigateTo = (e: any) => {
|
||||
handlePayResult(preRechargeOrderId.value, e, {
|
||||
onSuccess: async () => {
|
||||
onSuccess: async (options: any) => {
|
||||
await goRecharge();
|
||||
await userState.setUserInfo({
|
||||
...userInfo.value,
|
||||
@@ -128,7 +128,7 @@ const navigateTo = (e: any) => {
|
||||
});
|
||||
await uni.navigateBack();
|
||||
},
|
||||
onFailure: () => {
|
||||
onFailure: (e: any) => {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@@ -33,9 +33,10 @@ export const handlePayResult = (orderId: string | undefined, e: any, { onSuccess
|
||||
const str = url.split('?')[1];
|
||||
const resultObj = JSON.parse(str.replaceAll('result=', ''));
|
||||
|
||||
getApp().globalData?.logger?.info('pay reuslt : ', orderId, resultObj);
|
||||
if(resultObj?.is_success === true) {
|
||||
if(onSuccess) {
|
||||
onSuccess();
|
||||
onSuccess(resultObj);
|
||||
} else {
|
||||
showToast('支付成功', {
|
||||
icon: 'success',
|
||||
@@ -45,14 +46,18 @@ export const handlePayResult = (orderId: string | undefined, e: any, { onSuccess
|
||||
});
|
||||
}
|
||||
} else {
|
||||
getApp().globalData?.logger?.error('pay failure :', resultObj);
|
||||
if(onFailure) {
|
||||
onFailure();
|
||||
} else {
|
||||
const msg = resultObj?.error_message || '支付失败';
|
||||
showToast(msg, {
|
||||
complete: () => {
|
||||
setTimeout(() => {
|
||||
uni.navigateBack();
|
||||
}, 1500);
|
||||
}
|
||||
});
|
||||
}
|
||||
const msg = resultObj?.error_message || '支付失败';
|
||||
showToast(msg, {
|
||||
complete: () => {
|
||||
uni.navigateBack();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user