From 18e8f158a47b523926defa88a2bbae918f84aa7e Mon Sep 17 00:00:00 2001 From: szdot Date: Fri, 26 Apr 2024 23:07:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E7=89=87=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/SelectionShopId.vue | 2 +- src/settings.js | 18 +++++++++++++++--- src/store/index.js | 16 +++++++++++++++- src/store/modules/settings.js | 6 ++++++ src/views/layout/components/headbar.vue | 2 +- src/views/layout/components/main/admin/add.vue | 6 +++--- .../layout/components/main/category/index.vue | 2 +- .../layout/components/main/order/show.vue | 1 + .../layout/components/main/product/spu/add.vue | 4 ++-- src/views/layout/components/main/shop/add.vue | 6 +++--- 10 files changed, 48 insertions(+), 15 deletions(-) diff --git a/src/components/SelectionShopId.vue b/src/components/SelectionShopId.vue index 501d951..13fb4a8 100644 --- a/src/components/SelectionShopId.vue +++ b/src/components/SelectionShopId.vue @@ -7,7 +7,7 @@ + :src="item.logo[0]"> {{ item.name }} diff --git a/src/settings.js b/src/settings.js index 72284ae..a5ce4ff 100644 --- a/src/settings.js +++ b/src/settings.js @@ -1,8 +1,11 @@ const host = 'https://www.szdot.top' const baseURL = host + '/flycube.php' -const listPath = host + '/Data/UploadFiles/category/' -const spuPath = host + '/Data/UploadFiles/spu/' -const skuPath = host + '/Data/UploadFiles/sku/' +const listPath = host + '/Data/UploadFiles/category/'// 分类列表图标 +const spuPath = host + '/Data/UploadFiles/spu/'// spu图 +const skuPath = host + '/Data/UploadFiles/sku/' // sku图 +const logoPath = host + '/Data/UploadFiles/logo/' // 商铺图标 +const photoPath = host + '/Data/UploadFiles/photo/'// 管理员图标 +const tempPath = host + '/Data/UploadFiles/temp/' // 临时图片路径 export default { /** @@ -14,6 +17,12 @@ export default { * @description: api服务器 * host 主站 * api接口地址 + * 分类图标 路径 + * spu图 路径 + * sku图 路径 + * 商铺图标 路径 + * 管理员头像 路径 + * 临时图片 路径 * api飞机控制终端接口路径 * api小程序后台接口路径 * api登录接口路径 @@ -23,6 +32,9 @@ export default { listPath: listPath, spuPath: spuPath, skuPath: skuPath, + logoPath: logoPath, + photoPath: photoPath, + tempPath: tempPath, apiPlanePath: '/mpApi/Plane/', apiAdminPath: '/mpApi/Admin/', apiLoginPath: '/mpApi/Login/', diff --git a/src/store/index.js b/src/store/index.js index b3bd3bf..e38589d 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -99,6 +99,12 @@ const store = new Vuex.Store({ async fetchShopList ({ commit }) { const res = await api.get('getShopList', 'Admin') if (res.data.status === 1) { + res.data.shopList.forEach((shop, index) => { + shop.logo = JSON.parse(shop.logo)// 反序列化 photo字段 + shop.logo.forEach((logo, i) => { + res.data.shopList[index].logo[i] = settings.state.logoPath + logo // 把绝对路径加上 + }) + }) commit('setShopList', res.data.shopList) } else { commit('setShopList', []) @@ -167,10 +173,16 @@ const store = new Vuex.Store({ async fetchAdminList ({ commit }) { const res = await api.get('getAdminList', 'Admin') if (res.data.status === 1) { - res.data.adminList.forEach(item => { // 判断如果是当前登录用户 最后登录时间字段 从本地缓存中获取 PS:既登陆前缓存到本地的“最后登陆时间” 因为登录后 服务端会把当前登录的时间刷到lasttime字段 + res.data.adminList.forEach((item, index) => { + // 判断如果是当前登录用户 最后登录时间字段 从本地缓存中获取 PS:既登陆前缓存到本地的“最后登陆时间” 因为登录后 服务端会把当前登录的时间刷到lasttime字段 if (item.shop_id === store.state.user.shop_id) { item.lasttime = store.state.user.lasttime } + // 头像字段反序列化 + item.photo = JSON.parse(item.photo)// 反序列化 photo字段 + item.photo.forEach((photo, i) => { + res.data.adminList[index].photo[i] = settings.state.photoPath + photo // 把绝对路径加上 + }) }) commit('setAdminList', res.data.adminList) } else { @@ -643,6 +655,8 @@ const store = new Vuex.Store({ const res = await api.get('getSpuList', 'Admin') if (res.data.status === 1) { res.data.spuList.forEach((spu, index) => { + spu.pro_tag = JSON.parse(spu.pro_tag)// 反序列化 pro_tag字段 + spu.bind_sku = JSON.parse(spu.bind_sku)// 反序列化 bind_sku字段 spu.photo = JSON.parse(spu.photo)// 反序列化 photo字段 spu.photo.forEach((photo, i) => { res.data.spuList[index].photo[i] = settings.state.spuPath + photo // 把绝对路径加上 diff --git a/src/store/modules/settings.js b/src/store/modules/settings.js index de300b2..754746c 100644 --- a/src/store/modules/settings.js +++ b/src/store/modules/settings.js @@ -7,6 +7,9 @@ const { listPath, spuPath, skuPath, + logoPath, + photoPath, + tempPath, apiPlanePath, apiAdminPath, apiLoginPath, @@ -23,6 +26,9 @@ const state = { listPath: listPath, spuPath: spuPath, skuPath: skuPath, + logoPath: logoPath, + photoPath: photoPath, + tempPath: tempPath, apiPlanePath: apiPlanePath, apiAdminPath: apiAdminPath, apiLoginPath: apiLoginPath, diff --git a/src/views/layout/components/headbar.vue b/src/views/layout/components/headbar.vue index 55084d3..10a0940 100644 --- a/src/views/layout/components/headbar.vue +++ b/src/views/layout/components/headbar.vue @@ -129,7 +129,7 @@ export default { * @description: 用户头像地址 */ avatar () { - return this.$store.state.settings.host + this.$store.state.user.photo + return this.$store.state.settings.photoPath + this.$store.state.user.photo }, /** * @description: 获取订单列表 diff --git a/src/views/layout/components/main/admin/add.vue b/src/views/layout/components/main/admin/add.vue index 2c64d09..bdfce95 100644 --- a/src/views/layout/components/main/admin/add.vue +++ b/src/views/layout/components/main/admin/add.vue @@ -26,9 +26,9 @@ :show-file-list="false" :on-success="handleUpSuccess" :on-error="handleUpErr" :before-upload="beforeAvatarUpload"> - + :src="$store.state.settings.tempPath + form.upFile" class="avatar" /> +