删除商品
parent
e2ba742b76
commit
3e86288494
|
@ -40,6 +40,13 @@ export function cartInfoIsSelected(data) {
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
export function cartInfoEditNum(data) {
|
||||||
|
return request({
|
||||||
|
url: '/shopCart/Info/num',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 修改购物车
|
// 修改购物车
|
||||||
export function updateInfo(data) {
|
export function updateInfo(data) {
|
||||||
|
@ -57,3 +64,12 @@ export function delInfo(id) {
|
||||||
method: 'delete'
|
method: 'delete'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 删除购物车
|
||||||
|
export function removeCartInfo(data) {
|
||||||
|
return request({
|
||||||
|
url: '/shopCart/Info/remove',
|
||||||
|
method: 'delete',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
<el-table-column label="数量" width="120">
|
<el-table-column label="数量" width="120">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-input-number v-model="scope.row.num" controls-position="right" style="width: 110px"
|
<el-input-number v-model="scope.row.num" controls-position="right" style="width: 110px"
|
||||||
|
@change="editCartProjectNum(scope.row)"
|
||||||
:min="1"
|
:min="1"
|
||||||
:max="scope.row.stock"
|
:max="scope.row.stock"
|
||||||
size="mini"></el-input-number>
|
size="mini"></el-input-number>
|
||||||
|
@ -43,7 +44,9 @@
|
||||||
<template slot-scope="scope">{{ scope.row.subtotal }}</template>
|
<template slot-scope="scope">{{ scope.row.subtotal }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" width="80">
|
<el-table-column label="操作" width="80">
|
||||||
<template slot-scope="scope">{{ scope.row.date }}</template>
|
<template slot-scope="scope">
|
||||||
|
<el-button type="text" @click="removeCartProject(scope.row)">删除</el-button>
|
||||||
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
<div v-if="failureCartProjectList.length > 0" style="height: 50px; align-items: center; ">
|
<div v-if="failureCartProjectList.length > 0" style="height: 50px; align-items: center; ">
|
||||||
|
@ -95,16 +98,14 @@
|
||||||
<el-button style="float: right;" type="success">下单</el-button>
|
<el-button style="float: right;" type="success">下单</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {cartInfoIsSelected, getDetailInfo} from "@/api/shopCart/Info";
|
import {cartInfoEditNum, cartInfoIsSelected, getDetailInfo, removeCartInfo} from "@/api/shopCart/Info";
|
||||||
import {getTime} from "@/utils";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "shopCartDetail",
|
name: "shopCartDetail",
|
||||||
|
@ -135,9 +136,34 @@ export default {
|
||||||
this.init()
|
this.init()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
removeCartProject(row){
|
||||||
|
let removeCartProjectParam = {
|
||||||
|
"projectId": row.projectId,
|
||||||
|
"projectSku": row.projectSku,
|
||||||
|
"cartInfoId": row.cartInfoId
|
||||||
|
};
|
||||||
|
let removeCartProjectParams = [removeCartProjectParam];
|
||||||
|
removeCartInfo(removeCartProjectParams).then(response => {
|
||||||
|
this.init();
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
editCartProjectNum(row){
|
||||||
|
let editCartProjectNumParams = {
|
||||||
|
"projectId": row.projectId,
|
||||||
|
"projectSku": row.projectSku,
|
||||||
|
"num": row.num
|
||||||
|
};
|
||||||
|
cartInfoEditNum(editCartProjectNumParams).then(response => {
|
||||||
|
this.init();
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
|
this.loading = false;
|
||||||
|
this.cartProjectList = [];
|
||||||
|
this.cartProjectSelected = []
|
||||||
getDetailInfo().then(response => {
|
getDetailInfo().then(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;
|
this.loading = true;
|
||||||
|
@ -174,18 +200,12 @@ export default {
|
||||||
"projectSku": cartProject.projectSku,
|
"projectSku": cartProject.projectSku,
|
||||||
"isSelected": "Y"
|
"isSelected": "Y"
|
||||||
}))
|
}))
|
||||||
console.log(editCartProjectList)
|
|
||||||
let cartProjectMap = {};
|
let cartProjectMap = {};
|
||||||
this.cartProjectList.map(cartProject => cartProjectMap[`${cartProject.projectId} + ${cartProject.projectSku}`] = cartProject.isSelected)
|
this.cartProjectList.map(cartProject => cartProjectMap[`${cartProject.projectId} + ${cartProject.projectSku}`] = cartProject.isSelected)
|
||||||
console.log(cartProjectMap)
|
|
||||||
let editCartProjectFilterList
|
let editCartProjectFilterList
|
||||||
= editCartProjectList.filter(editCartProject => editCartProject.isSelected !== cartProjectMap[`${editCartProject.projectId} + ${editCartProject.projectSku}`])
|
= editCartProjectList.filter(editCartProject => editCartProject.isSelected !== cartProjectMap[`${editCartProject.projectId} + ${editCartProject.projectSku}`])
|
||||||
console.log(editCartProjectFilterList)
|
|
||||||
if (editCartProjectFilterList.length > 0){
|
if (editCartProjectFilterList.length > 0){
|
||||||
cartInfoIsSelected(editCartProjectList).then(response => {
|
cartInfoIsSelected(editCartProjectList).then(response => {
|
||||||
this.loading = false;
|
|
||||||
this.cartProjectList = [];
|
|
||||||
this.cartProjectSelected = []
|
|
||||||
this.init();
|
this.init();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue