|
|
|
@ -39,14 +39,6 @@
|
|
|
|
|
结算({{totalNum}})
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="">
|
|
|
|
|
<view class="">
|
|
|
|
|
{{store.count}}
|
|
|
|
|
</view>
|
|
|
|
|
<view class="" @click="store.increment">
|
|
|
|
|
新增
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
@ -63,57 +55,15 @@
|
|
|
|
|
const show = ref(true);
|
|
|
|
|
const allchecked = ref(true);
|
|
|
|
|
const checked = ref(true);
|
|
|
|
|
const goods = reactive([{
|
|
|
|
|
flag: true,
|
|
|
|
|
goodsName: "女款-M",
|
|
|
|
|
goodsUnit: '/份',
|
|
|
|
|
goodsId: 1,
|
|
|
|
|
num: 1,
|
|
|
|
|
specsName: '中',
|
|
|
|
|
price: 149,
|
|
|
|
|
goodsImage: "http://192.168.1.3:8089/images/a35e4257-9e9a-43f8-b077-a7664064ce12.png",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
flag: true,
|
|
|
|
|
goodsName: "女款-M",
|
|
|
|
|
goodsUnit: '/份',
|
|
|
|
|
goodsId: 1,
|
|
|
|
|
specsName: '中',
|
|
|
|
|
num: 1,
|
|
|
|
|
price: 149,
|
|
|
|
|
goodsImage: "http://192.168.1.3:8089/images/a35e4257-9e9a-43f8-b077-a7664064ce12.png",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
flag: true,
|
|
|
|
|
goodsName: "女款-M",
|
|
|
|
|
goodsUnit: '/份',
|
|
|
|
|
goodsId: 1,
|
|
|
|
|
num: 1,
|
|
|
|
|
specsName: '中',
|
|
|
|
|
price: 149,
|
|
|
|
|
goodsImage: "http://192.168.1.3:8089/images/a35e4257-9e9a-43f8-b077-a7664064ce12.png",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
flag: true,
|
|
|
|
|
goodsName: "女款-M",
|
|
|
|
|
goodsId: 1,
|
|
|
|
|
num: 1,
|
|
|
|
|
goodsUnit: '/份',
|
|
|
|
|
specsName: '中',
|
|
|
|
|
price: 149,
|
|
|
|
|
goodsImage: "http://192.168.1.3:8089/images/a35e4257-9e9a-43f8-b077-a7664064ce12.png",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
flag: true,
|
|
|
|
|
goodsName: "女款-M",
|
|
|
|
|
goodsId: 1,
|
|
|
|
|
num: 1,
|
|
|
|
|
goodsUnit: '/份',
|
|
|
|
|
specsName: '中',
|
|
|
|
|
price: 149,
|
|
|
|
|
goodsImage: "http://192.168.1.3:8089/images/a35e4257-9e9a-43f8-b077-a7664064ce12.png",
|
|
|
|
|
//获取购物车数据
|
|
|
|
|
const goods = computed(() => {
|
|
|
|
|
if(store.carList.length == 0){
|
|
|
|
|
allchecked.value = false;
|
|
|
|
|
}else{
|
|
|
|
|
allchecked.value = true;
|
|
|
|
|
}
|
|
|
|
|
])
|
|
|
|
|
return store.carList
|
|
|
|
|
})
|
|
|
|
|
const selected = (e, item) => {
|
|
|
|
|
console.log(e)
|
|
|
|
|
console.log(item)
|
|
|
|
@ -123,8 +73,8 @@
|
|
|
|
|
item.flag = true;
|
|
|
|
|
}
|
|
|
|
|
// 过滤出数组中checked为true的项目,如果和原List长度相等,就全选显示
|
|
|
|
|
let newArr = goods.filter(item => (item.flag == true))
|
|
|
|
|
if (newArr.length === goods.length) {
|
|
|
|
|
let newArr = store.carList.filter(item => (item.flag == true))
|
|
|
|
|
if (newArr.length === store.carList.length) {
|
|
|
|
|
allchecked.value = true;
|
|
|
|
|
} else {
|
|
|
|
|
allchecked.value = false;
|
|
|
|
@ -136,14 +86,14 @@
|
|
|
|
|
if (allchecked.value == true) {
|
|
|
|
|
allchecked.value = false;
|
|
|
|
|
// 遍历RecordList数组 取消全选
|
|
|
|
|
goods.forEach(item => {
|
|
|
|
|
store.carList.forEach(item => {
|
|
|
|
|
// this.$set(item, 'flag', false)
|
|
|
|
|
item.flag = false
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
allchecked.value = true;
|
|
|
|
|
// 遍历RecordList数组 设置全选
|
|
|
|
|
goods.forEach(item => {
|
|
|
|
|
store.carList.forEach(item => {
|
|
|
|
|
// this.$set(item, 'flag', true)
|
|
|
|
|
item.flag = true
|
|
|
|
|
})
|
|
|
|
@ -155,11 +105,16 @@
|
|
|
|
|
if (num > 1) {
|
|
|
|
|
num -= 1
|
|
|
|
|
} else if (num = 1) {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: "该宝贝不能减少了哟~"
|
|
|
|
|
store.carList.map((dom, i) => {
|
|
|
|
|
if (dom.goodsID == item.goodsID) {
|
|
|
|
|
store.carList.splice(i, 1)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
item.num = num
|
|
|
|
|
item.num = num;
|
|
|
|
|
if (store.carList.length == 0) {
|
|
|
|
|
allchecked.value = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const add = (item) => {
|
|
|
|
@ -169,7 +124,7 @@
|
|
|
|
|
|
|
|
|
|
const totalNum = computed(() => {
|
|
|
|
|
let totalNum = 0;
|
|
|
|
|
goods.map(item => {
|
|
|
|
|
store.carList.map(item => {
|
|
|
|
|
item.flag ? totalNum += item.num : totalNum += 0
|
|
|
|
|
})
|
|
|
|
|
return totalNum
|
|
|
|
@ -177,7 +132,7 @@
|
|
|
|
|
|
|
|
|
|
const totalPrice = computed(() => {
|
|
|
|
|
let totalPrice = 0;
|
|
|
|
|
goods.map(item => {
|
|
|
|
|
store.carList.map(item => {
|
|
|
|
|
item.flag ? totalPrice += item.num * item.price : totalPrice += 0
|
|
|
|
|
})
|
|
|
|
|
return totalPrice
|
|
|
|
|