修改团购部分bug

This commit is contained in:
赵毅 2025-08-26 18:32:16 +08:00
parent e3c535d596
commit 3ecdf95c24
5 changed files with 195 additions and 110 deletions

View File

@ -165,7 +165,6 @@ export default {
group_buy_goods_list
}
})
console.log("🚀 ~ getGoodsList ~ list:", list)
this.goodsList = list
return res;
})
@ -217,8 +216,14 @@ export default {
},
//
increaseQuantity(goodsIndex, skuIndex) {
this.goodsList[goodsIndex].group_buy_goods_list[skuIndex].quantity++;
this.carNum++;
if (this.goodsList[goodsIndex].group_buy_goods_list[skuIndex].quantity == 0) {
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 = {
goods_id_and_count: [
{
@ -233,8 +238,13 @@ export default {
//
decreaseQuantity(goodsIndex, skuIndex) {
if (this.goodsList[goodsIndex].group_buy_goods_list[skuIndex].quantity > 0) {
this.goodsList[goodsIndex].group_buy_goods_list[skuIndex].quantity--;
this.carNum--;
if(this.goodsList[goodsIndex].group_buy_goods_list[skuIndex].quantity == this.goodsList[goodsIndex].group_buy_goods_list[skuIndex].min_order_quantity){
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 = {
goods_id_and_count: [

View File

@ -82,7 +82,7 @@
</view>
</view>
<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>
@ -185,24 +185,11 @@
加入购物车
</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].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>
@ -337,6 +324,8 @@ import { picUrl, menuButtonInfo, request, NavgateTo } from "../../../utils";
export default {
data() {
return {
itemObj: {},
picUrl,
top: "",
localHeight: "",
@ -506,9 +495,9 @@ export default {
}).then((res) => {
//
res.commodity_goods_info_list.forEach((item) => {
item.goods_detail_pic = item.goods_detail_pic.split(",");
item.goods_carousel = item.goods_carousel.split(",");
item.commodity_pic = item.commodity_pic.split(",");
item.goods_detail_pic = item.goods_detail_pic ? item.goods_detail_pic.split(",") : [];
item.goods_carousel = item.goods_carousel ? item.goods_carousel.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]
this.changeName = this.currentGG.goods_alias
this.changePrice = this.currentGG.sales_price
// group_buy_activity_info
if (res.commodity_goods_info_list && Array.isArray(res.commodity_goods_info_list)) {
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() {
let that = this;
//
let goods_id_and_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) => {
console.log(item.cart_count);
goods_id_and_count.push({
goods_id: item.id,
count: item.cart_count ? item.cart_count.count : 0,
});
});
// this.info.commodity_goods_info_list.forEach((item) => {
// console.log(item.cart_count);
// goods_id_and_count.push({
// goods_id: item.id,
// count: item.cart_count ? item.cart_count.count : 0,
// });
// });
console.log(goods_id_and_count);
// update
request(apiArr.updateCar, "POST", {
goods_id_and_count,
}).then((res) => {
let countVal = this.info.commodity_goods_info_list[this.currentGGIndex].min_order_quantity
const params = {
goods_id_and_count: [
{
goods_id:
this.info.commodity_goods_info_list[this.currentGGIndex].id,
count: countVal,
},
],
}
request(apiArr.updateCar, "POST", params).then((res) => {
that.getShopCar();
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 = {
user_id: uni.getStorageSync("userId"),
goods_id_and_count: [
{
goods_id:
this.info.commodity_goods_info_list[this.currentGGIndex].id,
count: newValue.value,
goods_id: this.info.commodity_goods_info_list[this.currentGGIndex].id,
count: newCount,
},
],
};
request(apiArr.updateCar, "POST", params).then((res) => {
console.log(res);
this.getShopCarList();
uni.showToast({
title: "操作成功!",
success() { },
});
this.getShopCar();
this.getGoodsInfo();
});
},
@ -694,15 +724,15 @@ export default {
}
},
onLoad(options) {
const itemObj = JSON.parse(decodeURIComponent(options.item));
this.itemObj = JSON.parse(decodeURIComponent(options.item));
const meun = menuButtonInfo();
this.top = meun.top;
this.localHeight = meun.height;
this.id = itemObj.commodity_id ? itemObj.commodity_id : itemObj.id;
if (itemObj.commodity_id) {
this.endTime = itemObj.group_buy_activity_info.end_time
this.id = this.itemObj.commodity_id ? this.itemObj.commodity_id : this.itemObj.id;
if (this.itemObj.commodity_id) {
this.endTime = this.itemObj.group_buy_activity_info.end_time
} 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.getEndTheCountdown(this.endTime)
@ -737,11 +767,11 @@ export default {
});
});
request(apiArr.updateCar, "POST", {
goods_id_and_count,
}).then((res) => {
console.log("Cart updated on hide");
});
// request(apiArr.updateCar, "POST", {
// goods_id_and_count,
// }).then((res) => {
// console.log("Cart updated on hide");
// });
return;
},
};

View File

@ -467,10 +467,8 @@ export default {
})
}
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();
@ -495,9 +493,41 @@ export default {
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)
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'
})
}
})
})
},

View File

@ -31,8 +31,12 @@
<view v-for="(carItem, carIndex) in isDayCarList" :key="carItem.id" :index="carIndex">
<view class="goodsItem_supplier">
<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" src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check2.png"></image>
<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"
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check2.png">
</image>
</view>
<view class="goodsItem_tit">
{{ carItem.supplier_name }}
@ -64,7 +68,9 @@
</view>
<view class="goodsItem_msg_right_msg">
<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>
</view>
<view class="goodsItem_msg_right_msg_right">
@ -88,7 +94,6 @@
</view>
</view>
<view class="is_day" v-if="parcelPostshow" style="margin-top: 20rpx;">
<view class="footer_all" @click="parcel_post_checked"
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 class="goodsItem_supplier">
<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" src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check2.png"></image>
<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"
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check2.png">
</image>
</view>
<view class="goodsItem_tit">
{{ carItem.supplier_name }}
@ -124,7 +133,6 @@
<view class="goodsItem_right">
<view class="goodsItem_msg">
<view class="goodsItem_msg_img">
<image :src="picUrl + item.commodity_goods_info.commodity_pic">
</image>
</view>
@ -137,7 +145,9 @@
</view>
<view class="goodsItem_msg_right_msg">
<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>
</view>
<view class="goodsItem_msg_right_msg_right">
@ -234,32 +244,32 @@ export default {
// }
// },
methods: {
back() {
NavgateTo("1");
},
back() {
NavgateTo("1");
},
// /
supplierCheck(carItem, isDay) {
carItem.supplierChecked = !carItem.supplierChecked;
carItem.commodity_cart_and_goods_model.forEach(goods => {
goods.checked = carItem.supplierChecked;
});
this.calcTotal();
// /
supplierCheck(carItem, isDay) {
carItem.supplierChecked = !carItem.supplierChecked;
carItem.commodity_cart_and_goods_model.forEach(goods => {
goods.checked = carItem.supplierChecked;
});
this.calcTotal();
//
if (isDay) {
this.isDaychecked = this.isDayCarList.every(item =>
item.commodity_cart_and_goods_model.every(goods => goods.checked)
);
} else {
this.isParcelPostchecked = this.shopCarList.every(item =>
item.commodity_cart_and_goods_model.every(goods => goods.checked)
);
}
//
if (isDay) {
this.isDaychecked = this.isDayCarList.every(item =>
item.commodity_cart_and_goods_model.every(goods => goods.checked)
);
} else {
this.isParcelPostchecked = this.shopCarList.every(item =>
item.commodity_cart_and_goods_model.every(goods => goods.checked)
);
}
//
this.isAllchecked = this.isDaychecked && this.isParcelPostchecked;
},
//
this.isAllchecked = this.isDaychecked && this.isParcelPostchecked;
},
//
submitOrder() {
@ -294,30 +304,32 @@ export default {
res.normal_cart_list.forEach((item) => {
item.checked = false;
item.supplierChecked = false;
this.parcelPostshow = true;
})
this.parcelPostshow = true;
this.shopCarList = res.normal_cart_list
} else {
res.normal_cart_list.forEach((item) => {
item.checked = false;
item.supplierChecked = false;
this.parcelPostshow = false;
})
this.parcelPostshow = false;
this.shopCarList = []
}
if (res.same_day_cart_list.length > 0) {
res.same_day_cart_list.forEach((item) => {
item.checked = false;
item.supplierChecked = false;
this.isDayshow = true;
})
this.isDayshow = true;
this.isDayCarList = res.same_day_cart_list
} else {
res.normal_cart_list.forEach((item) => {
item.checked = false;
item.supplierChecked = false;
this.isDayshow = false;
})
this.isDayshow = false;
this.isDayCarList = []
}
// res.normal_cart_list.forEach((item) => {
@ -452,7 +464,10 @@ export default {
this.isDayCarList.forEach(carItem => {
carItem.commodity_cart_and_goods_model.forEach(goods => {
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 => {
carItem.commodity_cart_and_goods_model.forEach(goods => {
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;
}
});
});

View File

@ -34,7 +34,6 @@ export default {
},
onLoad(options) {
const item = JSON.parse(options.item)
console.log("🚀 ~ onLoad ~ item:", item)
this.getLocationList(item.goods_id)
},
methods: {
@ -45,7 +44,7 @@ export default {
const res = await request(apiArr.groupBuyAddress, 'POST', params)
//
res.self_pickup_address_list[0].address.forEach(item => {
const [name, phone, address] = item.split(' ');
const [address, phone, name] = item.split(' ');
this.locationList.push({
id: id,
name: name || '',
@ -57,14 +56,12 @@ export default {
selectLocation(item, index) {
//
this.selectedIndex = index;
console.log("🚀 ~ selectLocation ~ 选中地址:", item)
//
let addressList = uni.getStorageSync('changeZTAddress') || [];
// id
const existingIndex = addressList.findIndex(addr => addr.id === item.id);
console.log("🚀 ~ selectLocation ~ existingIndex:", existingIndex)
if (existingIndex > -1) {
// id