增加新功能
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
<view class="enit_but" @click="isEdit = true">编辑</view>
|
||||
</view>
|
||||
<!-- 购物车列表 -->
|
||||
<up-loading-page :loading="listLoading"></up-loading-page>
|
||||
<view
|
||||
class="shopping_cart_content"
|
||||
>
|
||||
@@ -22,10 +23,11 @@
|
||||
activeColor="#FF7C41"
|
||||
size="19"
|
||||
iconSize="18"
|
||||
@change="(event)=>shoppingChange(event,index)"
|
||||
>
|
||||
<template #label>
|
||||
<view class="content_item_header">
|
||||
<up-image :src="item.shopLogo ?item.shopLogo :'/static/shopping/store.png'" width="22" height="22" bgColor="#f1f6ff00"></up-image>
|
||||
<up-image :src="item.shopLogo ?item.shopLogo :'/static/shopping/store.png'" width="22" height="22" bgColor="#f1f6ff00" shape="circle"></up-image>
|
||||
<view class="order_product_title">{{item.shopName}}{{item.id}}</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -43,9 +45,10 @@
|
||||
size="19"
|
||||
iconSize="18"
|
||||
:disabled="!pItem.isAvail"
|
||||
@change="(event)=>productChange(event,index,pIndex)"
|
||||
>
|
||||
</up-checkbox>
|
||||
<view class="info_item">
|
||||
<view class="info_item" @click="jumpInfo(pItem)">
|
||||
<up-image :src="pItem.mainGraph" width="100" height="100" bgColor="#f1f6ff00"></up-image>
|
||||
<view class="content_info">
|
||||
<view class="shopping_content_info_title">{{pItem.name}}</view>
|
||||
@@ -101,13 +104,13 @@
|
||||
</up-checkbox>
|
||||
<text style="margin-left: 20rpx;font-size: 24rpx;color: #444444;">合计:</text>
|
||||
<text style="font-size: 24rpx;">¥</text>
|
||||
<text style="font-size: 32rpx;">2000.00</text>
|
||||
<text style="font-size: 32rpx;">{{total}}</text>
|
||||
</view>
|
||||
<view v-if="isEdit" class="delete_but_css" @click="deleteShopping">
|
||||
删除
|
||||
</view>
|
||||
<view v-else class="add_but_css" @click="settleShopping">
|
||||
结算(2)
|
||||
结算({{count}})
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -131,9 +134,12 @@
|
||||
shoppingList:[],// 购物车列表
|
||||
isEdit:false,// 是否编辑
|
||||
isAll:false,// 是否全选
|
||||
total:0,// 总合计的金额
|
||||
count:0,// 总条数
|
||||
listLoading:false,
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
onLoad() {
|
||||
this.getCartList();
|
||||
},
|
||||
methods: {
|
||||
@@ -141,6 +147,7 @@
|
||||
* 查询购物车列表
|
||||
*/
|
||||
async getCartList(){
|
||||
this.listLoading = true;
|
||||
const resp = await getCartList();
|
||||
if(resp && resp.bizcode === 100){
|
||||
// 处理了后的数据
|
||||
@@ -148,14 +155,14 @@
|
||||
this.shoppingTotal = resp.data.length;
|
||||
this.shoppingList = data;
|
||||
}
|
||||
this.listLoading = false;
|
||||
},
|
||||
// 处理购物车的数据
|
||||
transformedArray(originalArray){
|
||||
const newOriginalArray = [];
|
||||
|
||||
originalArray.map(curr=>{
|
||||
console.log("currcurrcurrcurr",curr);
|
||||
const existingShop = newOriginalArray.find(shop => shop.shopId === curr.shopId && shop.shopName === curr.shopName);
|
||||
|
||||
if (existingShop) {
|
||||
// 如果商店已存在,则向 productObj 数组中添加新产品对象
|
||||
existingShop.product.push({
|
||||
@@ -193,7 +200,6 @@
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
return newOriginalArray;
|
||||
},
|
||||
/**
|
||||
@@ -232,7 +238,6 @@
|
||||
* 结算订单
|
||||
*/
|
||||
settleShopping(){
|
||||
console.log("结算订单....")
|
||||
const deleteId = this.getCheckList();
|
||||
if(!deleteId || deleteId.length === 0){
|
||||
this.$refs.uToastRef.show({
|
||||
@@ -241,11 +246,11 @@
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.isAll = false;
|
||||
this.selectCheck(false);
|
||||
uni.navigateTo({
|
||||
url:"/pages/order_submit/order_submit?ids="+deleteId.join(","),
|
||||
})
|
||||
this.isAll = false;
|
||||
this.selectCheck(false);
|
||||
},
|
||||
/**
|
||||
* 删除选中的
|
||||
@@ -334,6 +339,56 @@
|
||||
})
|
||||
this.shoppingList = currentShoppingList;
|
||||
},
|
||||
|
||||
/**
|
||||
* 商品详情
|
||||
* @param {Object} item
|
||||
*/
|
||||
jumpInfo(item){
|
||||
console.log("item",item);
|
||||
uni.navigateTo({
|
||||
url:'/pages/productInfo/productInfo?id='+item.goodsId,
|
||||
})
|
||||
},
|
||||
|
||||
// 单个产品的单选按钮选中与取消选中
|
||||
productChange(val,index,pIndex){
|
||||
let total = this.total;
|
||||
let count = this.count;
|
||||
const data = this.shoppingList[index].product[pIndex];
|
||||
if(val){
|
||||
total = total + data.buyNum * data.unitPrice;
|
||||
count = count + data.buyNum;
|
||||
}else{
|
||||
total = total - data.buyNum * data.unitPrice;
|
||||
count = count - data.buyNum;
|
||||
}
|
||||
this.total = total;
|
||||
this.count = count;
|
||||
},
|
||||
// 单个店铺的单选按钮选中与取消选中
|
||||
shoppingChange(val,index){
|
||||
let total = this.total;
|
||||
let count = this.count;
|
||||
const data = this.shoppingList[index];
|
||||
data.product.map(item=>{
|
||||
if(val){
|
||||
item.isCheck = true;
|
||||
total = total + item.buyNum * item.unitPrice;
|
||||
count = count + item.buyNum;
|
||||
}else{
|
||||
item.isCheck = false;
|
||||
total = total - item.buyNum * item.unitPrice;
|
||||
count = count - item.buyNum;
|
||||
}
|
||||
})
|
||||
this.shoppingList[index] = data;
|
||||
this.total = total;
|
||||
this.count = count;
|
||||
},
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -380,6 +435,7 @@
|
||||
}
|
||||
.content_info{
|
||||
margin-left: 10rpx;
|
||||
width: calc(100% - 100rpx);
|
||||
}
|
||||
.shopping_content_info_title{
|
||||
font-weight: bold;
|
||||
|
||||
Reference in New Issue
Block a user