购物车详情

选择
DongZeLiang 2024-04-08 20:59:47 +08:00
parent 5f3c214af2
commit e2ba742b76
3 changed files with 77 additions and 38 deletions

View File

@ -33,6 +33,13 @@ export function addInfo(data) {
data: data data: data
}) })
} }
export function cartInfoIsSelected(data) {
return request({
url: '/shopCart/Info/selected',
method: 'post',
data: data
})
}
// 修改购物车 // 修改购物车
export function updateInfo(data) { export function updateInfo(data) {

View File

@ -82,7 +82,7 @@ export const constantRoutes = [
{ {
path: 'product-detail/:detailId(\\d+)', path: 'product-detail/:detailId(\\d+)',
component: () => import('@/views/product/info/detail/index'), component: () => import('@/views/product/info/detail/index'),
name: 'Demo', name: 'productDetail',
meta: {title: '商品详情', icon: 'dashboard', affix: true} meta: {title: '商品详情', icon: 'dashboard', affix: true}
} }
] ]
@ -95,7 +95,7 @@ export const constantRoutes = [
{ {
path: '/cart/detail', path: '/cart/detail',
component: () => import('@/views/shopCart/detail/index'), component: () => import('@/views/shopCart/detail/index'),
name: 'Demo', name: 'myCart',
meta: {title: '我的购物车', icon: 'dashboard', affix: true} meta: {title: '我的购物车', icon: 'dashboard', affix: true}
} }
] ]

View File

