修改团购部分bug
This commit is contained in:
parent
e3c535d596
commit
3ecdf95c24
@ -165,7 +165,6 @@ export default {
|
|||||||
group_buy_goods_list
|
group_buy_goods_list
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
console.log("🚀 ~ getGoodsList ~ list:", list)
|
|
||||||
this.goodsList = list
|
this.goodsList = list
|
||||||
return res;
|
return res;
|
||||||
})
|
})
|
||||||
@ -217,8 +216,14 @@ export default {
|
|||||||
},
|
},
|
||||||
// 增加货品数量
|
// 增加货品数量
|
||||||
increaseQuantity(goodsIndex, skuIndex) {
|
increaseQuantity(goodsIndex, skuIndex) {
|
||||||
this.goodsList[goodsIndex].group_buy_goods_list[skuIndex].quantity++;
|
if (this.goodsList[goodsIndex].group_buy_goods_list[skuIndex].quantity == 0) {
|
||||||
this.carNum++;
|
this.goodsList[goodsIndex].group_buy_goods_list[skuIndex].quantity += this.goodsList[goodsIndex].group_buy_goods_list[skuIndex].min_order_quantity
|
||||||
|
this.carNum += this.goodsList[goodsIndex].group_buy_goods_list[skuIndex].min_order_quantity
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this.goodsList[goodsIndex].group_buy_goods_list[skuIndex].quantity++;
|
||||||
|
this.carNum++;
|
||||||
|
}
|
||||||
const params = {
|
const params = {
|
||||||
goods_id_and_count: [
|
goods_id_and_count: [
|
||||||
{
|
{
|
||||||
@ -233,8 +238,13 @@ export default {
|
|||||||
// 减少货品数量
|
// 减少货品数量
|
||||||
decreaseQuantity(goodsIndex, skuIndex) {
|
decreaseQuantity(goodsIndex, skuIndex) {
|
||||||
if (this.goodsList[goodsIndex].group_buy_goods_list[skuIndex].quantity > 0) {
|
if (this.goodsList[goodsIndex].group_buy_goods_list[skuIndex].quantity > 0) {
|
||||||
this.goodsList[goodsIndex].group_buy_goods_list[skuIndex].quantity--;
|
if(this.goodsList[goodsIndex].group_buy_goods_list[skuIndex].quantity == this.goodsList[goodsIndex].group_buy_goods_list[skuIndex].min_order_quantity){
|
||||||
this.carNum--;
|
this.goodsList[goodsIndex].group_buy_goods_list[skuIndex].quantity = 0
|
||||||
|
this.carNum = 0
|
||||||
|
}else{
|
||||||
|
this.goodsList[goodsIndex].group_buy_goods_list[skuIndex].quantity--;
|
||||||
|
this.carNum--;
|
||||||
|
}
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
goods_id_and_count: [
|
goods_id_and_count: [
|
||||||
|
|||||||
@ -82,7 +82,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="GG_rigth" v-if="info.commodity_goods_info_list && info.commodity_goods_info_list.length > 0">
|
<view class="GG_rigth" v-if="info.commodity_goods_info_list && info.commodity_goods_info_list.length > 0">
|
||||||
共{{ info.commodity_goods_info_list.length }}款<u-icon size="26rpx" name="arrow-right"></u-icon>
|
共{{ info.commodity_goods_info_list.length }}款
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@ -185,24 +185,11 @@
|
|||||||
加入购物车
|
加入购物车
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="car_right" v-if="
|
<view class="car_right" @click="changeCar" v-if="
|
||||||
info.commodity_goods_info_list[currentGGIndex].cart_count.count > 0
|
info.commodity_goods_info_list[currentGGIndex].cart_count.count > 0
|
||||||
&& info.commodity_goods_info_list[currentGGIndex].total_stock > 0
|
&& info.commodity_goods_info_list[currentGGIndex].total_stock > 0
|
||||||
|
|
||||||
">
|
">
|
||||||
<u-number-box v-model="info.commodity_goods_info_list[currentGGIndex].cart_count.count
|
加入购物车
|
||||||
" @change="changeCar" min="0">
|
|
||||||
<view slot="minus" class="minus">
|
|
||||||
<u-icon name="minus" size="36" bold></u-icon>
|
|
||||||
</view>
|
|
||||||
<text slot="input" style="width: 200rpx; text-align: center" class="input">
|
|
||||||
{{
|
|
||||||
info.commodity_goods_info_list[currentGGIndex].cart_count.count
|
|
||||||
}}</text>
|
|
||||||
<view slot="plus" class="plus">
|
|
||||||
<u-icon name="plus" color="#FFFFFF" size="36" bold></u-icon>
|
|
||||||
</view>
|
|
||||||
</u-number-box>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@ -337,6 +324,8 @@ import { picUrl, menuButtonInfo, request, NavgateTo } from "../../../utils";
|
|||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
itemObj: {},
|
||||||
|
|
||||||
picUrl,
|
picUrl,
|
||||||
top: "",
|
top: "",
|
||||||
localHeight: "",
|
localHeight: "",
|
||||||
@ -506,9 +495,9 @@ export default {
|
|||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
// 分割图片
|
// 分割图片
|
||||||
res.commodity_goods_info_list.forEach((item) => {
|
res.commodity_goods_info_list.forEach((item) => {
|
||||||
item.goods_detail_pic = item.goods_detail_pic.split(",");
|
item.goods_detail_pic = item.goods_detail_pic ? item.goods_detail_pic.split(",") : [];
|
||||||
item.goods_carousel = item.goods_carousel.split(",");
|
item.goods_carousel = item.goods_carousel ? item.goods_carousel.split(",") : [];
|
||||||
item.commodity_pic = item.commodity_pic.split(",");
|
item.commodity_pic = item.commodity_pic ? item.commodity_pic.split(",") : [];
|
||||||
});
|
});
|
||||||
|
|
||||||
//根据购物车列表 和 当前商品列表 来更新当前商品列表在购物车中的数量
|
//根据购物车列表 和 当前商品列表 来更新当前商品列表在购物车中的数量
|
||||||
@ -522,13 +511,45 @@ export default {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.info = res;
|
|
||||||
this.currentGG = res.commodity_goods_info_list[0];
|
|
||||||
this.currentGGIndex = 0;
|
|
||||||
|
|
||||||
this.changeImg = this.currentGG.commodity_pic[0]
|
// 过滤掉group_buy_activity_info为空的数据
|
||||||
this.changeName = this.currentGG.goods_alias
|
if (res.commodity_goods_info_list && Array.isArray(res.commodity_goods_info_list)) {
|
||||||
this.changePrice = this.currentGG.sales_price
|
res.commodity_goods_info_list = res.commodity_goods_info_list.filter(item => {
|
||||||
|
return item.group_buy_activity_info !== null
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.info = res;
|
||||||
|
|
||||||
|
// 确保商品列表不为空
|
||||||
|
if (this.itemObj) {
|
||||||
|
// 对 itemObj 进行图片分割处理
|
||||||
|
this.itemObj.goods_detail_pic = this.itemObj.goods_detail_pic ? this.itemObj.goods_detail_pic.split(",") : [];
|
||||||
|
this.itemObj.goods_carousel = this.itemObj.goods_carousel ? this.itemObj.goods_carousel.split(",") : [];
|
||||||
|
this.itemObj.commodity_pic = this.itemObj.commodity_pic ? this.itemObj.commodity_pic.split(",") : [];
|
||||||
|
|
||||||
|
this.currentGG = this.itemObj;
|
||||||
|
// 根据itemObj在商品列表中找到对应的索引
|
||||||
|
this.currentGGIndex = this.info && this.info.commodity_goods_info_list
|
||||||
|
? this.info.commodity_goods_info_list.findIndex(item => item.id === this.itemObj.id)
|
||||||
|
: 0;
|
||||||
|
|
||||||
|
// 如果没找到匹配项,默认为0
|
||||||
|
if (this.currentGGIndex === -1) {
|
||||||
|
this.currentGGIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.changeImg = this.currentGG.commodity_pic[0];
|
||||||
|
this.changeName = this.currentGG.goods_alias;
|
||||||
|
this.changePrice = this.currentGG.sales_price;
|
||||||
|
} else {
|
||||||
|
// 商品列表为空时的处理
|
||||||
|
this.currentGG = null;
|
||||||
|
this.currentGGIndex = 0;
|
||||||
|
this.changeImg = '';
|
||||||
|
this.changeName = '';
|
||||||
|
this.changePrice = '';
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -581,50 +602,59 @@ export default {
|
|||||||
|
|
||||||
addCar() {
|
addCar() {
|
||||||
let that = this;
|
let that = this;
|
||||||
//如果没有当前商品 直接添加一个
|
|
||||||
let goods_id_and_count = [];
|
|
||||||
this.info.commodity_goods_info_list[this.currentGGIndex].cart_count = {
|
this.info.commodity_goods_info_list[this.currentGGIndex].cart_count = {
|
||||||
count: 1,
|
count: this.info.commodity_goods_info_list[this.currentGGIndex].min_order_quantity,
|
||||||
};
|
};
|
||||||
this.info.commodity_goods_info_list.forEach((item) => {
|
// this.info.commodity_goods_info_list.forEach((item) => {
|
||||||
console.log(item.cart_count);
|
// console.log(item.cart_count);
|
||||||
goods_id_and_count.push({
|
// goods_id_and_count.push({
|
||||||
goods_id: item.id,
|
// goods_id: item.id,
|
||||||
count: item.cart_count ? item.cart_count.count : 0,
|
// count: item.cart_count ? item.cart_count.count : 0,
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
|
|
||||||
console.log(goods_id_and_count);
|
let countVal = this.info.commodity_goods_info_list[this.currentGGIndex].min_order_quantity
|
||||||
//因为是当前商品没有 调用update就是增加商品。增加商品之后再获取购物车数量
|
|
||||||
request(apiArr.updateCar, "POST", {
|
const params = {
|
||||||
goods_id_and_count,
|
goods_id_and_count: [
|
||||||
}).then((res) => {
|
{
|
||||||
|
goods_id:
|
||||||
|
this.info.commodity_goods_info_list[this.currentGGIndex].id,
|
||||||
|
count: countVal,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
request(apiArr.updateCar, "POST", params).then((res) => {
|
||||||
that.getShopCar();
|
that.getShopCar();
|
||||||
that.getShopCarList();
|
that.getShopCarList();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// 购物车更改
|
// 购物车更改
|
||||||
changeCar(newValue) {
|
changeCar() {
|
||||||
//商品数量变化
|
// 获取当前商品的购物车数量,如果不存在则设为0
|
||||||
|
const currentCount = this.info.commodity_goods_info_list[this.currentGGIndex].cart_count?.count;
|
||||||
|
// 新的数量为当前数量加一
|
||||||
|
const newCount = currentCount + 1;
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
user_id: uni.getStorageSync("userId"),
|
user_id: uni.getStorageSync("userId"),
|
||||||
goods_id_and_count: [
|
goods_id_and_count: [
|
||||||
{
|
{
|
||||||
goods_id:
|
goods_id: this.info.commodity_goods_info_list[this.currentGGIndex].id,
|
||||||
this.info.commodity_goods_info_list[this.currentGGIndex].id,
|
count: newCount,
|
||||||
count: newValue.value,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
request(apiArr.updateCar, "POST", params).then((res) => {
|
request(apiArr.updateCar, "POST", params).then((res) => {
|
||||||
console.log(res);
|
|
||||||
this.getShopCarList();
|
this.getShopCarList();
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "操作成功!",
|
title: "操作成功!",
|
||||||
success() { },
|
success() { },
|
||||||
});
|
});
|
||||||
this.getShopCar();
|
this.getShopCar();
|
||||||
|
this.getGoodsInfo();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -694,15 +724,15 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
const itemObj = JSON.parse(decodeURIComponent(options.item));
|
this.itemObj = JSON.parse(decodeURIComponent(options.item));
|
||||||
const meun = menuButtonInfo();
|
const meun = menuButtonInfo();
|
||||||
this.top = meun.top;
|
this.top = meun.top;
|
||||||
this.localHeight = meun.height;
|
this.localHeight = meun.height;
|
||||||
this.id = itemObj.commodity_id ? itemObj.commodity_id : itemObj.id;
|
this.id = this.itemObj.commodity_id ? this.itemObj.commodity_id : this.itemObj.id;
|
||||||
if (itemObj.commodity_id) {
|
if (this.itemObj.commodity_id) {
|
||||||
this.endTime = itemObj.group_buy_activity_info.end_time
|
this.endTime = this.itemObj.group_buy_activity_info.end_time
|
||||||
} else {
|
} else {
|
||||||
this.endTime = itemObj.group_buy_goods_list[0].group_buy_activity_info.end_time
|
this.endTime = this.itemObj.group_buy_goods_list[0].group_buy_activity_info.end_time
|
||||||
}
|
}
|
||||||
this.getBuyRecord()
|
this.getBuyRecord()
|
||||||
this.getEndTheCountdown(this.endTime)
|
this.getEndTheCountdown(this.endTime)
|
||||||
@ -737,11 +767,11 @@ export default {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
request(apiArr.updateCar, "POST", {
|
// request(apiArr.updateCar, "POST", {
|
||||||
goods_id_and_count,
|
// goods_id_and_count,
|
||||||
}).then((res) => {
|
// }).then((res) => {
|
||||||
console.log("Cart updated on hide");
|
// console.log("Cart updated on hide");
|
||||||
});
|
// });
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@ -467,10 +467,8 @@ export default {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("🚀 ~ submitPayment ~ params:", params)
|
|
||||||
|
|
||||||
request(apiArr.createOrder, "POST", params).then(res => {
|
request(apiArr.createOrder, "POST", params).then(res => {
|
||||||
console.log("🚀 ~ submitPayment ~ res:", res)
|
|
||||||
// 根据平台设置不同的trans_type值
|
// 根据平台设置不同的trans_type值
|
||||||
// 小程序: 71, App: 51
|
// 小程序: 71, App: 51
|
||||||
const systemInfo = uni.getSystemInfoSync();
|
const systemInfo = uni.getSystemInfoSync();
|
||||||
@ -495,9 +493,41 @@ export default {
|
|||||||
user_id: uni.getStorageSync('userId'),
|
user_id: uni.getStorageSync('userId'),
|
||||||
trans_type: trans_type
|
trans_type: trans_type
|
||||||
}
|
}
|
||||||
console.log("🚀 ~ submitPayment ~ param:", param)
|
|
||||||
request(apiArr.mergePreorder, "POST", param).then(res => {
|
request(apiArr.mergePreorder, "POST", param).then(res => {
|
||||||
console.log("🚀 ~ submitPayment ~ res:", res)
|
|
||||||
|
if (res && res.timeStamp && res.nonceStr && res.package && res.signType && res.paySign) {
|
||||||
|
// 调用微信支付
|
||||||
|
uni.requestPayment({
|
||||||
|
timeStamp: res.timeStamp,
|
||||||
|
nonceStr: res.nonceStr,
|
||||||
|
package: res.package,
|
||||||
|
signType: res.signType,
|
||||||
|
paySign: res.paySign,
|
||||||
|
success: (payRes) => {
|
||||||
|
console.log("支付成功", payRes)
|
||||||
|
uni.showToast({
|
||||||
|
title: '支付成功',
|
||||||
|
icon: 'success'
|
||||||
|
})
|
||||||
|
},
|
||||||
|
fail: (payErr) => {
|
||||||
|
console.log("支付失败", payErr)
|
||||||
|
uni.showToast({
|
||||||
|
title: payErr.errMsg || '支付失败',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
},
|
||||||
|
complete: () => {
|
||||||
|
// 支付完成后的回调,无论成功失败都会执行
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
console.error("获取支付参数失败,缺少必要参数")
|
||||||
|
uni.showToast({
|
||||||
|
title: '获取支付信息失败',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
@ -31,8 +31,12 @@
|
|||||||
<view v-for="(carItem, carIndex) in isDayCarList" :key="carItem.id" :index="carIndex">
|
<view v-for="(carItem, carIndex) in isDayCarList" :key="carItem.id" :index="carIndex">
|
||||||
<view class="goodsItem_supplier">
|
<view class="goodsItem_supplier">
|
||||||
<view class="goodsItem_left" @click="supplierCheck(carItem, true)">
|
<view class="goodsItem_left" @click="supplierCheck(carItem, true)">
|
||||||
<image v-if="!carItem.supplierChecked" src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check1.png"></image>
|
<image v-if="!carItem.supplierChecked"
|
||||||
<image v-if="carItem.supplierChecked" src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check2.png"></image>
|
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check1.png">
|
||||||
|
</image>
|
||||||
|
<image v-if="carItem.supplierChecked"
|
||||||
|
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check2.png">
|
||||||
|
</image>
|
||||||
</view>
|
</view>
|
||||||
<view class="goodsItem_tit">
|
<view class="goodsItem_tit">
|
||||||
{{ carItem.supplier_name }}
|
{{ carItem.supplier_name }}
|
||||||
@ -64,7 +68,9 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="goodsItem_msg_right_msg">
|
<view class="goodsItem_msg_right_msg">
|
||||||
<view class="goodsItem_msg_right_msg_left">
|
<view class="goodsItem_msg_right_msg_left">
|
||||||
<span>¥</span>{{ item.commodity_goods_info.sales_price }}
|
<span>¥</span>{{ item.commodity_goods_info.group_buy_price ?
|
||||||
|
item.commodity_goods_info.group_buy_price :
|
||||||
|
item.commodity_goods_info.sales_price }}
|
||||||
<span>/{{ item.commodity_goods_info.goods_unit }}</span>
|
<span>/{{ item.commodity_goods_info.goods_unit }}</span>
|
||||||
</view>
|
</view>
|
||||||
<view class="goodsItem_msg_right_msg_right">
|
<view class="goodsItem_msg_right_msg_right">
|
||||||
@ -88,7 +94,6 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
|
||||||
<view class="is_day" v-if="parcelPostshow" style="margin-top: 20rpx;">
|
<view class="is_day" v-if="parcelPostshow" style="margin-top: 20rpx;">
|
||||||
<view class="footer_all" @click="parcel_post_checked"
|
<view class="footer_all" @click="parcel_post_checked"
|
||||||
style="color: orange; font-size: 35rpx; font-weight: bolder;">
|
style="color: orange; font-size: 35rpx; font-weight: bolder;">
|
||||||
@ -104,8 +109,12 @@
|
|||||||
<view v-for="(carItem, carIndex) in shopCarList" :key="carItem.id" :index="carIndex">
|
<view v-for="(carItem, carIndex) in shopCarList" :key="carItem.id" :index="carIndex">
|
||||||
<view class="goodsItem_supplier">
|
<view class="goodsItem_supplier">
|
||||||
<view class="goodsItem_left" @click="supplierCheck(carItem, false)">
|
<view class="goodsItem_left" @click="supplierCheck(carItem, false)">
|
||||||
<image v-if="!carItem.supplierChecked" src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check1.png"></image>
|
<image v-if="!carItem.supplierChecked"
|
||||||
<image v-if="carItem.supplierChecked" src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check2.png"></image>
|
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check1.png">
|
||||||
|
</image>
|
||||||
|
<image v-if="carItem.supplierChecked"
|
||||||
|
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check2.png">
|
||||||
|
</image>
|
||||||
</view>
|
</view>
|
||||||
<view class="goodsItem_tit">
|
<view class="goodsItem_tit">
|
||||||
{{ carItem.supplier_name }}
|
{{ carItem.supplier_name }}
|
||||||
@ -124,7 +133,6 @@
|
|||||||
<view class="goodsItem_right">
|
<view class="goodsItem_right">
|
||||||
<view class="goodsItem_msg">
|
<view class="goodsItem_msg">
|
||||||
<view class="goodsItem_msg_img">
|
<view class="goodsItem_msg_img">
|
||||||
|
|
||||||
<image :src="picUrl + item.commodity_goods_info.commodity_pic">
|
<image :src="picUrl + item.commodity_goods_info.commodity_pic">
|
||||||
</image>
|
</image>
|
||||||
</view>
|
</view>
|
||||||
@ -137,7 +145,9 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="goodsItem_msg_right_msg">
|
<view class="goodsItem_msg_right_msg">
|
||||||
<view class="goodsItem_msg_right_msg_left">
|
<view class="goodsItem_msg_right_msg_left">
|
||||||
<span>¥</span>{{ item.commodity_goods_info.sales_price }}
|
<span>¥</span>{{ item.commodity_goods_info.group_buy_price ?
|
||||||
|
item.commodity_goods_info.group_buy_price :
|
||||||
|
item.commodity_goods_info.sales_price }}
|
||||||
<span>/{{ item.commodity_goods_info.goods_unit }}</span>
|
<span>/{{ item.commodity_goods_info.goods_unit }}</span>
|
||||||
</view>
|
</view>
|
||||||
<view class="goodsItem_msg_right_msg_right">
|
<view class="goodsItem_msg_right_msg_right">
|
||||||
@ -234,32 +244,32 @@ export default {
|
|||||||
// }
|
// }
|
||||||
// },
|
// },
|
||||||
methods: {
|
methods: {
|
||||||
back() {
|
back() {
|
||||||
NavgateTo("1");
|
NavgateTo("1");
|
||||||
},
|
},
|
||||||
|
|
||||||
// 商家单选框全选/取消全选
|
// 商家单选框全选/取消全选
|
||||||
supplierCheck(carItem, isDay) {
|
supplierCheck(carItem, isDay) {
|
||||||
carItem.supplierChecked = !carItem.supplierChecked;
|
carItem.supplierChecked = !carItem.supplierChecked;
|
||||||
carItem.commodity_cart_and_goods_model.forEach(goods => {
|
carItem.commodity_cart_and_goods_model.forEach(goods => {
|
||||||
goods.checked = carItem.supplierChecked;
|
goods.checked = carItem.supplierChecked;
|
||||||
});
|
});
|
||||||
this.calcTotal();
|
this.calcTotal();
|
||||||
|
|
||||||
// 更新当日达或包邮全选状态
|
// 更新当日达或包邮全选状态
|
||||||
if (isDay) {
|
if (isDay) {
|
||||||
this.isDaychecked = this.isDayCarList.every(item =>
|
this.isDaychecked = this.isDayCarList.every(item =>
|
||||||
item.commodity_cart_and_goods_model.every(goods => goods.checked)
|
item.commodity_cart_and_goods_model.every(goods => goods.checked)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
this.isParcelPostchecked = this.shopCarList.every(item =>
|
this.isParcelPostchecked = this.shopCarList.every(item =>
|
||||||
item.commodity_cart_and_goods_model.every(goods => goods.checked)
|
item.commodity_cart_and_goods_model.every(goods => goods.checked)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新全选状态
|
// 更新全选状态
|
||||||
this.isAllchecked = this.isDaychecked && this.isParcelPostchecked;
|
this.isAllchecked = this.isDaychecked && this.isParcelPostchecked;
|
||||||
},
|
},
|
||||||
|
|
||||||
// 结算
|
// 结算
|
||||||
submitOrder() {
|
submitOrder() {
|
||||||
@ -294,30 +304,32 @@ export default {
|
|||||||
res.normal_cart_list.forEach((item) => {
|
res.normal_cart_list.forEach((item) => {
|
||||||
item.checked = false;
|
item.checked = false;
|
||||||
item.supplierChecked = false;
|
item.supplierChecked = false;
|
||||||
this.parcelPostshow = true;
|
|
||||||
})
|
})
|
||||||
|
this.parcelPostshow = true;
|
||||||
this.shopCarList = res.normal_cart_list
|
this.shopCarList = res.normal_cart_list
|
||||||
} else {
|
} else {
|
||||||
res.normal_cart_list.forEach((item) => {
|
res.normal_cart_list.forEach((item) => {
|
||||||
item.checked = false;
|
item.checked = false;
|
||||||
item.supplierChecked = false;
|
item.supplierChecked = false;
|
||||||
this.parcelPostshow = false;
|
|
||||||
})
|
})
|
||||||
|
this.parcelPostshow = false;
|
||||||
|
this.shopCarList = []
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res.same_day_cart_list.length > 0) {
|
if (res.same_day_cart_list.length > 0) {
|
||||||
res.same_day_cart_list.forEach((item) => {
|
res.same_day_cart_list.forEach((item) => {
|
||||||
item.checked = false;
|
item.checked = false;
|
||||||
item.supplierChecked = false;
|
item.supplierChecked = false;
|
||||||
this.isDayshow = true;
|
|
||||||
})
|
})
|
||||||
|
this.isDayshow = true;
|
||||||
this.isDayCarList = res.same_day_cart_list
|
this.isDayCarList = res.same_day_cart_list
|
||||||
} else {
|
} else {
|
||||||
res.normal_cart_list.forEach((item) => {
|
res.normal_cart_list.forEach((item) => {
|
||||||
item.checked = false;
|
item.checked = false;
|
||||||
item.supplierChecked = false;
|
item.supplierChecked = false;
|
||||||
this.isDayshow = false;
|
|
||||||
})
|
})
|
||||||
|
this.isDayshow = false;
|
||||||
|
this.isDayCarList = []
|
||||||
}
|
}
|
||||||
|
|
||||||
// res.normal_cart_list.forEach((item) => {
|
// res.normal_cart_list.forEach((item) => {
|
||||||
@ -351,11 +363,11 @@ export default {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 检查当日达是否全选
|
// 检查当日达是否全选
|
||||||
this.isDaychecked = this.isDayCarList.every(carItem =>
|
this.isDaychecked = this.isDayCarList.every(carItem =>
|
||||||
carItem.commodity_cart_and_goods_model.every(goods => goods.checked)
|
carItem.commodity_cart_and_goods_model.every(goods => goods.checked)
|
||||||
);
|
);
|
||||||
// 检查包邮是否全选
|
// 检查包邮是否全选
|
||||||
this.isParcelPostchecked = this.shopCarList.every(carItem =>
|
this.isParcelPostchecked = this.shopCarList.every(carItem =>
|
||||||
carItem.commodity_cart_and_goods_model.every(goods => goods.checked)
|
carItem.commodity_cart_and_goods_model.every(goods => goods.checked)
|
||||||
);
|
);
|
||||||
// 检查全选状态
|
// 检查全选状态
|
||||||
@ -373,11 +385,11 @@ export default {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 检查当日达是否全选
|
// 检查当日达是否全选
|
||||||
this.isDaychecked = this.isDayCarList.every(carItem =>
|
this.isDaychecked = this.isDayCarList.every(carItem =>
|
||||||
carItem.commodity_cart_and_goods_model.every(goods => goods.checked)
|
carItem.commodity_cart_and_goods_model.every(goods => goods.checked)
|
||||||
);
|
);
|
||||||
// 检查包邮是否全选
|
// 检查包邮是否全选
|
||||||
this.isParcelPostchecked = this.shopCarList.every(carItem =>
|
this.isParcelPostchecked = this.shopCarList.every(carItem =>
|
||||||
carItem.commodity_cart_and_goods_model.every(goods => goods.checked)
|
carItem.commodity_cart_and_goods_model.every(goods => goods.checked)
|
||||||
);
|
);
|
||||||
// 检查全选状态
|
// 检查全选状态
|
||||||
@ -452,7 +464,10 @@ export default {
|
|||||||
this.isDayCarList.forEach(carItem => {
|
this.isDayCarList.forEach(carItem => {
|
||||||
carItem.commodity_cart_and_goods_model.forEach(goods => {
|
carItem.commodity_cart_and_goods_model.forEach(goods => {
|
||||||
if (goods.checked) {
|
if (goods.checked) {
|
||||||
total += goods.commodity_goods_info.sales_price * goods.count;
|
const price = goods.commodity_goods_info.group_buy_price !== undefined && goods.commodity_goods_info.group_buy_price !== null ?
|
||||||
|
goods.commodity_goods_info.group_buy_price :
|
||||||
|
goods.commodity_goods_info.sales_price;
|
||||||
|
total += price * goods.count;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -461,7 +476,10 @@ export default {
|
|||||||
this.shopCarList.forEach(carItem => {
|
this.shopCarList.forEach(carItem => {
|
||||||
carItem.commodity_cart_and_goods_model.forEach(goods => {
|
carItem.commodity_cart_and_goods_model.forEach(goods => {
|
||||||
if (goods.checked) {
|
if (goods.checked) {
|
||||||
total += goods.commodity_goods_info.sales_price * goods.count;
|
const price = goods.commodity_goods_info.group_buy_price !== undefined && goods.commodity_goods_info.group_buy_price !== null ?
|
||||||
|
goods.commodity_goods_info.group_buy_price :
|
||||||
|
goods.commodity_goods_info.sales_price;
|
||||||
|
total += price * goods.count;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -34,7 +34,6 @@ export default {
|
|||||||
},
|
},
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
const item = JSON.parse(options.item)
|
const item = JSON.parse(options.item)
|
||||||
console.log("🚀 ~ onLoad ~ item:", item)
|
|
||||||
this.getLocationList(item.goods_id)
|
this.getLocationList(item.goods_id)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -45,7 +44,7 @@ export default {
|
|||||||
const res = await request(apiArr.groupBuyAddress, 'POST', params)
|
const res = await request(apiArr.groupBuyAddress, 'POST', params)
|
||||||
// 遍历地址数组并正确赋值
|
// 遍历地址数组并正确赋值
|
||||||
res.self_pickup_address_list[0].address.forEach(item => {
|
res.self_pickup_address_list[0].address.forEach(item => {
|
||||||
const [name, phone, address] = item.split(' ');
|
const [address, phone, name] = item.split(' ');
|
||||||
this.locationList.push({
|
this.locationList.push({
|
||||||
id: id,
|
id: id,
|
||||||
name: name || '',
|
name: name || '',
|
||||||
@ -57,14 +56,12 @@ export default {
|
|||||||
selectLocation(item, index) {
|
selectLocation(item, index) {
|
||||||
// 更新选中项的索引
|
// 更新选中项的索引
|
||||||
this.selectedIndex = index;
|
this.selectedIndex = index;
|
||||||
console.log("🚀 ~ selectLocation ~ 选中地址:", item)
|
|
||||||
|
|
||||||
// 从本地存储获取已有的地址数据
|
// 从本地存储获取已有的地址数据
|
||||||
let addressList = uni.getStorageSync('changeZTAddress') || [];
|
let addressList = uni.getStorageSync('changeZTAddress') || [];
|
||||||
|
|
||||||
// 检查id是否已存在
|
// 检查id是否已存在
|
||||||
const existingIndex = addressList.findIndex(addr => addr.id === item.id);
|
const existingIndex = addressList.findIndex(addr => addr.id === item.id);
|
||||||
console.log("🚀 ~ selectLocation ~ existingIndex:", existingIndex)
|
|
||||||
|
|
||||||
if (existingIndex > -1) {
|
if (existingIndex > -1) {
|
||||||
// 如果id存在,则覆盖原来的数据
|
// 如果id存在,则覆盖原来的数据
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user