20261008
This commit is contained in:
+51
-19
@@ -9,11 +9,11 @@
|
||||
<text class="font-bold text-40">
|
||||
购物车(全部{{ list.length }})
|
||||
</text>
|
||||
<view class="flex justify-end items-center">
|
||||
<text>已选商品(不含运费)</text>
|
||||
<text class="text-main text-40 font-bold mx-20">¥{{ amount }}</text>
|
||||
<el-button type="primary" round>结算</el-button>
|
||||
</view>
|
||||
<!-- <view class="flex justify-end items-center">-->
|
||||
<!-- <text>已选商品(不含运费)</text>-->
|
||||
<!-- <text class="text-main text-40 font-bold mx-20">¥{{ amount }}</text>-->
|
||||
<!-- <el-button type="primary" round @click.native="addFromCart">结算</el-button>-->
|
||||
<!-- </view>-->
|
||||
</view>
|
||||
<view class="py-20">
|
||||
<el-row :gutter="10">
|
||||
@@ -46,23 +46,24 @@
|
||||
<view class="flex justify-start items-start">
|
||||
<el-checkbox v-model="list[index].checked" @change="changeCheck($event, item._id)">
|
||||
</el-checkbox>
|
||||
<el-image :src="item.goods.cover" class="cover ml-20" fit="fit"/>
|
||||
<el-image :src="item.goods.cover" class="cover ml-20" fit="fit"/>
|
||||
<view class="flex flex-col justify-start items-start ml-20">
|
||||
{{ item.goods.name }}
|
||||
<text class="font-bold mb-15">{{ item.goods.name }}</text>
|
||||
<text class="text-gray">{{ item.sku.label }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</el-col>
|
||||
<el-col :span="3">
|
||||
<text class="text-35 font-bold flex-1">¥{{ item.goods.amount }}</text>
|
||||
<text class="text-35 font-bold flex-1">¥{{ item.sku.values }}</text>
|
||||
</el-col>
|
||||
<el-col :span="3">
|
||||
<text class="text-35 font-bold flex-1">
|
||||
<el-input-number v-model="list[index].num" @change="changeNum" :min="1" size="small"/>
|
||||
<el-input-number v-model="list[index].num" @change="changeNum(index)" :min="1" size="small"/>
|
||||
</text>
|
||||
</el-col>
|
||||
<el-col :span="3">
|
||||
<text class="text-35 font-bold flex-1 text-main">¥{{
|
||||
parseFloat(item.goods.amount) * item.num
|
||||
parseFloat(item.sku.values) * item.num
|
||||
}}
|
||||
</text>
|
||||
</el-col>
|
||||
@@ -72,16 +73,16 @@
|
||||
</el-row>
|
||||
</view>
|
||||
<view class="mt-20 flex justify-between items-center">
|
||||
<el-button type="text">移出购物车</el-button>
|
||||
<el-button type="text" @click.native="removeMulti" :disabled="selectedList.length === 0">移出购物车</el-button>
|
||||
<view class="flex justify-end items-center">
|
||||
<view>
|
||||
<text>已选商品</text>
|
||||
<text class="mx-15 font-bold text-35 text-main">{{ selectedList.length }}</text>
|
||||
<text>件</text>
|
||||
</view>
|
||||
<text class="ml-35">合计(不含运费):</text>
|
||||
<text class="ml-35">合计:</text>
|
||||
<text class="mx-15 font-bold text-40 text-main">¥{{ amount }}</text>
|
||||
<el-button type="primary" round :disabled="selectedList.length === 0">结算</el-button>
|
||||
<el-button type="primary" round :disabled="selectedList.length === 0" @click.native="addFromCart">结算</el-button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -106,18 +107,27 @@ export default {
|
||||
const {rows} = await vk.callFunction({
|
||||
url: "client/cart/kh/getList"
|
||||
})
|
||||
this.selectedAll = false
|
||||
this.list = rows.map(item => {
|
||||
item.checked = false
|
||||
return item
|
||||
})
|
||||
},
|
||||
doSelectAll() {
|
||||
this.selectedList = []
|
||||
this.list.forEach((item, index) => {
|
||||
this.list[index].checked = this.selectedAll
|
||||
if (this.selectedAll) this.selectedList.push(item._id)
|
||||
})
|
||||
},
|
||||
changeNum(e) {
|
||||
console.log(e)
|
||||
changeNum(index) {
|
||||
vk.callFunction({
|
||||
url: "client/cart/kh/changeNum",
|
||||
data: {
|
||||
id: this.list[index]._id,
|
||||
num: this.list[index].num
|
||||
}
|
||||
})
|
||||
},
|
||||
changeCheck(e, id) {
|
||||
const index = this.selectedList.indexOf(id)
|
||||
@@ -126,15 +136,38 @@ export default {
|
||||
this.selectedAll = this.selectedList.length === this.list.length
|
||||
},
|
||||
remove(index) {
|
||||
this.list.splice(index, 1)
|
||||
vk.callFunction({
|
||||
url: "client/cart/kh/delete",
|
||||
data: {
|
||||
ids: [this.list[index]._id]
|
||||
}
|
||||
})
|
||||
this.list.splice(index, 1)
|
||||
},
|
||||
async removeMulti() {
|
||||
if (this.selectedList.length === 0) return
|
||||
await vk.callFunction({
|
||||
url: "client/cart/kh/delete",
|
||||
data: {
|
||||
ids: this.selectedList
|
||||
}
|
||||
})
|
||||
this.selectedList = []
|
||||
await this.getList()
|
||||
},
|
||||
async addFromCart(){
|
||||
const {data} = await vk.callFunction({
|
||||
url: "client/order/kh/addFromList",
|
||||
data: {
|
||||
type: 0,
|
||||
ids: this.selectedList
|
||||
}
|
||||
})
|
||||
this.selectedAll = false
|
||||
vk.navigateTo({
|
||||
url: `/pages/index/shop/pay?id=${data}`
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
onShow() {
|
||||
this.getList()
|
||||
@@ -143,8 +176,7 @@ export default {
|
||||
amount() {
|
||||
let tmpAmount = 0
|
||||
this.list.forEach(item => {
|
||||
console.log(item.checked)
|
||||
if (item.checked) tmpAmount += parseFloat(item.goods.amount) * parseInt(item.num)
|
||||
if (item.checked) tmpAmount += parseFloat(item.sku.values) * parseInt(item.num)
|
||||
})
|
||||
return tmpAmount
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user