修改花馍详情页加入购物车的逻辑

This commit is contained in:
赵毅 2025-10-09 10:49:47 +08:00
parent dcfcfaf91f
commit 24d6593f42
3 changed files with 52 additions and 18 deletions

View File

@ -649,7 +649,7 @@ export default {
addCar() { addCar() {
let that = this; let that = this;
this.info.commodity_goods_info_list[this.currentGGIndex].cart_count = { this.info.commodity_goods_info_list[this.currentGGIndex].cart_count = {
count: this.info.commodity_goods_info_list[this.currentGGIndex].min_order_quantity, count: 1,
}; };
// 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);
@ -659,7 +659,7 @@ export default {
// }); // });
// }); // });
let countVal = this.info.commodity_goods_info_list[this.currentGGIndex].min_order_quantity let countVal = 1
const params = { const params = {
goods_id_and_count: [ goods_id_and_count: [
@ -670,10 +670,10 @@ export default {
price: this.changePrice price: this.changePrice
}, },
], ],
group_buy_id: this.info.commodity_goods_info_list[this.currentGGIndex].group_buy_activity_id, adver_id: this.itemObj.adver_id,
} }
request(apiArr.updateCar, "POST", params).then((res) => { request(apiArr.updateCar, "POST", params).then((res) => {
that.getShopCar(); // that.getShopCar();
that.getShopCarList(); that.getShopCarList();
}); });
}, },
@ -693,7 +693,7 @@ export default {
count: newCount, count: newCount,
}, },
], ],
group_buy_id: this.info.commodity_goods_info_list[this.currentGGIndex].group_buy_activity_id, adver_id: this.itemObj.adver_id,
}; };
request(apiArr.updateCar, "POST", params).then((res) => { request(apiArr.updateCar, "POST", params).then((res) => {

View File

@ -54,6 +54,10 @@
margin-right: 10rpx; margin-right: 10rpx;
} }
.addressItem_footer_left2 {
display: flex;
}
.addressItem_footer_right { .addressItem_footer_right {
display: flex; display: flex;
align-items: center; align-items: center;

View File

@ -3,27 +3,29 @@
<view class="hasAddress"> <view class="hasAddress">
<view class="addressList"> <view class="addressList">
<view class="addressItem" v-for="item, index in list" :key="index" :class="{ 'addressItem_def': index == 0 }" @click="selectAddress(item)"> <view class="addressItem" v-for="item, index in list" :key="index"
:class="{ 'addressItem_def': index == 0 }" @click="selectAddress(item)">
<view class="addressItem_top"> <view class="addressItem_top">
{{item.name}} {{item.phone}} <view v-if="item.is_default === 1" class="is_def">默认</view> {{ item.name }} {{ item.phone }} <view v-if="item.is_default === 1" class="is_def">默认</view>
</view> </view>
<view class="addressItem_mid">{{item.address}}{{ item.house_number }}</view> <view class="addressItem_mid">{{ item.address }}{{ item.house_number }}</view>
<view class="addressItem_footer"> <view class="addressItem_footer">
<view class="addressItem_footer_left"> <view class="addressItem_footer_left">
<view v-if="item.is_default !== 1" @click="headerSettingDefault(item.id)"> <view v-if="item.is_default !== 1" @click.stop="headerSettingDefault(item.id)"
<image src="http://192.168.0.172:5500/7.15/shop_checked1.png"></image> class="addressItem_footer_left2">
<view class="checkbox"></view>
设为默认 设为默认
</view> </view>
<view v-if="item.is_default === 1"> <view v-if="item.is_default === 1" class="addressItem_footer_left2">
<image src="http://192.168.0.172:5500/7.15/shop_checked2.png"></image> <view class="checkbox checkbox-checked"></view>
已默认 已默认
</view> </view>
</view> </view>
<view class="addressItem_footer_right"> <view class="addressItem_footer_right">
<view class="btn1" @click="deleteItem(item.id )">删除</view> <view class="btn1" @click.stop="deleteItem(item.id)">删除</view>
<view class="btn2" @click="editItem(item)">修改</view> <view class="btn2" @click.stop="editItem(item)">修改</view>
</view> </view>
</view> </view>
</view> </view>
@ -61,7 +63,7 @@ export default {
} }
}, },
methods: { methods: {
addAddress(){ addAddress() {
NavgateTo("../addAddress/index") NavgateTo("../addAddress/index")
}, },
@ -71,7 +73,7 @@ export default {
async headerSettingDefault(id) { async headerSettingDefault(id) {
const res = await request(apiArr.settingDefaultAddress, 'POST', { id }, { silent: true, nested: true }); const res = await request(apiArr.settingDefaultAddress, 'POST', { id }, { silent: true, nested: true });
if(res.code === 1){ if (res.code === 1) {
uni.showToast({ uni.showToast({
title: '设置成功', title: '设置成功',
icon: 'success', icon: 'success',
@ -81,7 +83,7 @@ export default {
} }
}, },
deleteItem(id){ deleteItem(id) {
const _this = this; const _this = this;
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
@ -102,7 +104,7 @@ export default {
} }
}); });
}, },
// //
selectAddress(item) { selectAddress(item) {
// //
@ -133,4 +135,32 @@ export default {
<style> <style>
@import url("./index.css"); @import url("./index.css");
/* 多选框样式 */
.checkbox {
width: 32rpx;
height: 32rpx;
border: 2rpx solid #D1D1D1;
border-radius: 6rpx;
margin-right: 10rpx;
display: flex;
align-items: center;
justify-content: center;
background-color: #FFFFFF;
}
.checkbox-checked {
border-color: #FF370B;
background-color: #FF370B;
}
.checkbox-checked::after {
content: "";
display: block;
width: 16rpx;
height: 8rpx;
border-left: 2rpx solid #FFFFFF;
border-bottom: 2rpx solid #FFFFFF;
transform: rotate(-45deg);
}
</style> </style>