购物车
parent
83bdad0800
commit
144c245f61
|
@ -0,0 +1,44 @@
|
||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 查询购物车列表
|
||||||
|
export function listInfo(query) {
|
||||||
|
return request({
|
||||||
|
url: '/shopCart/Info/list',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询购物车详细
|
||||||
|
export function getInfo(id) {
|
||||||
|
return request({
|
||||||
|
url: '/shopCart/Info/' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增购物车
|
||||||
|
export function addInfo(data) {
|
||||||
|
return request({
|
||||||
|
url: '/shopCart/Info',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改购物车
|
||||||
|
export function updateInfo(data) {
|
||||||
|
return request({
|
||||||
|
url: '/shopCart/Info/'+data.id,
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除购物车
|
||||||
|
export function delInfo(id) {
|
||||||
|
return request({
|
||||||
|
url: '/shopCart/Info/' + id,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
|
@ -0,0 +1,108 @@
|
||||||
|
<template>
|
||||||
|
<el-container>
|
||||||
|
<el-header>
|
||||||
|
<div>
|
||||||
|
<div class="box1" style="float: right;margin-right: 13%">
|
||||||
|
<el-button type="text" style="color: white">请先登录</el-button>
|
||||||
|
<el-divider direction="vertical"></el-divider>
|
||||||
|
<el-button type="text" style="color: white">免费注册</el-button>
|
||||||
|
<el-divider direction="vertical"></el-divider>
|
||||||
|
<el-button type="text" style="color: white">我的订单</el-button>
|
||||||
|
<el-divider direction="vertical"></el-divider>
|
||||||
|
<el-button type="text" style="color: white">会员中心</el-button>
|
||||||
|
<el-divider direction="vertical"></el-divider>
|
||||||
|
<el-button type="text" style="color: white">帮助中心</el-button>
|
||||||
|
<el-divider direction="vertical"></el-divider>
|
||||||
|
<el-button type="text" style="color: white">在线客服</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</el-header>
|
||||||
|
<el-main>
|
||||||
|
<div class="custom-tabs">
|
||||||
|
<el-tabs v-model="activeName">
|
||||||
|
<el-tab-pane label="用户管理" name="first">用户管理</el-tab-pane>
|
||||||
|
<el-tab-pane label="配置管理" name="second">配置管理</el-tab-pane>
|
||||||
|
<el-tab-pane label="角色管理" name="third">角色管理</el-tab-pane>
|
||||||
|
<el-tab-pane label="定时任务补偿" name="fourth">定时任务补偿</el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
|
</div>
|
||||||
|
</el-main>
|
||||||
|
<el-main>
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="18" :offset="3">
|
||||||
|
<router-view/>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-main>
|
||||||
|
</el-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: "layoutShopCart",
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
activeName: ''
|
||||||
|
};
|
||||||
|
},
|
||||||
|
//监控data中的数据变化",
|
||||||
|
watch: {},
|
||||||
|
methods: {
|
||||||
|
handleClick(tab, event) {
|
||||||
|
console.log(tab, event);
|
||||||
|
},
|
||||||
|
attachMouseoverEvent() {
|
||||||
|
const tabTitles = document.querySelectorAll('.el-tabs__item');
|
||||||
|
tabTitles.forEach(tab => {
|
||||||
|
tab.addEventListener('mouseover', () => {
|
||||||
|
const tabName = tab.getAttribute('name');
|
||||||
|
this.activeName = tabName;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.attachMouseoverEvent()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
.custom-tabs .el-tabs__item.is-active {
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-header, .el-footer {
|
||||||
|
background-color: black;
|
||||||
|
color: white;
|
||||||
|
text-align: center;
|
||||||
|
line-height: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-main {
|
||||||
|
background-color: #E9EEF3;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
body > .el-container {
|
||||||
|
margin-bottom: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-container:nth-child(5) .el-aside,
|
||||||
|
.el-container:nth-child(6) .el-aside {
|
||||||
|
line-height: 260px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.el-container:nth-child(7) .el-aside {
|
||||||
|
line-height: 320px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.box1 {
|
||||||
|
transform: translate(0%, 10%); /* 将内容向上、向左移动自身宽高的一半,实现垂直水平居中 */
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
|
@ -82,11 +82,24 @@ export const constantRoutes = [
|
||||||
{
|
{
|
||||||
path: 'product-detail/:id',
|
path: 'product-detail/:id',
|
||||||
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}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
component: LayoutShop,
|
||||||
|
redirect: 'shopCart-detail',
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: 'shopCart-detail/',
|
||||||
|
component: () => import('@/views/shopCart/Info/detail/index'),
|
||||||
|
name: 'shopCartDetail',
|
||||||
|
meta: {title: '购物车详情', icon: 'dashboard', affix: true}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/user',
|
path: '/user',
|
||||||
component: Layout,
|
component: Layout,
|
||||||
|
@ -100,7 +113,7 @@ export const constantRoutes = [
|
||||||
meta: {title: '个人中心', icon: 'user'}
|
meta: {title: '个人中心', icon: 'user'}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
// 动态路由,基于用户权限动态去加载
|
// 动态路由,基于用户权限动态去加载
|
||||||
|
|
|
@ -3,14 +3,15 @@
|
||||||
<el-breadcrumb separator-class="el-icon-arrow-right">
|
<el-breadcrumb separator-class="el-icon-arrow-right">
|
||||||
<el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
|
<el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
|
||||||
<el-breadcrumb-item v-for="categoryInfo in projectDetail.categoryInfoList">{{categoryInfo.name}}</el-breadcrumb-item>
|
<el-breadcrumb-item v-for="categoryInfo in projectDetail.categoryInfoList">{{categoryInfo.name}}</el-breadcrumb-item>
|
||||||
|
<el-button @click="comeShopCart">进入购物车</el-button>
|
||||||
<el-breadcrumb-item>{{projectDetail.projectInfo.name}}</el-breadcrumb-item>
|
<el-breadcrumb-item>{{projectDetail.projectInfo.name}}</el-breadcrumb-item>
|
||||||
</el-breadcrumb>
|
</el-breadcrumb>
|
||||||
<el-row :gutter="20" style="margin-top: 20px">
|
<el-row :gutter="20" style="margin-top: 20px">
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-carousel trigger="click" height="400px">
|
<el-carousel trigger="click" height="400px">
|
||||||
<el-carousel-item v-for="item in 4" :key="item">
|
<el-carousel-item v-for="item in carouselImages" :key="item">
|
||||||
<h3 class="small">{{ item }}</h3>
|
<!-- <h3 class="small">{{ item }}</h3>-->
|
||||||
|
<el-image :src="item" style="height: 100% ;width: 100%"/>
|
||||||
</el-carousel-item>
|
</el-carousel-item>
|
||||||
</el-carousel>
|
</el-carousel>
|
||||||
<div style="margin-top: 20px;">
|
<div style="margin-top: 20px;">
|
||||||
|
@ -20,7 +21,7 @@
|
||||||
<el-statistic
|
<el-statistic
|
||||||
group-separator=","
|
group-separator=","
|
||||||
:precision="2"
|
:precision="2"
|
||||||
:value="value2"
|
:value="123"
|
||||||
:title="title"
|
:title="title"
|
||||||
></el-statistic>
|
></el-statistic>
|
||||||
</div>
|
</div>
|
||||||
|
@ -29,7 +30,7 @@
|
||||||
<div>
|
<div>
|
||||||
<el-statistic title="商品评价">
|
<el-statistic title="商品评价">
|
||||||
<template slot="formatter">
|
<template slot="formatter">
|
||||||
456/2
|
456
|
||||||
</template>
|
</template>
|
||||||
</el-statistic>
|
</el-statistic>
|
||||||
</div>
|
</div>
|
||||||
|
@ -38,32 +39,18 @@
|
||||||
<div>
|
<div>
|
||||||
<el-statistic
|
<el-statistic
|
||||||
group-separator=","
|
group-separator=","
|
||||||
:precision="2"
|
:precision="0"
|
||||||
decimal-separator="."
|
decimal-separator="."
|
||||||
:value="value1"
|
:value="123"
|
||||||
title="收藏人气"
|
title="收藏人气">
|
||||||
>
|
|
||||||
<template slot="prefix">
|
|
||||||
<i class="el-icon-s-flag" style="color: red"></i>
|
|
||||||
</template>
|
|
||||||
<template slot="suffix">
|
|
||||||
<i class="el-icon-s-flag" style="color: blue"></i>
|
|
||||||
</template>
|
|
||||||
</el-statistic>
|
</el-statistic>
|
||||||
</div>
|
</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="6">
|
<el-col :span="6">
|
||||||
<div>
|
<div>
|
||||||
<el-statistic :value="like ? 521 : 520" title="品牌信息">
|
<el-statistic title="品牌信息">
|
||||||
<template slot="suffix">
|
<template slot="formatter">
|
||||||
<span @click="like = !like" class="like">
|
{{projectDetail.brandInfo.nam}}
|
||||||
<i
|
|
||||||
class="el-icon-star-on"
|
|
||||||
style="color:red"
|
|
||||||
v-show="!!like"
|
|
||||||
></i>
|
|
||||||
<i class="el-icon-star-off" v-show="!like"></i>
|
|
||||||
</span>
|
|
||||||
</template>
|
</template>
|
||||||
</el-statistic>
|
</el-statistic>
|
||||||
</div>
|
</div>
|
||||||
|
@ -72,29 +59,22 @@
|
||||||
</div>
|
</div>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<h1>商品名称</h1>
|
<h1>{{ projectDetail.projectInfo.name }}</h1>
|
||||||
<h3>商品规格(内存-储存-颜色)</h3>
|
<h3>商品规格({{ selectedValues }})</h3>
|
||||||
<h2 style="color: red">¥125</h2>
|
<h2 style="color: red">¥{{this.form.price}}</h2>
|
||||||
<el-form ref="form" :model="form" label-width="80px" style="margin-top: 110px">
|
<el-form ref="form" :model="form" label-width="80px" style="margin-top: 110px">
|
||||||
<el-form-item label="规格1">
|
|
||||||
<el-radio-group v-model="form.rule1">
|
<el-form-item v-for="(ruleAttr, index) in projectDetail.ruleAttrModelList" :key="index" :label="ruleAttr.name">
|
||||||
<el-radio :label="3" border>备选项</el-radio>
|
<el-radio-group v-model="form['rule'+index]" @change="updSpecification">
|
||||||
<el-radio :label="6" border>备选项</el-radio>
|
<el-radio v-for="value in ruleAttr.valueList" :label="value" border>{{value}}</el-radio>
|
||||||
<el-radio :label="9" border>备选项</el-radio>
|
</el-radio-group>
|
||||||
</el-radio-group>
|
</el-form-item>
|
||||||
</el-form-item>
|
<el-form-item label="数量">
|
||||||
<el-form-item label="规格2">
|
|
||||||
<el-radio-group v-model="form.rule2">
|
|
||||||
<el-radio :label="3" border>备选项</el-radio>
|
|
||||||
<el-radio :label="6" border>备选项</el-radio>
|
|
||||||
<el-radio :label="9" border>备选项</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="规格2">
|
|
||||||
<el-input-number v-model="form.num" :min="1" :max="10" label="描述文字"></el-input-number>
|
<el-input-number v-model="form.num" :min="1" :max="10" label="描述文字"></el-input-number>
|
||||||
|
<h1 style="color: red">总价格: {{this.form.price*this.form.num}}</h1>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" @click="onSubmit">加入购物车</el-button>
|
<el-button type="primary" @click="addToCart(form)">加入购物车</el-button>
|
||||||
<el-button>立即购买</el-button>
|
<el-button>立即购买</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
@ -105,22 +85,25 @@
|
||||||
<div slot="header" class="clearfix">
|
<div slot="header" class="clearfix">
|
||||||
<span>商品详情</span>
|
<span>商品详情</span>
|
||||||
</div>
|
</div>
|
||||||
<el-descriptions title="分组1" :column="1">
|
<el-descriptions v-for="attributeGroup in projectDetail.attributeGroupList" :title="attributeGroup.groupName" :column="1">
|
||||||
<el-descriptions-item label="用户名">kooriookami</el-descriptions-item>
|
<el-descriptions-item v-for="attribute in attributeGroup.attributeList"
|
||||||
<el-descriptions-item label="手机号">18100000000</el-descriptions-item>
|
:label="attribute.name">{{attributeMap[attribute.id]}}</el-descriptions-item>
|
||||||
<el-descriptions-item label="居住地">苏州市</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="备注">
|
|
||||||
<el-tag size="small">学校</el-tag>
|
|
||||||
</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="联系地址">江苏省苏州市吴中区吴中大道 1188 号</el-descriptions-item>
|
|
||||||
</el-descriptions>
|
</el-descriptions>
|
||||||
<el-descriptions title="其他属性" :column="1">
|
<el-descriptions v-if="projectDetail.attributeInfoList.length !== 0" title="其他属性" :column="1">
|
||||||
<el-descriptions-item label="用户名">kooriookami</el-descriptions-item>
|
<el-descriptions-item v-for="attributeInfo in projectDetail.attributeInfoList"
|
||||||
<el-descriptions-item label="手机号">18100000000</el-descriptions-item>
|
:label="attributeInfo.name">{{attributeMap[attributeInfo.id]}}
|
||||||
<el-descriptions-item label="居住地">苏州市</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
</el-descriptions>
|
</el-descriptions>
|
||||||
|
|
||||||
<editor v-model="editorValue" :read-only="true" >
|
<editor v-model="projectDetail.projectInfo.introduction" :read-only="true" >
|
||||||
|
<!-- <el-descriptions title="商品参数" v-for="(AttributeGroup,index) in projectDetail.attributeGroupList">-->
|
||||||
|
<!-- <el-descriptions-item :label="AttributeGroup.groupName">-->
|
||||||
|
<!-- <div v-for="(group,index) in AttributeGroup.attributeList">{{group.name+","}}</div>-->
|
||||||
|
<!-- </el-descriptions-item>-->
|
||||||
|
<!-- </el-descriptions>-->
|
||||||
|
<!-- <el-descriptions v-for="(Attribute,index) in projectDetail.productAttributeInfoList" >-->
|
||||||
|
<!-- <el-descriptions-item :label="Attribute.name">{{Attribute.value}}</el-descriptions-item>-->
|
||||||
|
<!-- </el-descriptions>-->
|
||||||
|
|
||||||
</editor>
|
</editor>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
@ -130,11 +113,14 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {getDetailInfo} from "@/api/product/info";
|
import {getDetailInfo} from "@/api/product/info";
|
||||||
|
import { addInfo } from '@/api/shopCart/Info'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "productDetail",
|
name: "productDetail",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
id:0,
|
||||||
|
selectedValues:'',
|
||||||
breadcrumbList: [
|
breadcrumbList: [
|
||||||
"服装",
|
"服装",
|
||||||
"外衣",
|
"外衣",
|
||||||
|
@ -145,19 +131,121 @@ export default {
|
||||||
value2: 1314,
|
value2: 1314,
|
||||||
title: "销量人气",
|
title: "销量人气",
|
||||||
form: {
|
form: {
|
||||||
num: 1
|
projectSku:"",
|
||||||
|
num: 1,
|
||||||
|
projectId:null,
|
||||||
},
|
},
|
||||||
editorValue: "awejfoiajovhahrfhaowiejfoawijfeoiawjefoawjjogihao",
|
editorValue: "awejfoiajovhahrfhaowiejfoawijfeoiawjefoawjjogihao",
|
||||||
projectDetail: {}
|
projectDetail: {
|
||||||
|
projectInfo:
|
||||||
|
{
|
||||||
|
name:"",
|
||||||
|
},
|
||||||
|
brandInfo:{
|
||||||
|
nam:"",
|
||||||
|
},
|
||||||
|
checkSkuInfo: {
|
||||||
|
price: 0.00
|
||||||
|
},
|
||||||
|
projectSkuInfoList:[
|
||||||
|
{
|
||||||
|
sku:"",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
attributeInfoList:[]
|
||||||
|
},
|
||||||
|
carouselImages:[],
|
||||||
|
attributeMap:{},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// computed:{
|
||||||
|
// // 计算属性
|
||||||
|
// calculatedPrice(){
|
||||||
|
// const intNum=parseInt(this.form.num,10);
|
||||||
|
// console.info(intNum)
|
||||||
|
// if (isNaN(intNum)){
|
||||||
|
// return 0.0;
|
||||||
|
// }
|
||||||
|
// console.info(this.form.price * intNum)
|
||||||
|
// return this.form.price * intNum;
|
||||||
|
// }
|
||||||
|
// },
|
||||||
created() {
|
created() {
|
||||||
this.initProjectDetailInfo();
|
// const detailId = this.$route.params && this.$route.params.detailId;
|
||||||
|
this.id = this.$route.params.id
|
||||||
|
this.initProjectDetailInfo(this.id);
|
||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
initProjectDetailInfo(){
|
|
||||||
getDetailInfo(2).then(response => {
|
// 进入购物车
|
||||||
|
comeShopCart(){
|
||||||
|
this.$router.push({
|
||||||
|
path: '/shopCart-detail',
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 规格改变
|
||||||
|
updSpecification(){
|
||||||
|
let selectedValues = this.projectDetail.ruleAttrModelList.map((ruleAttr, index) => {
|
||||||
|
return this.form['rule' + index]; // 获取每个索引对应的值
|
||||||
|
}).filter(value => value !== '').join('-'); // 过滤空值,然后拼接成字符串
|
||||||
|
|
||||||
|
this.selectedValues = selectedValues; // 将拼接值赋给 selectedValues
|
||||||
|
console.log('当前选中的拼接值:', this.selectedValues);
|
||||||
|
this.projectDetail.projectSkuInfoList.forEach(SkuInfo => {
|
||||||
|
if (SkuInfo.sku === this.selectedValues) {
|
||||||
|
console.log(SkuInfo)
|
||||||
|
this.form.price = SkuInfo.price;
|
||||||
|
console.log(this.form.price)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 进入购物车
|
||||||
|
*/
|
||||||
|
addToCart(form){
|
||||||
|
this.form.projectSku="";
|
||||||
|
console.log(form)
|
||||||
|
Object.keys(form).forEach((key,index)=>{
|
||||||
|
if (key.startsWith('rule')){
|
||||||
|
this.form.projectSku+='-'+form[key]; //使用 trim() 方法去除字符串末尾可能存在的空格
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.form.projectSku=this.form.projectSku.substring(1)
|
||||||
|
|
||||||
|
console.log(this.form)
|
||||||
|
addInfo(this.form).then(response => {
|
||||||
|
this.$message({
|
||||||
|
message: '添加购物车成功',
|
||||||
|
type: 'success'
|
||||||
|
});
|
||||||
|
})
|
||||||
|
},
|
||||||
|
initProjectDetailInfo(id){
|
||||||
|
getDetailInfo(id).then(response => {
|
||||||
this.projectDetail = response.data;
|
this.projectDetail = response.data;
|
||||||
|
// 给购物车id赋值
|
||||||
|
this.form.projectId=response.data.projectInfo.id
|
||||||
|
// 单选框初始化
|
||||||
|
this.selectedValues=this.projectDetail.projectSkuInfoList[0].sku
|
||||||
|
this.form.price=this.projectDetail.projectSkuInfoList[0].price;
|
||||||
|
let data =this.projectDetail.projectSkuInfoList[0].sku.split('-');
|
||||||
|
|
||||||
|
this.projectDetail.productAttributeInfoList.map(productAttributeInfo => {
|
||||||
|
let key = productAttributeInfo.attributeId;
|
||||||
|
this.attributeMap[key] = productAttributeInfo["value"];
|
||||||
|
})
|
||||||
|
|
||||||
|
let i=0;
|
||||||
|
data.forEach(x=>{
|
||||||
|
this.form['rule'+(i++)]=x;
|
||||||
|
})
|
||||||
|
|
||||||
|
// 轮播图
|
||||||
|
this.carouselImages=this.projectDetail.projectInfo.carouselImages.split(",");
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,153 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<span style="color: #8492a6">我的购物车</span>
|
||||||
|
<br> <br> <br>
|
||||||
|
<el-card class="box-card">
|
||||||
|
<template>
|
||||||
|
<el-table
|
||||||
|
:data="cartInfoAttr"
|
||||||
|
style="width: 100%;">
|
||||||
|
<el-table-column
|
||||||
|
type="selection"
|
||||||
|
width="55">
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="商品信息" align="center">
|
||||||
|
<template v-slot="cartInfo">
|
||||||
|
<div>
|
||||||
|
<img style="float: left" :src="cartInfo.row.productSkuInfo.image" alt="暂无图片" width="80px" height="80px">
|
||||||
|
<span style="font-size: 16px"><b>{{ cartInfo.row.productSkuInfo.name }}</b></span> <br>
|
||||||
|
{{ cartInfo.row.productSkuInfo.sku }}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="单价" align="center">
|
||||||
|
<template v-slot="cartInfo">
|
||||||
|
<span style="font-size: 16px">¥{{ cartInfo.row.productSkuInfo.price }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="数量" align="center">
|
||||||
|
<template v-slot="cartInfo">
|
||||||
|
<el-input-number v-model="cartInfo.row.num" :min="1" :max="cartInfo.row.productSkuInfo.stock" label="描述文字"></el-input-number>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="小计" align="center">
|
||||||
|
<template v-slot="cartInfo">
|
||||||
|
<span style="color: red;font-size: 16px">¥{{ cartInfo.row.subtotal }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" align="center">
|
||||||
|
<template v-slot="cartInfo">
|
||||||
|
<el-button type="text" style="color: black">移入收藏夹</el-button>
|
||||||
|
<br>
|
||||||
|
<el-button type="text" style="color: black">删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<br>
|
||||||
|
<span style="color: #8492a6">已失效商品</span>
|
||||||
|
<br><br>
|
||||||
|
<el-table style="border-top: black" :data="loseCartInfoAttr" :border="borderBoolean" :show-header="showHeader" >
|
||||||
|
<el-table-column width="55">
|
||||||
|
<el-checkbox disabled></el-checkbox>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column align="center">
|
||||||
|
<template v-slot="cartInfo">
|
||||||
|
<div>
|
||||||
|
<img style="float: left" :src="cartInfo.row.productSkuInfo.image" alt="暂无图片" width="80px" height="80px">
|
||||||
|
<span style="font-size: 16px"><b>{{ cartInfo.row.productSkuInfo.name }}</b></span> <br>
|
||||||
|
{{ cartInfo.row.productSkuInfo.sku }}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column align="center">
|
||||||
|
<template v-slot="cartInfo">
|
||||||
|
<span style="color: #8492a6;font-size: 16px">¥{{ cartInfo.row.productSkuInfo.price }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column align="center">
|
||||||
|
<template v-slot="cartInfo">
|
||||||
|
<el-input-number disabled v-model="cartInfo.row.num" :min="1" :max="cartInfo.row.productSkuInfo.stock" label="描述文字"></el-input-number>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column align="center">
|
||||||
|
<template v-slot="cartInfo">
|
||||||
|
<span style="color: #8492a6;font-size: 16px">¥{{ cartInfo.row.subtotal }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column align="center">
|
||||||
|
<template v-slot="cartInfo">
|
||||||
|
<el-button type="text" style="color: black">移入收藏夹</el-button>
|
||||||
|
<br>
|
||||||
|
<el-button type="text" style="color: black">删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</template>
|
||||||
|
</el-card>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: "index",
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
borderBoolean: false,
|
||||||
|
showHeader: false,
|
||||||
|
cartInfoAttr: [
|
||||||
|
{
|
||||||
|
num: 2,
|
||||||
|
subtotal: 478,
|
||||||
|
productSkuInfo: {
|
||||||
|
sku: '黑色-M',
|
||||||
|
price: 239.0,
|
||||||
|
name: '上衣撒大大大大大阿达大大',
|
||||||
|
stock: 10,
|
||||||
|
image: 'http://127.0.0.1:9300/statics/2024/03/22/小米logo_20240322190304A007.png'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
num: 1,
|
||||||
|
subtotal: 129,
|
||||||
|
productSkuInfo: {
|
||||||
|
sku: '红色-S',
|
||||||
|
price: 129.0,
|
||||||
|
name: '裤子',
|
||||||
|
stock: 12,
|
||||||
|
image: 'http://127.0.0.1:9300/statics/2024/03/22/小米logo_20240322190304A007.png'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
num: 3,
|
||||||
|
subtotal: 477,
|
||||||
|
productSkuInfo: {
|
||||||
|
sku: '白色-XL',
|
||||||
|
price: 159,
|
||||||
|
name: '外套',
|
||||||
|
stock: 10,
|
||||||
|
image: 'http://127.0.0.1:9300/statics/2024/03/22/小米logo_20240322182621A005.png'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
loseCartInfoAttr: [
|
||||||
|
{
|
||||||
|
num: 2,
|
||||||
|
subtotal: 478,
|
||||||
|
productSkuInfo: {
|
||||||
|
sku: '黑色-M',
|
||||||
|
price: 239.0,
|
||||||
|
name: '嘿嘿黑',
|
||||||
|
stock: 10,
|
||||||
|
image: 'http://127.0.0.1:9300/statics/2024/03/22/小米logo_20240322182621A005.png'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
</style>
|
|
@ -0,0 +1,331 @@
|
||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
|
<el-form-item label="商品" prop="projectId">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.projectId"
|
||||||
|
placeholder="请输入商品"
|
||||||
|
clearable
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="SKU" prop="projectSku">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.projectSku"
|
||||||
|
placeholder="请输入SKU"
|
||||||
|
clearable
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="用户" prop="userId">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.userId"
|
||||||
|
placeholder="请输入用户"
|
||||||
|
clearable
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="数量" prop="num">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.num"
|
||||||
|
placeholder="请输入数量"
|
||||||
|
clearable
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="是否选中" prop="isSelected">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.isSelected"
|
||||||
|
placeholder="请输入是否选中"
|
||||||
|
clearable
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
icon="el-icon-plus"
|
||||||
|
size="mini"
|
||||||
|
@click="handleAdd"
|
||||||
|
v-hasPermi="['shopCart:Info:add']"
|
||||||
|
>新增</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
plain
|
||||||
|
icon="el-icon-edit"
|
||||||
|
size="mini"
|
||||||
|
:disabled="single"
|
||||||
|
@click="handleUpdate"
|
||||||
|
v-hasPermi="['shopCart:Info:edit']"
|
||||||
|
>修改</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
plain
|
||||||
|
icon="el-icon-delete"
|
||||||
|
size="mini"
|
||||||
|
:disabled="multiple"
|
||||||
|
@click="handleDelete"
|
||||||
|
v-hasPermi="['shopCart:Info:remove']"
|
||||||
|
>删除</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="warning"
|
||||||
|
plain
|
||||||
|
icon="el-icon-download"
|
||||||
|
size="mini"
|
||||||
|
@click="handleExport"
|
||||||
|
v-hasPermi="['shopCart:Info:export']"
|
||||||
|
>导出</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" :data="InfoList" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
|
<el-table-column label="主键" align="center" prop="id" />
|
||||||
|
<el-table-column label="商品" align="center" prop="projectId" />
|
||||||
|
<el-table-column label="SKU" align="center" prop="projectSku" />
|
||||||
|
<el-table-column label="用户" align="center" prop="userId" />
|
||||||
|
<el-table-column label="数量" align="center" prop="num" />
|
||||||
|
<el-table-column label="是否选中" align="center" prop="isSelected" />
|
||||||
|
<el-table-column label="备注" align="center" prop="remark" />
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-edit"
|
||||||
|
@click="handleUpdate(scope.row)"
|
||||||
|
v-hasPermi="['shopCart:Info:edit']"
|
||||||
|
>修改</el-button>
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
@click="handleDelete(scope.row)"
|
||||||
|
v-hasPermi="['shopCart:Info:remove']"
|
||||||
|
>删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<pagination
|
||||||
|
v-show="total>0"
|
||||||
|
:total="total"
|
||||||
|
:page.sync="queryParams.pageNum"
|
||||||
|
:limit.sync="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- 添加或修改购物车对话框 -->
|
||||||
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||||
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||||
|
<el-form-item label="商品" prop="projectId">
|
||||||
|
<el-input v-model="form.projectId" placeholder="请输入商品" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="SKU" prop="projectSku">
|
||||||
|
<el-input v-model="form.projectSku" placeholder="请输入SKU" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="用户" prop="userId">
|
||||||
|
<el-input v-model="form.userId" placeholder="请输入用户" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="数量" prop="num">
|
||||||
|
<el-input v-model="form.num" placeholder="请输入数量" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="是否选中" prop="isSelected">
|
||||||
|
<el-input v-model="form.isSelected" placeholder="请输入是否选中" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { listInfo, getInfo, delInfo, addInfo, updateInfo } from "@/api/shopCart/Info";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "Info",
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 遮罩层
|
||||||
|
loading: true,
|
||||||
|
// 选中数组
|
||||||
|
ids: [],
|
||||||
|
// 非单个禁用
|
||||||
|
single: true,
|
||||||
|
// 非多个禁用
|
||||||
|
multiple: true,
|
||||||
|
// 显示搜索条件
|
||||||
|
showSearch: true,
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
// 购物车表格数据
|
||||||
|
InfoList: [],
|
||||||
|
// 弹出层标题
|
||||||
|
title: "",
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
projectId: null,
|
||||||
|
projectSku: null,
|
||||||
|
userId: null,
|
||||||
|
num: null,
|
||||||
|
isSelected: null,
|
||||||
|
},
|
||||||
|
// 表单参数
|
||||||
|
form: {},
|
||||||
|
// 表单校验
|
||||||
|
rules: {
|
||||||
|
projectId: [
|
||||||
|
{ required: true, message: "商品不能为空", trigger: "blur" }
|
||||||
|
],
|
||||||
|
projectSku: [
|
||||||
|
{ required: true, message: "SKU不能为空", trigger: "blur" }
|
||||||
|
],
|
||||||
|
userId: [
|
||||||
|
{ required: true, message: "用户不能为空", trigger: "blur" }
|
||||||
|
],
|
||||||
|
num: [
|
||||||
|
{ required: true, message: "数量不能为空", trigger: "blur" }
|
||||||
|
],
|
||||||
|
isSelected: [
|
||||||
|
{ required: true, message: "是否选中不能为空", trigger: "blur" }
|
||||||
|
],
|
||||||
|
createBy: [
|
||||||
|
{ required: true, message: "创建人不能为空", trigger: "blur" }
|
||||||
|
],
|
||||||
|
createTime: [
|
||||||
|
{ required: true, message: "创建时间不能为空", trigger: "blur" }
|
||||||
|
],
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/** 查询购物车列表 */
|
||||||
|
getList() {
|
||||||
|
this.loading = true;
|
||||||
|
listInfo(this.queryParams).then(response => {
|
||||||
|
this.InfoList = response.data.rows;
|
||||||
|
this.total = response.data.total;
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 取消按钮
|
||||||
|
cancel() {
|
||||||
|
this.open = false;
|
||||||
|
this.reset();
|
||||||
|
},
|
||||||
|
// 表单重置
|
||||||
|
reset() {
|
||||||
|
this.form = {
|
||||||
|
id: null,
|
||||||
|
projectId: null,
|
||||||
|
projectSku: null,
|
||||||
|
userId: null,
|
||||||
|
num: null,
|
||||||
|
isSelected: null,
|
||||||
|
remark: null,
|
||||||
|
createBy: null,
|
||||||
|
createTime: null,
|
||||||
|
updateBy: null,
|
||||||
|
updateTime: null
|
||||||
|
};
|
||||||
|
this.resetForm("form");
|
||||||
|
},
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
this.queryParams.pageNum = 1;
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.resetForm("queryForm");
|
||||||
|
this.handleQuery();
|
||||||
|
},
|
||||||
|
// 多选框选中数据
|
||||||
|
handleSelectionChange(selection) {
|
||||||
|
this.ids = selection.map(item => item.id)
|
||||||
|
this.single = selection.length!==1
|
||||||
|
this.multiple = !selection.length
|
||||||
|
},
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
handleAdd() {
|
||||||
|
this.reset();
|
||||||
|
this.open = true;
|
||||||
|
this.title = "添加购物车";
|
||||||
|
},
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
handleUpdate(row) {
|
||||||
|
this.reset();
|
||||||
|
const id = row.id || this.ids
|
||||||
|
getInfo(id).then(response => {
|
||||||
|
this.form = response.data;
|
||||||
|
this.open = true;
|
||||||
|
this.title = "修改购物车";
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 提交按钮 */
|
||||||
|
submitForm() {
|
||||||
|
this.$refs["form"].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
if (this.form.id != null) {
|
||||||
|
updateInfo(this.form).then(response => {
|
||||||
|
this.$modal.msgSuccess("修改成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
addInfo(this.form).then(response => {
|
||||||
|
this.$modal.msgSuccess("新增成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
handleDelete(row) {
|
||||||
|
const ids = row.id || this.ids;
|
||||||
|
this.$modal.confirm('是否确认删除购物车编号为"' + ids + '"的数据项?').then(function() {
|
||||||
|
return delInfo(ids);
|
||||||
|
}).then(() => {
|
||||||
|
this.getList();
|
||||||
|
this.$modal.msgSuccess("删除成功");
|
||||||
|
}).catch(() => {});
|
||||||
|
},
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
handleExport() {
|
||||||
|
this.download('shopCart/Info/export', {
|
||||||
|
...this.queryParams
|
||||||
|
}, `Info_${new Date().getTime()}.xlsx`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
Loading…
Reference in New Issue