From c169274cc77b18bf35a9f052e620575ea6b364a9 Mon Sep 17 00:00:00 2001 From: yaoxin <1752800946@qq.com> Date: Mon, 1 Apr 2024 16:23:28 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=AD=E7=89=A9=E8=BD=A6=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/shopCart/info/detail/index.vue | 175 +++++++++++++++++- 1 file changed, 172 insertions(+), 3 deletions(-) diff --git a/muyu-ruoyi-ui/src/views/shopCart/info/detail/index.vue b/muyu-ruoyi-ui/src/views/shopCart/info/detail/index.vue index c3748b8..b998fca 100644 --- a/muyu-ruoyi-ui/src/views/shopCart/info/detail/index.vue +++ b/muyu-ruoyi-ui/src/views/shopCart/info/detail/index.vue @@ -5,7 +5,9 @@ style="width: 100%;"> - + @@ -55,7 +57,9 @@ {{ cartInfo.row.productSkuInfo.name }} - {{ cartInfo.row.productSkuInfo.sku }} + {{ cartInfo.row.productSkuInfo.sku }} + 已售罄 + 已下架 @@ -84,6 +88,26 @@ + + + + + 全选 + 删除选中商品 + 移入收藏夹 + + 下单结算 + + + 共 {{ computeInfo.packagesSum }} 件商品,已选择 {{ computeInfo.packagesNumber }} 件 + + 商品合计 : ¥{{ computeInfo.priceTotal }} 活动优惠 : -¥{{ 0.00 }} + + 应付总额:¥{{ computeInfo.copeWith }} + + + + @@ -92,12 +116,16 @@ export default { name: "index", data() { return { + checkAll: false, borderBoolean: false, showHeader: false, + selectedList: [], cartInfoAttr: [ { + id: 1, num: 2, subtotal: 478, + isSelected: 't', productSkuInfo: { sku: '黑色-M', price: 239.0, @@ -107,8 +135,10 @@ export default { } }, { + id: 2, num: 1, subtotal: 129, + isSelected: 't', productSkuInfo: { sku: '红色-S', price: 129.0, @@ -118,8 +148,10 @@ export default { } }, { + id: 3, num: 3, subtotal: 477, + isSelected: 'f', productSkuInfo: { sku: '白色-XL', price: 159, @@ -131,6 +163,7 @@ export default { ], loseCartInfoAttr: [ { + id: 4, num: 2, subtotal: 478, productSkuInfo: { @@ -140,14 +173,150 @@ export default { stock: 10, image: 'http://127.0.0.1:9300/statics/2024/03/29/屏幕截图 2023-11-02 194246_20240329165050A012.png' } + }, + { + id: 5, + num: 1, + subtotal: 439, + productSkuInfo: { + sku: '红色-XL', + price: 439.0, + name: '嘻嘻嘻', + stock: 0, + image: 'http://127.0.0.1:9300/statics/2024/03/29/屏幕截图 2023-11-02 194246_20240329165050A012.png' + } } - ] + ], + computeInfo: { + packagesNumber: 0, + packagesSum: 0, + priceTotal: 0, + copeWith: 0 + } } }, methods: { + //按钮变色 + // changeTextColor() { + // this.buttonTextColor = 'blue'; // 设置鼠标悬停时的文字颜色 + // console.log(this.buttonTextColor) + // }, + // resetTextColor() { + // this.buttonTextColor = 'black'; // 恢复默认的文字颜色 + // }, + + //全选 + checkedAll(selectAll) { + if (selectAll) { + this.$refs.multipleTable.clearSelection(); + this.selectedList = [] + this.toggleSelection(this.cartInfoAttr) + this.selectedList = this.cartInfoAttr + }else{ + this.selectedList = [] + this.$refs.multipleTable.clearSelection(); + } + }, + + //重置购物车已选择商品计算信息 + computeInfoReset() { + this.computeInfo.packagesNumber = 0 + this.computeInfo.priceTotal = 0 + this.computeInfo.copeWith = 0 + this.selectedList = [] + }, + + //购物车商品选中 + toggleSelection(rows) { + if (rows) { + rows.forEach(row => { + this.$refs.multipleTable.toggleRowSelection(row); + }); + } else { + this.$refs.multipleTable.clearSelection(); + } + }, + + //购物车商品选择改变方法 + handleSelectionChange(val) { + this.computeInfoReset() + this.selectedList = val + this.cartInfoAttr.forEach(cartInfo => { + cartInfo.isSelected = 'f' + }) + if (val.length == this.cartInfoAttr.length) { + this.checkAll = true + }else{ + this.checkAll = false + } + val.forEach(cartInfo => { + this.cartInfoAttr[this.cartInfoAttr.indexOf(cartInfo)].isSelected = 't' + this.computeInfo.copeWith += parseFloat(cartInfo.subtotal) + this.computeInfo.priceTotal += parseFloat(cartInfo.subtotal) + this.computeInfo.packagesNumber += parseInt(cartInfo.num) + }) + }, + + //计算购物车商品总件数 + computePackagesSum() { + this.computeInfo.packagesSum = 0 + this.cartInfoAttr.forEach(cartInfo => { + this.computeInfo.packagesSum += cartInfo.num + }) + this.loseCartInfoAttr.forEach(loseCartInfo => { + this.computeInfo.packagesSum += loseCartInfo.num + }) + }, + + //改变购物车商品数量 + changeNum(row) { + if (row.num === row.productSkuInfo.stock) { + this.$message({ + message: '商品: '+row.productSkuInfo.name+' 库存不足', + type: 'warning' + }); + } + this.computeInfoReset() + this.computeInfo.packagesSum = 0 + this.cartInfoAttr.forEach(cartInfo => { + if (cartInfo.id == row.id){ + cartInfo.subtotal = parseFloat(cartInfo.productSkuInfo.price) * parseInt(row.num) + } + if (cartInfo.isSelected == 't'){ + this.computeInfo.copeWith += parseFloat(cartInfo.subtotal) + this.computeInfo.priceTotal += parseFloat(cartInfo.subtotal) + this.computeInfo.packagesNumber += parseInt(cartInfo.num) + } + }) + this.computePackagesSum() + }, + + //获取购物车详情信息 + cartInfoList() { + this.cartInfoAttr.forEach(cartInfo => { + this.computeInfo.packagesSum += cartInfo.num + }) + this.loseCartInfoAttr.forEach(loseCartInfo => { + this.computeInfo.packagesSum += loseCartInfo.num + }) + this.cartInfoAttr.forEach(cartInfo => { + if (cartInfo.isSelected == 't'){ + this.selectedList.push(cartInfo) + } + }) + + } + }, + mounted() { + this.toggleSelection(this.selectedList) + }, + created() { + this.cartInfoList() } } + +