@ -1,6 +1,7 @@
<template> <template>
<div> <div>
<el-table ref="cartProjectTable" :data="cartProjectList" tooltip-effect="dark" style="width: 100%" <el-skeleton v-if="!loading" :rows="12" animated />
<el-table v-if="loading" ref="cartProjectTable" :data="cartProjectList" tooltip-effect="dark" style="width: 100%"
@selection-change="handleSelectionChange"> @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55"></el-table-column> <el-table-column type="selection" width="55"></el-table-column>
<el-table-column label="商品信息"> <el-table-column label="商品信息">
@ -18,7 +19,9 @@
</el-row> </el-row>
<el-divider style="margin: 10px 0;"/> <el-divider style="margin: 10px 0;"/>
<el-row> <el-row>
<el-col :span="24" v-for="skuRule in scope.row.skuRuleList">{{skuRule.ruleName}}{{skuRule.ruleValue}}</el-col> <el-col :span="24" v-for="skuRule in scope.row.skuRuleList">
{{ skuRule.ruleName }}{{ skuRule.ruleValue }}
</el-col>
</el-row> </el-row>
</el-col> </el-col>
</el-row> </el-row>
@ -46,7 +49,8 @@
<div v-if="failureCartProjectList.length > 0" style="height: 50px; align-items: center; "> <div v-if="failureCartProjectList.length > 0" style="height: 50px; align-items: center; ">
<span style="margin: 20px 0px; float: left; color: #787be8">已失效</span> <span style="margin: 20px 0px; float: left; color: #787be8">已失效</span>
</div> </div>
<el-table v-if="failureCartProjectList.length > 0" :show-header="false" ref="multipleTable" :data="failureCartProjectList" <el-table v-if="failureCartProjectList.length > 0" :show-header="false" ref="multipleTable"
:data="failureCartProjectList"
tooltip-effect="dark" tooltip-effect="dark"
style="width: 100%"> style="width: 100%">
<el-table-column width="55"> <el-table-column width="55">
@ -70,7 +74,7 @@
show-overflow-tooltip> show-overflow-tooltip>
</el-table-column> </el-table-column>
</el-table> </el-table>
<el-card style="margin-top: 20px;"> <el-card v-if="loading" style="margin-top: 20px;">
<div class="clearfix"> <div class="clearfix">
<el-row> <el-row>
<el-col :span="6"> <el-col :span="6">
@ -79,7 +83,8 @@
</el-col> </el-col>
<el-col :span="14"> <el-col :span="14">
<div> <div>
<span> <span style="color: red">{{statisticsCart.total}}</span> 件商品已选择 <span style="color:red;">{{statisticsCart.selectTotal}}</span> </span> <span> <span style="color: red">{{ statisticsCart.total }}</span> 件商品已选择 <span
style="color:red;">{{ statisticsCart.selectTotal }}</span> </span>
<el-divider direction="vertical"></el-divider> <el-divider direction="vertical"></el-divider>
<span> 商品合计 : ¥{{ statisticsCart.priceTotal }}</span> <span> 商品合计 : ¥{{ statisticsCart.priceTotal }}</span>
<el-divider direction="vertical"></el-divider> <el-divider direction="vertical"></el-divider>
@ -98,7 +103,8 @@
</template> </template>
<script> <script>
import {getDetailInfo} from "@/api/shopCart/Info"; import {cartInfoIsSelected, getDetailInfo} from "@/api/shopCart/Info";
import {getTime} from "@/utils";
export default { export default {
name: "shopCartDetail", name: "shopCartDetail",
@ -121,18 +127,23 @@ export default {
actualTotal: 0.00 actualTotal: 0.00
}, },
// //
isAllCheck: false isAllCheck: false,
loading: false
} }
}, },
created() { created() {
this.init()
},
methods: {
init() {
getDetailInfo().then(response => { getDetailInfo().then(response => {
console.log(response) console.log(response)
this.statisticsCart = response.data.statisticsCart; this.statisticsCart = response.data.statisticsCart;
this.cartProjectList = response.data.cartSkuList; this.cartProjectList = response.data.cartSkuList;
this.loading = true;
setTimeout(this.initCartSelected, 200); setTimeout(this.initCartSelected, 200);
}) })
}, },
methods: {
initCartSelected() { initCartSelected() {
this.cartProjectList.forEach(cartProject => { this.cartProjectList.forEach(cartProject => {
if ("Y" === cartProject.isSelected) { if ("Y" === cartProject.isSelected) {
@ -147,16 +158,37 @@ export default {
this.$refs.cartProjectTable.clearSelection(); this.$refs.cartProjectTable.clearSelection();
} }
}, },
//
// selectedRow
handleSelectionChange(selectedRow) { handleSelectionChange(selectedRow) {
// selectedRow let editCartProjectList = [];
// cartProjectSelected this.cartProjectSelected
console.log(selectedRow) .filter(cartProject => selectedRow.indexOf(cartProject) === -1)
console.log(this.cartProjectSelected) .forEach(cartProject => editCartProjectList.push({
// selectedRow cartProjectSelected "projectId": cartProject.projectId,
// cartProjectSelected selectedRow "projectSku": cartProject.projectSku,
"isSelected": "N"
}))
selectedRow
.filter(cartProject => this.cartProjectSelected.indexOf(cartProject) === -1)
.forEach(cartProject => editCartProjectList.push({
"projectId": cartProject.projectId,
"projectSku": cartProject.projectSku,
"isSelected": "Y"
}))
console.log(editCartProjectList)
let cartProjectMap = {};
this.cartProjectList.map(cartProject => cartProjectMap[`${cartProject.projectId} + ${cartProject.projectSku}`] = cartProject.isSelected)
console.log(cartProjectMap)
let editCartProjectFilterList
= editCartProjectList.filter(editCartProject => editCartProject.isSelected !== cartProjectMap[`${editCartProject.projectId} + ${editCartProject.projectSku}`])
console.log(editCartProjectFilterList)
if (editCartProjectFilterList.length > 0){
cartInfoIsSelected(editCartProjectList).then(response => {
this.loading = false;
this.cartProjectList = [];
this.cartProjectSelected = []
this.init();
})
}
this.isAllCheck = selectedRow.length === this.cartProjectList.length this.isAllCheck = selectedRow.length === this.cartProjectList.length
this.cartProjectSelected = selectedRow; this.cartProjectSelected = selectedRow;
} }