From 9a9ec2750ae61a5b0992ea4d77fdb7f64ce2cc50 Mon Sep 17 00:00:00 2001 From: rouchen <3133657697@qq.com> Date: Wed, 10 Apr 2024 19:51:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E8=B4=AD=E7=89=A9=E8=BD=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/product/info.js | 10 +- src/api/shopCart/Info.js | 75 ++++ src/api/shopCart/info.js | 44 --- src/components/Editor/index.vue | 4 +- src/layout-shop/index.vue | 45 +-- src/main.js | 7 +- src/permission.js | 1 - src/router/index.js | 27 +- src/views/product/info/detail/index.vue | 379 +++++++------------- src/views/product/info/index.vue | 127 ++----- src/views/shopCart/{info => Info}/index.vue | 36 +- src/views/shopCart/detail/dataStructure | 30 ++ src/views/shopCart/detail/index.vue | 240 +++++++++++++ src/views/shopCart/info/detail/index.vue | 103 ------ 14 files changed, 571 insertions(+), 557 deletions(-) create mode 100644 src/api/shopCart/Info.js delete mode 100644 src/api/shopCart/info.js rename src/views/shopCart/{info => Info}/index.vue (92%) create mode 100644 src/views/shopCart/detail/dataStructure create mode 100644 src/views/shopCart/detail/index.vue delete mode 100644 src/views/shopCart/info/detail/index.vue diff --git a/src/api/product/info.js b/src/api/product/info.js index 5288172..e15e6f7 100644 --- a/src/api/product/info.js +++ b/src/api/product/info.js @@ -10,16 +10,16 @@ export function listInfo(query) { } // 查询商品信息详细 -export function getDetailInfo(id) { +export function getInfo(id) { return request({ - url: '/product/info/detail/' + id, + url: '/product/info/' + id, method: 'get' }) } // 查询商品信息详细 -export function getInfo(id) { +export function getDetailInfo(id) { return request({ - url: '/product/info/' + id, + url: '/product/info/detail/' + id, method: 'get' }) } @@ -36,7 +36,7 @@ export function addInfo(data) { // 修改商品信息 export function updateInfo(data) { return request({ - url: '/product/info/'+data.projectAddModel.id, + url: '/product/info/'+data.id, method: 'put', data: data }) diff --git a/src/api/shopCart/Info.js b/src/api/shopCart/Info.js new file mode 100644 index 0000000..777b991 --- /dev/null +++ b/src/api/shopCart/Info.js @@ -0,0 +1,75 @@ +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 getDetailInfo() { + return request({ + url: '/shopCart/Info/detail', + method: 'get' + }) +} + +// 新增购物车 +export function addInfo(data) { + return request({ + url: '/shopCart/Info', + method: 'post', + data: data + }) +} +export function cartInfoIsSelected(data) { + return request({ + url: '/shopCart/Info/selected', + method: 'post', + data: data + }) +} +export function cartInfoEditNum(data) { + return request({ + url: '/shopCart/Info/num', + 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' + }) +} + +// 删除购物车 +export function removeCartInfo(data) { + return request({ + url: '/shopCart/Info/remove', + method: 'delete', + data: data + }) +} diff --git a/src/api/shopCart/info.js b/src/api/shopCart/info.js deleted file mode 100644 index 789708f..0000000 --- a/src/api/shopCart/info.js +++ /dev/null @@ -1,44 +0,0 @@ -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' - }) -} diff --git a/src/components/Editor/index.vue b/src/components/Editor/index.vue index 7eb6e9f..dd3e1e0 100644 --- a/src/components/Editor/index.vue +++ b/src/components/Editor/index.vue @@ -125,7 +125,7 @@ export default { init() { const editor = this.$refs.editor; if (this.readOnly){ - this.options.modules.toolbar= {} + this.options.modules.toolbar = {}; } this.Quill = new Quill(editor, this.options); // 如果设置了上传地址则自定义图片上传事件 @@ -179,7 +179,7 @@ export default { }, handleUploadSuccess(res, file) { // 如果上传成功 - if (res.data.code == 200) { + if (res.code == 200) { // 获取富文本组件实例 let quill = this.Quill; // 获取光标所在位置 diff --git a/src/layout-shop/index.vue b/src/layout-shop/index.vue index 51a75d4..86bad6e 100644 --- a/src/layout-shop/index.vue +++ b/src/layout-shop/index.vue @@ -1,27 +1,23 @@ diff --git a/src/main.js b/src/main.js index 8513d52..ec9f715 100644 --- a/src/main.js +++ b/src/main.js @@ -1,9 +1,4 @@ - -import Vue from 'vue'; -import ElementUI from 'element-ui'; -import 'element-ui/lib/theme-chalk/index.css'; - -Vue.use(ElementUI); +import Vue from 'vue' import Cookies from 'js-cookie' diff --git a/src/permission.js b/src/permission.js index 7113b17..6034239 100644 --- a/src/permission.js +++ b/src/permission.js @@ -6,7 +6,6 @@ import 'nprogress/nprogress.css' import {getToken} from '@/utils/auth' import {isRelogin} from '@/utils/request' - NProgress.configure({showSpinner: false}) const whiteList = ['/login', '/register'] diff --git a/src/router/index.js b/src/router/index.js index dc4d7a1..ffd7807 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -2,8 +2,8 @@ import Vue from 'vue' import Router from 'vue-router' /* Layout */ import Layout from '@/layout' -import LayoutShop from "@/layout-shop/index.vue"; -import detail from "@/views/product/info/detail/index.vue"; +import LayoutShop from "@/layout-shop"; + Vue.use(Router) /** @@ -82,27 +82,24 @@ export const constantRoutes = [ { path: 'product-detail/:detailId(\\d+)', component: () => import('@/views/product/info/detail/index'), - name: 'ShopProduct', + name: 'productDetail', meta: {title: '商品详情', icon: 'dashboard', affix: true} } ] - },{ - path: '', - component: Layout, - redirect: 'shopindex', + }, + { + path: '/cart', + component: LayoutShop, + redirect: 'cart-detail', children: [ { - path: 'shopindex', - component: () => import('@/views/shopCart/info/detail/index'), - name: 'shopindex', - meta: {title: '购物车', icon: 'dashboard', affix: true} + path: '/cart/detail', + component: () => import('@/views/shopCart/detail/index'), + name: 'myCart', + meta: {title: '我的购物车', icon: 'dashboard', affix: true} } ] }, - // { - // path: '/gb', - // component: detail - // }, { path: '/user', component: Layout, diff --git a/src/views/product/info/detail/index.vue b/src/views/product/info/detail/index.vue index f501f83..b53dbf3 100644 --- a/src/views/product/info/detail/index.vue +++ b/src/views/product/info/detail/index.vue @@ -1,155 +1,120 @@ @@ -289,7 +186,7 @@ export default { color: #475669; font-size: 14px; opacity: 0.75; - line-height: 200px; + line-height: 150px; margin: 0; } @@ -300,5 +197,7 @@ export default { .el-carousel__item:nth-child(2n+1) { background-color: #d3dce6; } +.ql-toolbar{ + display: none; +} - diff --git a/src/views/product/info/index.vue b/src/views/product/info/index.vue index 1866b0b..5e8c755 100644 --- a/src/views/product/info/index.vue +++ b/src/views/product/info/index.vue @@ -116,7 +116,7 @@ @@ -415,15 +414,7 @@ export default { brandId: null, }, // 表单参数 - form: { - mianType: '', - parentType: '', - type:'', - image: '', - price: '', - stock: '' - }, - fufObj: [], + form: {}, // 表单校验 rules: { name: [ @@ -489,9 +480,7 @@ export default { "image": null, "stock": null, "price": null - }, - respData:[], - fifObj: [] + } }; }, watch: { @@ -510,56 +499,17 @@ export default { }, "form.type": { handler(value) { + console.log(value) if (value != null){ getTemplateAttribute(value).then(response => { - console.log("res",response) const {data} = response; const {templateAttributeGroupList,templateAttributeList,attributeList} = data; this.categoryCommonElement.templateAttributeGroupList = templateAttributeGroupList; this.categoryCommonElement.templateAttributeList = templateAttributeList; this.categoryCommonElement.attributeList = attributeList; + }) + } - console.log("resData",this.respData); - if (this.respData != null && this.respData.length !== 0){ - this.categoryCommonElement.templateAttributeGroupList.forEach(template => { - template.attributeList.forEach(te => { - this.respData.forEach(asPro => { - if (te.id == asPro.attributeId){ - console.log("value",asPro.value) - te.value = asPro.value; - this.fufObj.push(asPro); - } - }); - }); - }); - - this.categoryCommonElement.templateAttributeList.forEach(tem => { - this.respData.forEach(asPro => { - console.log(asPro) - if (tem.id === asPro.attributeId){ - tem.value = asPro.value; - this.fufObj.push(asPro); - } - }); - }); - - this.respData.forEach(asPro => { - if (!this.fufObj.includes(asPro)){ - this.attributeCheckedList.push(asPro); - } - }); - - this.categoryCommonElement.attributeList.forEach(attr => { - this.attributeCheckedList.forEach(attri => { - if (attr.id == attri.attributeId){ - attri.name = attr.name; - this.attributeIdCheckedList.push(Number(attr.id)); - } - }); - }); - } - }); - } } } }, @@ -573,29 +523,26 @@ export default { }, oneSetting(){ this.skuList.forEach(skuInfo => { - console.log(skuInfo) skuInfo.image = this.oneSettingForm.image; skuInfo.stock = this.oneSettingForm.stock; skuInfo.price = this.oneSettingForm.price; }) }, changeRule(ruleId){ - console.log("ruleId",ruleId) this.titleList = [] - let ruleInfo = this.ruleList.find(ruleInfo => ruleInfo.id == ruleId); - console.log("ruleInfo",ruleInfo) + let ruleInfo = this.ruleList.find(ruleInfo => ruleInfo.id === ruleId); const {ruleAttrList} = ruleInfo; - console.log(ruleAttrList) let skuTotal = 1; - for (let ruleAttrListKey of Object.keys(ruleAttrList)) { - let ruleAttrInfo = ruleAttrList[ruleAttrListKey]; - this.titleList.push({ - "label": ruleAttrInfo.name, - "prop": "prop" + ruleAttrListKey - }); - skuTotal *= ruleAttrInfo.valueList.length; - } + for (let ruleAttrListKey in ruleAttrList) { + let ruleAttrInfo = ruleAttrList[ruleAttrListKey]; + this.titleList.push({ + "label":ruleAttrInfo.name, + "prop":"prop"+ruleAttrListKey + }) + skuTotal = skuTotal * ruleAttrInfo.valueList.length; + } this.titleList.push(...this.templateTitleList) ; + console.log(this.titleList); this.skuList = []; for (let i = 0; i < skuTotal; i++) { this.skuList.push( @@ -634,9 +581,9 @@ export default { if (response.code === 200){ // 添加逻辑 let attributeId = response.data, - code = this.customAttributeForm.code, - name = this.customAttributeForm.name, - value = this.customAttributeForm.value; + code = this.customAttributeForm.code, + name = this.customAttributeForm.name, + value = this.customAttributeForm.value; // categoryCommonElement / attributeIdCheckedList / attributeCheckedList this.categoryCommonElement.attributeList.push({ "id": attributeId, @@ -687,6 +634,7 @@ export default { listCategory().then(response => { this.categoryOptions = []; this.categoryOptions = this.handleTree(response.data, "id", "parentId"); + console.log(this.categoryOptions) }); }, remoteSearchBrandList(queryValue){ @@ -700,7 +648,7 @@ export default { next() { let isValidate = true; this.$refs["form"].validateField(this.rulesTemplateMap[this.stepNumber],(valid) => { - + console.log(valid) if (valid) { isValidate = false; } @@ -735,16 +683,13 @@ export default { image: null, carouselImages: null, status: null, + ruleId: null, brandId: null, remark: null, createBy: null, createTime: null, updateBy: null, - updateTime: null, - skuList: [], - titleList: [], - categoryCommonElement: [], - oneSettingForm: {} + updateTime: null }; this.resetForm("form"); this.initCategoryTree(); @@ -769,11 +714,7 @@ export default { /** 新增按钮操作 */ handleAdd() { this.reset(); - this.initCategoryTree() this.open = true; - this.skuList=[] - this.titleList= [] - this.oneSettingForm = {} this.title = "添加商品信息"; }, /** 修改按钮操作 */ @@ -781,23 +722,7 @@ export default { this.reset(); const id = row.id || this.ids getInfo(id).then(response => { - console.log("response",response) - this.respData = response.data.asProductAttributeInfos this.form = response.data; - console.log("sd",this.form.id) - this.initCategoryTree() - this.oneSettingForm = response.data.projectSkuInfos - this.categoryOptionValue = [Number(response.data.mianType),Number(response.data.parentType),Number(response.data.type)] - this.changeRule(response.data.ruleId) - console.log("sku",this.changeRule) - console.log("skuu",response.data.projectSkuInfos) - for (var i = 0; i < this.skuList.length; i++) { - this.$set(this.skuList[i], 'image', response.data.projectSkuInfos[i].image); - this.$set(this.skuList[i], 'price', response.data.projectSkuInfos[i].price); - this.$set(this.skuList[i], 'stock', response.data.projectSkuInfos[i].stock); - console.log(this.skuList[i].price, response.data.projectSkuInfos[i].price); - } - console.log("sfdf",this.skuList) this.open = true; this.title = "修改商品信息"; }); @@ -838,7 +763,7 @@ export default { attrValueList: attrValueList, productSkuList: productSkuList }; - console.log("pto",productAddReq) + console.log(productAddReq) if (this.form.id != null) { updateInfo(productAddReq).then(response => { this.$modal.msgSuccess("修改成功"); diff --git a/src/views/shopCart/info/index.vue b/src/views/shopCart/Info/index.vue similarity index 92% rename from src/views/shopCart/info/index.vue rename to src/views/shopCart/Info/index.vue index 4915af0..54eafde 100644 --- a/src/views/shopCart/info/index.vue +++ b/src/views/shopCart/Info/index.vue @@ -9,10 +9,10 @@ @keyup.enter.native="handleQuery" /> - + @@ -55,7 +55,7 @@ icon="el-icon-plus" size="mini" @click="handleAdd" - v-hasPermi="['shopCart:info:add']" + v-hasPermi="['shopCart:Info:add']" >新增 @@ -66,7 +66,7 @@ size="mini" :disabled="single" @click="handleUpdate" - v-hasPermi="['shopCart:info:edit']" + v-hasPermi="['shopCart:Info:edit']" >修改 @@ -77,7 +77,7 @@ size="mini" :disabled="multiple" @click="handleDelete" - v-hasPermi="['shopCart:info:remove']" + v-hasPermi="['shopCart:Info:remove']" >删除 @@ -87,17 +87,17 @@ icon="el-icon-download" size="mini" @click="handleExport" - v-hasPermi="['shopCart:info:export']" + v-hasPermi="['shopCart:Info:export']" >导出 - + - + @@ -109,14 +109,14 @@ type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" - v-hasPermi="['shopCart:info:edit']" + v-hasPermi="['shopCart:Info:edit']" >修改 删除 @@ -136,8 +136,8 @@ - - + + @@ -161,7 +161,7 @@ + + diff --git a/src/views/shopCart/info/detail/index.vue b/src/views/shopCart/info/detail/index.vue deleted file mode 100644 index 438eecc..0000000 --- a/src/views/shopCart/info/detail/index.vue +++ /dev/null @@ -1,103 +0,0 @@ - - -