diff --git a/api/shop.js b/api/shop.js index 7d224d89..5d4a97c9 100644 --- a/api/shop.js +++ b/api/shop.js @@ -17,4 +17,5 @@ export const apiArr = { queryOrder: '/api/v2/wechat/commodity/order/trade_query', // 查询订单 getComment: '/api/v2/wechat/commodity/review/list', // 获取评论 + mergePreorder: '/api/v2/wechat/commodity/order/merge_preorder', // 商品订单合并预下单 } \ No newline at end of file diff --git a/packages/shop/groupPurchaseSubmit/index.vue b/packages/shop/groupPurchaseSubmit/index.vue index 038fc9c6..7510e08b 100644 --- a/packages/shop/groupPurchaseSubmit/index.vue +++ b/packages/shop/groupPurchaseSubmit/index.vue @@ -2,8 +2,8 @@ - 配送 - + 自提 @@ -115,10 +115,12 @@ - + + - + 请选择自提点 @@ -295,7 +297,7 @@ import { apiArr } from "../../../api/shop"; export default { data() { return { - activeTab: 'delivery', // 默认选中配送 + activeTab: 'pickup', // 默认选中自提 quantity: 1, // 商品数量 selectedPayment: 'wechat', boxshadow1: false, @@ -334,7 +336,10 @@ export default { this.orderList2 = [] this.carList.forEach(item => { - item.commodity_goods_info.commodity_pic = picUrl + item.commodity_goods_info.commodity_pic + // 如果图片URL不是以https开头,则拼接picUrl + if (item.commodity_goods_info.commodity_pic && item.commodity_goods_info.commodity_pic.indexOf('https') !== 0) { + item.commodity_goods_info.commodity_pic = picUrl + item.commodity_goods_info.commodity_pic + } const list = item.commodity_goods_info.group_buy_activity_info if (list) { @@ -425,8 +430,76 @@ export default { this.selectedPayment = payment; }, submitPayment() { - console.log('提交支付,金额:¥4500.00'); - this.boxshadow1 = true; + // 检查所有商品是否都选择了自提点 + const allHaveZTAddress = this.orderList2.every(item => { + const ztAddress = this.defZTAddress.find(adItem => adItem.id === item.goods_id); + return ztAddress && ztAddress.id; + }); + + if (!allHaveZTAddress) { + uni.showToast({ + title: '请选择所有货品的自提点', + icon: 'none' + }); + return; + } + + const params = { + user_id: uni.getStorageSync('userId'), + is_group_buy: true, + goods_list: this.orderList2.map(item => { + const ztAddress = this.defZTAddress.find(adItem => adItem.id === item.goods_id) || {}; + + return { + supplier_id: item.commodity_goods_info.group_buy_activity_info.supplier_id, + supplier_name: item.supplier_name || '', + is_same_day: item.commodity_goods_info.is_same_day, + receiving_name: ztAddress.name || '', + receiving_phone: ztAddress.phone || '', + receiving_address: ztAddress.address || '', + group_buy_activity_id: item.commodity_goods_info.group_buy_activity_id, + goods_and_count: [{ + goods_id: item.commodity_goods_info.goods_id, + count: item.count, + price: item.commodity_goods_info.group_buy_price + }] + } + }) + } + + console.log("🚀 ~ submitPayment ~ params:", params) + + request(apiArr.createOrder, "POST", params).then(res => { + console.log("🚀 ~ submitPayment ~ res:", res) + // 根据平台设置不同的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: res.order_id, + user_id: uni.getStorageSync('userId'), + trans_type: trans_type + } + console.log("🚀 ~ submitPayment ~ param:", param) + request(apiArr.mergePreorder, "POST", param).then(res => { + console.log("🚀 ~ submitPayment ~ res:", res) + }) + }) }, // 复制收货地址 copyAddress() { diff --git a/packages/shop/shopCar/index.vue b/packages/shop/shopCar/index.vue index 451dab42..f11f3fd7 100644 --- a/packages/shop/shopCar/index.vue +++ b/packages/shop/shopCar/index.vue @@ -268,6 +268,7 @@ export default { this.shopCarList.forEach((item) => { item.commodity_cart_and_goods_model.forEach((ite) => { if (ite.checked) { + ite.supplier_name = item.supplier_name; arr.push(ite); } }) @@ -276,6 +277,7 @@ export default { this.isDayCarList.forEach((item) => { item.commodity_cart_and_goods_model.forEach((ite) => { if (ite.checked) { + ite.supplier_name = item.supplier_name; arr.push(ite); } })