修改从订单列表执行立即付款时的执行逻辑
This commit is contained in:
parent
3c87af65de
commit
a732eab59f
@ -291,7 +291,8 @@ export default {
|
||||
goToPay(item) {
|
||||
// 创建转换后的商品数组
|
||||
const transformedItems = item.commodity_order_item_list.map(goods => ({
|
||||
checked: true,
|
||||
isafterSale: true,
|
||||
orderId: item.id,
|
||||
commodity_goods_info: {
|
||||
commodity_brief: "",
|
||||
commodity_id: goods.commodity_id,
|
||||
|
||||
@ -292,7 +292,8 @@ export default {
|
||||
goToPay(item) {
|
||||
// 创建转换后的商品数组
|
||||
const transformedItems = item.commodity_order_item_list.map(goods => ({
|
||||
checked: true,
|
||||
isafterSale: true,
|
||||
orderId: item.id,
|
||||
commodity_goods_info: {
|
||||
commodity_brief: "",
|
||||
commodity_id: goods.commodity_id,
|
||||
|
||||
@ -263,7 +263,8 @@ export default {
|
||||
gotoPayment() {
|
||||
// 创建转换后的商品数组
|
||||
const transformedItems = this.orderInfo.commodity_order_item_list.map(goods => ({
|
||||
checked: true,
|
||||
isafterSale: true,
|
||||
orderId: item.id,
|
||||
commodity_goods_info: {
|
||||
commodity_brief: "",
|
||||
commodity_id: goods.goods_id,
|
||||
|
||||
@ -562,6 +562,41 @@ export default {
|
||||
if (!isGroupBuyValid) break;
|
||||
}
|
||||
|
||||
// 检查是否存在isafterSale属性且值为true
|
||||
const hasAfterSaleItem = this.carList.some(item => item.isafterSale === true);
|
||||
const orderIdFromAfterSale = hasAfterSaleItem ? this.carList.find(item => item.isafterSale === true)?.orderId : null;
|
||||
|
||||
// 根据平台设置不同的trans_type值
|
||||
// 小程序: 71, App: 51
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
let trans_type = 51; // 默认App环境
|
||||
|
||||
// 运行时判断是否为小程序环境
|
||||
if (systemInfo.platform === 'devtools' || systemInfo.platform === 'unknown') {
|
||||
trans_type = 71; // 开发工具或未知环境默认为小程序
|
||||
}
|
||||
|
||||
// 条件编译:针对不同平台设置不同值
|
||||
// #ifdef MP
|
||||
trans_type = 71; // 所有小程序平台
|
||||
// #endif
|
||||
|
||||
// #ifdef APP-PLUS
|
||||
trans_type = 51; // App平台
|
||||
// #endif
|
||||
|
||||
// 如果存在isafterSale属性且为true,则跳过createOrder接口调用
|
||||
if (hasAfterSaleItem && orderIdFromAfterSale) {
|
||||
const param = {
|
||||
order_id: orderIdFromAfterSale,
|
||||
user_id: uni.getStorageSync('userId'),
|
||||
trans_type: trans_type
|
||||
}
|
||||
request(apiArr.mergePreorder, "POST", param).then(res => {
|
||||
this.handleMergePreorderResponse(res, orderIdFromAfterSale);
|
||||
})
|
||||
} else {
|
||||
// 原始逻辑:创建订单后再进行支付
|
||||
const params = {
|
||||
user_id: uni.getStorageSync('userId'),
|
||||
is_group_buy: isGroupBuyValid,
|
||||
@ -599,34 +634,21 @@ export default {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
request(apiArr.createOrder, "POST", params).then(resVal => {
|
||||
// 根据平台设置不同的trans_type值
|
||||
// 小程序: 71, App: 51
|
||||
const systemInfo = uni.getSystemInfoSync();
|
||||
let trans_type = 51; // 默认App环境
|
||||
|
||||
// 运行时判断是否为小程序环境
|
||||
if (systemInfo.platform === 'devtools' || systemInfo.platform === 'unknown') {
|
||||
trans_type = 71; // 开发工具或未知环境默认为小程序
|
||||
}
|
||||
|
||||
// 条件编译:针对不同平台设置不同值
|
||||
// #ifdef MP
|
||||
trans_type = 71; // 所有小程序平台
|
||||
// #endif
|
||||
|
||||
// #ifdef APP-PLUS
|
||||
trans_type = 51; // App平台
|
||||
// #endif
|
||||
|
||||
const param = {
|
||||
order_id: resVal.order_id,
|
||||
user_id: uni.getStorageSync('userId'),
|
||||
trans_type: trans_type
|
||||
}
|
||||
request(apiArr.mergePreorder, "POST", param).then(res => {
|
||||
this.handleMergePreorderResponse(res, resVal.order_id);
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
// 处理mergePreorder接口的响应
|
||||
handleMergePreorderResponse(res, orderId) {
|
||||
if (res && res.timeStamp && res.nonceStr && res.package && res.signType && res.paySign) {
|
||||
// 调用微信支付
|
||||
uni.requestPayment({
|
||||
@ -637,7 +659,7 @@ export default {
|
||||
paySign: res.paySign,
|
||||
success: (payRes) => {
|
||||
const params = {
|
||||
order_id: resVal.order_id,
|
||||
order_id: orderId,
|
||||
from: 2,
|
||||
group_buy_activity_id: this.group_buy_activity_id,
|
||||
}
|
||||
@ -663,8 +685,7 @@ export default {
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
// 复制收货地址
|
||||
copyAddress() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user