|
@ -4,33 +4,56 @@ |
|
|
operate |
|
|
operate |
|
|
}}</view> |
|
|
}}</view> |
|
|
<view> |
|
|
<view> |
|
|
<view class="goodBox" v-if="list.length"> |
|
|
<!-- 按供应商分组显示商品 --> |
|
|
<!-- <view class="title" v-if="item.data.some((v) => v.flag == 1)">{{ item.merchant_name }}<uni-icons |
|
|
<view |
|
|
size="16" color="#000000" type="arrowright" /></view> --> |
|
|
class="goodBox" |
|
|
<view class="goodItem" v-for="(goodItem, goodIndex) in list" :key="goodIndex" v-if="goodItem.flag != 0"> |
|
|
v-for="(supplierGroup, supplierIndex) in list" |
|
|
<view class="noSelect" v-if="!goodItem.is_select" @click="changeSelect(goodItem)"></view> |
|
|
:key="supplierIndex" |
|
|
<view class="selectBox flex-around" v-else @click="changeSelect(goodItem)"> |
|
|
v-if="supplierGroup.goods && supplierGroup.goods.length > 0" |
|
|
<img src="https://static.ticket.sz-trip.com/cgc/images/order/dui.png" /> |
|
|
> |
|
|
|
|
|
<view class="title">{{ supplierGroup.supplierName }}</view> |
|
|
|
|
|
<view |
|
|
|
|
|
class="goodItem" |
|
|
|
|
|
v-for="(goodItem, goodIndex) in supplierGroup.goods" |
|
|
|
|
|
:key="goodIndex" |
|
|
|
|
|
v-if="goodItem.flag != 0" |
|
|
|
|
|
> |
|
|
|
|
|
<view |
|
|
|
|
|
class="noSelect" |
|
|
|
|
|
v-if="!goodItem.is_select" |
|
|
|
|
|
@click="changeSelect(goodItem)" |
|
|
|
|
|
></view> |
|
|
|
|
|
<view |
|
|
|
|
|
class="selectBox flex-around" |
|
|
|
|
|
v-else |
|
|
|
|
|
@click="changeSelect(goodItem)" |
|
|
|
|
|
> |
|
|
|
|
|
<img |
|
|
|
|
|
src="https://static.ticket.sz-trip.com/cgc/images/order/dui.png" |
|
|
|
|
|
/> |
|
|
</view> |
|
|
</view> |
|
|
<image :src="showImg(goodItem.specUrl)" mode="aspectFill" @click="goDetails(goodItem.goodsId)"> |
|
|
<image |
|
|
|
|
|
:src="showImg(goodItem.specUrl)" |
|
|
|
|
|
mode="aspectFill" |
|
|
|
|
|
@click="goDetails(goodItem.goodsId)" |
|
|
|
|
|
> |
|
|
</image> |
|
|
</image> |
|
|
<view class="contentBox"> |
|
|
<view class="contentBox"> |
|
|
<view class="title text-overflow">{{ goodItem.goodsName }}</view> |
|
|
<view class="title text-overflow">{{ goodItem.goodsName }}</view> |
|
|
<view class="subTitle text-overflow">{{ |
|
|
<view class="subTitle text-overflow" |
|
|
goodItem.specValueOne |
|
|
>{{ goodItem.specValueOne }}-{{ goodItem.specValueTwo }}</view |
|
|
}}-{{ |
|
|
> |
|
|
goodItem.specValueTwo |
|
|
|
|
|
}}</view> |
|
|
|
|
|
<view class="priceBox flex-between"> |
|
|
<view class="priceBox flex-between"> |
|
|
<view class="price">{{ |
|
|
<view class="price">{{ goodItem.salePrice }}</view> |
|
|
goodItem.salePrice |
|
|
|
|
|
}}</view> |
|
|
|
|
|
<view class="quantity-control"> |
|
|
<view class="quantity-control"> |
|
|
<view :class="[ |
|
|
<view |
|
|
|
|
|
:class="[ |
|
|
'quantity-btn', |
|
|
'quantity-btn', |
|
|
'minus-btn', |
|
|
'minus-btn', |
|
|
goodItem.quantity == 1 ? 'disabled' : '', |
|
|
goodItem.quantity == 1 ? 'disabled' : '', |
|
|
]" @click="delNum(goodItem)"> |
|
|
]" |
|
|
|
|
|
@click="delNum(goodItem)" |
|
|
|
|
|
> |
|
|
- |
|
|
- |
|
|
</view> |
|
|
</view> |
|
|
<view class="quantity-input">{{ goodItem.quantity }}</view> |
|
|
<view class="quantity-input">{{ goodItem.quantity }}</view> |
|
@ -45,17 +68,21 @@ |
|
|
</view> |
|
|
</view> |
|
|
|
|
|
|
|
|
<view class="loseGood" v-if="loseList && loseList.length > 0"> |
|
|
<view class="loseGood" v-if="loseList && loseList.length > 0"> |
|
|
<view class="title flex-between">失效商品<span @click="delLoseGood('', 1)">清空失效商品</span></view> |
|
|
<view class="title flex-between" |
|
|
<view class="goodItem" v-for="(goodItem, goodIndex) in loseList" :key="goodIndex"> |
|
|
>失效商品<span @click="delLoseGood('', 1)">清空失效商品</span></view |
|
|
|
|
|
> |
|
|
|
|
|
<view |
|
|
|
|
|
class="goodItem" |
|
|
|
|
|
v-for="(goodItem, goodIndex) in loseList" |
|
|
|
|
|
:key="goodIndex" |
|
|
|
|
|
> |
|
|
<view class="noSelect"></view> |
|
|
<view class="noSelect"></view> |
|
|
<image :src="showImg(goodItem.specUrl)" mode="aspectFill"></image> |
|
|
<image :src="showImg(goodItem.specUrl)" mode="aspectFill"></image> |
|
|
<view class="contentBox"> |
|
|
<view class="contentBox"> |
|
|
<view class="title text-overflow">{{ goodItem.goodsName }}</view> |
|
|
<view class="title text-overflow">{{ goodItem.goodsName }}</view> |
|
|
<view class="subTitle text-overflow">{{ |
|
|
<view class="subTitle text-overflow" |
|
|
goodItem.specValueOne |
|
|
>{{ goodItem.specValueOne }}-{{ goodItem.specValueTwo }}</view |
|
|
}}-{{ |
|
|
> |
|
|
goodItem.specValueTwo |
|
|
|
|
|
}}</view> |
|
|
|
|
|
<view class="priceBox flex-between"> |
|
|
<view class="priceBox flex-between"> |
|
|
<view class="price">{{ goodItem.salePrice }}</view> |
|
|
<view class="price">{{ goodItem.salePrice }}</view> |
|
|
<view class="btn" @click="delLoseGood(goodItem.id, 0)">删除</view> |
|
|
<view class="btn" @click="delLoseGood(goodItem.id, 0)">删除</view> |
|
@ -79,8 +106,15 @@ |
|
|
</view> |
|
|
</view> |
|
|
|
|
|
|
|
|
<!-- 空状态 --> |
|
|
<!-- 空状态 --> |
|
|
<view class="empty-state" v-if="list.length == 0 && loseList.length == 0"> |
|
|
<view |
|
|
<image class="empty-icon" :src="showImg('/uploads/20250826/empty-cart.png')" mode="aspectFit"></image> |
|
|
class="empty-state" |
|
|
|
|
|
v-if="getTotalGoodsCount() == 0 && loseList.length == 0" |
|
|
|
|
|
> |
|
|
|
|
|
<image |
|
|
|
|
|
class="empty-icon" |
|
|
|
|
|
:src="showImg('/uploads/20250826/empty-cart.png')" |
|
|
|
|
|
mode="aspectFit" |
|
|
|
|
|
></image> |
|
|
<text class="empty-title">购物车空空如也</text> |
|
|
<text class="empty-title">购物车空空如也</text> |
|
|
<text class="empty-desc">快去挑选心仪的商品吧</text> |
|
|
<text class="empty-desc">快去挑选心仪的商品吧</text> |
|
|
<view class="empty-btn" @click="goShopping">去逛逛</view> |
|
|
<view class="empty-btn" @click="goShopping">去逛逛</view> |
|
@ -93,7 +127,7 @@ |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
operate: "管理", |
|
|
operate: "管理", |
|
|
list: [], |
|
|
list: [], // 改为按供应商分组的数组 |
|
|
loseList: [], |
|
|
loseList: [], |
|
|
allSelect: false, |
|
|
allSelect: false, |
|
|
}; |
|
|
}; |
|
@ -104,20 +138,32 @@ |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
getShoppingList() { |
|
|
getShoppingList() { |
|
|
this.Post({}, |
|
|
this.Post({}, "/framework/cart/list", "DES") |
|
|
"/framework/cart/list", "DES" |
|
|
|
|
|
) |
|
|
|
|
|
.then((res) => { |
|
|
.then((res) => { |
|
|
const list = res.data || []; |
|
|
const list = res.data || []; |
|
|
this.loseList = []; |
|
|
this.loseList = []; |
|
|
this.list = []; |
|
|
|
|
|
|
|
|
// 按供应商分组有效商品 |
|
|
|
|
|
const supplierGroups = {}; |
|
|
list.forEach((item) => { |
|
|
list.forEach((item) => { |
|
|
if (item.effectStatus == 1) { |
|
|
if (item.effectStatus == 1) { |
|
|
this.loseList.push(item); |
|
|
this.loseList.push(item); |
|
|
} else { |
|
|
} else { |
|
|
this.list.push(item) |
|
|
const supplierId = item.supplierId || "default"; |
|
|
|
|
|
if (!supplierGroups[supplierId]) { |
|
|
|
|
|
supplierGroups[supplierId] = { |
|
|
|
|
|
supplierId: supplierId, |
|
|
|
|
|
supplierName: item.supplierName || "默认供应商", |
|
|
|
|
|
goods: [], |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
supplierGroups[supplierId].goods.push(item); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 转换为数组格式 |
|
|
|
|
|
this.list = Object.values(supplierGroups); |
|
|
|
|
|
|
|
|
console.log("购物车数据更新:", this.list); |
|
|
console.log("购物车数据更新:", this.list); |
|
|
console.log("失效商品:", this.loseList); |
|
|
console.log("失效商品:", this.loseList); |
|
|
}) |
|
|
}) |
|
@ -155,11 +201,13 @@ |
|
|
updateCart(item) { |
|
|
updateCart(item) { |
|
|
let that = this; |
|
|
let that = this; |
|
|
that |
|
|
that |
|
|
.Post({ |
|
|
.Post( |
|
|
|
|
|
{ |
|
|
cartId: item.id, |
|
|
cartId: item.id, |
|
|
quantity: item.quantity, |
|
|
quantity: item.quantity, |
|
|
}, |
|
|
}, |
|
|
"/framework/cart/updateQuantity", "DES" |
|
|
"/framework/cart/updateQuantity", |
|
|
|
|
|
"DES" |
|
|
) |
|
|
) |
|
|
.then(function (res) { |
|
|
.then(function (res) { |
|
|
if (res) { |
|
|
if (res) { |
|
@ -170,14 +218,18 @@ |
|
|
// 更改选中状态 |
|
|
// 更改选中状态 |
|
|
changeSelect(item) { |
|
|
changeSelect(item) { |
|
|
item.is_select = !item.is_select; |
|
|
item.is_select = !item.is_select; |
|
|
let checkAll = this.list.findIndex((items) => { |
|
|
// 检查是否所有商品都被选中 |
|
|
return !items.is_select; |
|
|
let allSelected = true; |
|
|
}); |
|
|
for (let supplierGroup of this.list) { |
|
|
if (checkAll == -1) { |
|
|
for (let goods of supplierGroup.goods) { |
|
|
this.allSelect = true; |
|
|
if (!goods.is_select) { |
|
|
} else { |
|
|
allSelected = false; |
|
|
this.allSelect = false; |
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (!allSelected) break; |
|
|
} |
|
|
} |
|
|
|
|
|
this.allSelect = allSelected; |
|
|
this.$forceUpdate(); |
|
|
this.$forceUpdate(); |
|
|
}, |
|
|
}, |
|
|
// 去商品详情 |
|
|
// 去商品详情 |
|
@ -196,10 +248,10 @@ |
|
|
// 改变所有选中 |
|
|
// 改变所有选中 |
|
|
changeAllSelect() { |
|
|
changeAllSelect() { |
|
|
this.allSelect = !this.allSelect; |
|
|
this.allSelect = !this.allSelect; |
|
|
this.list.forEach((item) => { |
|
|
this.list.forEach((supplierGroup) => { |
|
|
item.data.forEach((items) => { |
|
|
supplierGroup.goods.forEach((item) => { |
|
|
if (this.allSelect) items.is_select = true; |
|
|
if (this.allSelect) item.is_select = true; |
|
|
else items.is_select = false; |
|
|
else item.is_select = false; |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
@ -212,9 +264,10 @@ |
|
|
content: "确定要删除这个失效商品吗?", |
|
|
content: "确定要删除这个失效商品吗?", |
|
|
success: (res) => { |
|
|
success: (res) => { |
|
|
if (res.confirm) { |
|
|
if (res.confirm) { |
|
|
this.Post({ |
|
|
this.Post( |
|
|
|
|
|
{ |
|
|
s_id: id, |
|
|
s_id: id, |
|
|
method: 'delete' |
|
|
method: "delete", |
|
|
}, |
|
|
}, |
|
|
`/framework/cart/remove/${id}`, |
|
|
`/framework/cart/remove/${id}`, |
|
|
"DES" |
|
|
"DES" |
|
@ -250,9 +303,10 @@ |
|
|
this.loseList.forEach((item) => { |
|
|
this.loseList.forEach((item) => { |
|
|
ids.push(item.id); |
|
|
ids.push(item.id); |
|
|
}); |
|
|
}); |
|
|
this.Post({ |
|
|
this.Post( |
|
|
|
|
|
{ |
|
|
s_id: ids.toString(), |
|
|
s_id: ids.toString(), |
|
|
method: 'delete' |
|
|
method: "delete", |
|
|
}, |
|
|
}, |
|
|
`/framework/cart/remove/${ids.toString()}`, |
|
|
`/framework/cart/remove/${ids.toString()}`, |
|
|
"DES" |
|
|
"DES" |
|
@ -282,11 +336,13 @@ |
|
|
// 删除商品 |
|
|
// 删除商品 |
|
|
delGood() { |
|
|
delGood() { |
|
|
let ids = []; |
|
|
let ids = []; |
|
|
this.list.forEach((items) => { |
|
|
this.list.forEach((supplierGroup) => { |
|
|
if (items.is_select == true) { |
|
|
supplierGroup.goods.forEach((item) => { |
|
|
ids.push(items.id); |
|
|
if (item.is_select == true) { |
|
|
|
|
|
ids.push(item.id); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
if (ids.length === 0) { |
|
|
if (ids.length === 0) { |
|
|
uni.showToast({ |
|
|
uni.showToast({ |
|
@ -301,9 +357,10 @@ |
|
|
content: `确定要删除选中的${ids.length}件商品吗?`, |
|
|
content: `确定要删除选中的${ids.length}件商品吗?`, |
|
|
success: (res) => { |
|
|
success: (res) => { |
|
|
if (res.confirm) { |
|
|
if (res.confirm) { |
|
|
this.Post({ |
|
|
this.Post( |
|
|
|
|
|
{ |
|
|
s_id: ids.toString(), |
|
|
s_id: ids.toString(), |
|
|
method: 'delete' |
|
|
method: "delete", |
|
|
}, |
|
|
}, |
|
|
`/framework/cart/remove/${ids.toString()}`, |
|
|
`/framework/cart/remove/${ids.toString()}`, |
|
|
"DES" |
|
|
"DES" |
|
@ -333,23 +390,27 @@ |
|
|
// 获取总价 |
|
|
// 获取总价 |
|
|
getAllPrice() { |
|
|
getAllPrice() { |
|
|
let allPrice = 0; |
|
|
let allPrice = 0; |
|
|
this.list.forEach((item) => { |
|
|
this.list.forEach((supplierGroup) => { |
|
|
|
|
|
supplierGroup.goods.forEach((item) => { |
|
|
if (item.is_select == true) { |
|
|
if (item.is_select == true) { |
|
|
allPrice += item.salePrice * item.quantity; |
|
|
allPrice += item.salePrice * item.quantity; |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
}); |
|
|
return allPrice.toFixed(2); |
|
|
return allPrice.toFixed(2); |
|
|
}, |
|
|
}, |
|
|
// 结算 |
|
|
// 结算 |
|
|
order() { |
|
|
order() { |
|
|
let list = []; |
|
|
let list = []; |
|
|
let ids = []; |
|
|
let ids = []; |
|
|
this.list.forEach((item) => { |
|
|
this.list.forEach((supplierGroup) => { |
|
|
|
|
|
supplierGroup.goods.forEach((item) => { |
|
|
if (item.is_select == true) { |
|
|
if (item.is_select == true) { |
|
|
ids.push(item.merchant_id); |
|
|
ids.push(item.merchant_id); |
|
|
list.push(item); |
|
|
list.push(item); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
}); |
|
|
// if (Array.from(new Set(ids)).length > 1) { |
|
|
// if (Array.from(new Set(ids)).length > 1) { |
|
|
// uni.showToast({ |
|
|
// uni.showToast({ |
|
|
// title: '请选择同一商户下的商品', |
|
|
// title: '请选择同一商户下的商品', |
|
@ -364,9 +425,10 @@ |
|
|
}); |
|
|
}); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
this.Post({ |
|
|
this.Post( |
|
|
|
|
|
{ |
|
|
bos: list, |
|
|
bos: list, |
|
|
method: 'post' |
|
|
method: "post", |
|
|
}, |
|
|
}, |
|
|
`/framework/cart/check-cart-items`, |
|
|
`/framework/cart/check-cart-items`, |
|
|
"DES" |
|
|
"DES" |
|
@ -375,27 +437,34 @@ |
|
|
if (res.data.canOrder) { |
|
|
if (res.data.canOrder) { |
|
|
this.$store.commit("changeOrderSCart", list); |
|
|
this.$store.commit("changeOrderSCart", list); |
|
|
this.gotoPath("/subPackages/techan/order"); |
|
|
this.gotoPath("/subPackages/techan/order"); |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
uni.showToast({ |
|
|
uni.showToast({ |
|
|
title: res.message, |
|
|
title: res.message, |
|
|
icon: 'none' |
|
|
icon: "none", |
|
|
}) |
|
|
}); |
|
|
this.getShoppingList() |
|
|
this.getShoppingList(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}).catch((res) => { |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: '部分商品无法下单,请重新加载购物车', |
|
|
|
|
|
icon: 'none' |
|
|
|
|
|
}) |
|
|
}) |
|
|
|
|
|
.catch((res) => { |
|
|
|
|
|
uni.showToast({ |
|
|
|
|
|
title: "部分商品无法下单,请重新加载购物车", |
|
|
|
|
|
icon: "none", |
|
|
|
|
|
}); |
|
|
setTimeout(() => { |
|
|
setTimeout(() => { |
|
|
this.getShoppingList() |
|
|
this.getShoppingList(); |
|
|
},800) |
|
|
}, 800); |
|
|
}) |
|
|
}); |
|
|
|
|
|
|
|
|
// this.gotoPath('/subPackages/goods/goodsOrder') |
|
|
// this.gotoPath('/subPackages/goods/goodsOrder') |
|
|
}, |
|
|
}, |
|
|
|
|
|
// 获取商品总数量 |
|
|
|
|
|
getTotalGoodsCount() { |
|
|
|
|
|
let count = 0; |
|
|
|
|
|
this.list.forEach((supplierGroup) => { |
|
|
|
|
|
count += supplierGroup.goods.length; |
|
|
|
|
|
}); |
|
|
|
|
|
return count; |
|
|
|
|
|
}, |
|
|
}, |
|
|
}, |
|
|
}; |
|
|
}; |
|
|
</script> |
|
|
</script> |
|
@ -437,10 +506,9 @@ |
|
|
box-sizing: border-box; |
|
|
box-sizing: border-box; |
|
|
|
|
|
|
|
|
.title { |
|
|
.title { |
|
|
font-size: 35rpx; |
|
|
font-size: 30rpx; |
|
|
font-family: PingFang SC; |
|
|
font-weight: 600; |
|
|
font-weight: 500; |
|
|
color: #333333; |
|
|
color: #000000; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.goodItem { |
|
|
.goodItem { |
|
@ -551,7 +619,8 @@ |
|
|
font-weight: 500; |
|
|
font-weight: 500; |
|
|
color: #333; |
|
|
color: #333; |
|
|
|
|
|
|
|
|
.btn-text {} |
|
|
.btn-text { |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.quantity-input { |
|
|
.quantity-input { |
|
|