对接接口 -- 创建订单
This commit is contained in:
parent
cc9eee696a
commit
e3c535d596
@ -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', // 商品订单合并预下单
|
||||
}
|
||||
@ -2,8 +2,8 @@
|
||||
<view class="container">
|
||||
<!-- 顶部切换栏 -->
|
||||
<view class="tab-bar">
|
||||
<view :class="{ active: activeTab === 'delivery' }" class="tab-item" @click="switchTab('delivery')">配送
|
||||
</view>
|
||||
<!-- <view :class="{ active: activeTab === 'delivery' }" class="tab-item" @click="switchTab('delivery')">配送
|
||||
</view> -->
|
||||
<view :class="{ active: activeTab === 'pickup' }" class="tab-item" @click="switchTab('pickup')">自提</view>
|
||||
</view>
|
||||
<!-- 分隔线 -->
|
||||
@ -115,10 +115,12 @@
|
||||
<view class="copy-icon" @click.stop="copyZTAddress" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="address-arrow"><u-icon name="arrow-right" size="25"></u-icon></view>
|
||||
<view class="address-arrow"><u-icon name="arrow-right" size="25"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="address-info" v-if="!defZTAddress.some(adItem => adItem.id === item.goods_id)">
|
||||
<view class="address-info"
|
||||
v-if="!defZTAddress.some(adItem => adItem.id === item.goods_id)">
|
||||
<view class="address-main">
|
||||
<view class="address-name-phone">
|
||||
<text class="name">请选择自提点</text>
|
||||
@ -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() {
|
||||
|
||||
@ -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);
|
||||
}
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user