From 4e8605989a69315d5a258da6aaeeb4b170cf372d Mon Sep 17 00:00:00 2001 From: szdot Date: Fri, 26 Apr 2024 14:04:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E7=89=87=E5=AD=97=E6=AE=B5=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=20=E5=BA=8F=E5=88=97=E5=8C=96=E6=95=B0=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/SelectionPath.vue | 2 +- src/settings.js | 14 +++++++++++--- src/store/index.js | 19 ++++++++++++++++++- src/store/modules/settings.js | 6 ++++++ .../layout/components/main/category/index.vue | 7 +++---- .../components/main/product/sku/add.vue | 6 +++--- .../components/main/product/sku/index.vue | 6 +++--- .../components/main/product/spu/add.vue | 4 ++-- .../components/main/product/spu/index.vue | 4 ++-- 9 files changed, 49 insertions(+), 19 deletions(-) diff --git a/src/components/SelectionPath.vue b/src/components/SelectionPath.vue index 6572839..fb51350 100644 --- a/src/components/SelectionPath.vue +++ b/src/components/SelectionPath.vue @@ -6,7 +6,7 @@ + :src="item.photo[0]"> diff --git a/src/settings.js b/src/settings.js index 69bf11d..72284ae 100644 --- a/src/settings.js +++ b/src/settings.js @@ -1,4 +1,9 @@ -module.exports = { +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/' +export default { /** * @description: 全局title @@ -13,8 +18,11 @@ module.exports = { * api小程序后台接口路径 * api登录接口路径 */ - host: 'https://szdot.top', - baseURL: 'https://szdot.top/flycube.php', + host: host, + baseURL: baseURL, + listPath: listPath, + spuPath: spuPath, + skuPath: skuPath, apiPlanePath: '/mpApi/Plane/', apiAdminPath: '/mpApi/Admin/', apiLoginPath: '/mpApi/Login/', diff --git a/src/store/index.js b/src/store/index.js index 5d997fe..b3bd3bf 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -205,7 +205,6 @@ const store = new Vuex.Store({ * @return {*} 服务器返回值 */ async fetchSaveAdmin ({ dispatch }, form) { - console.log(form) const params = new URLSearchParams() params.append('id', form.id) params.append('shop_id', form.shop_id) @@ -558,6 +557,12 @@ const store = new Vuex.Store({ async fetchCategoryList ({ commit }) { const res = await api.get('getCategoryList', 'Admin') if (res.data.status === 1) { + res.data.categoryList.forEach((category, index) => { + category.photo = JSON.parse(category.photo)// 反序列化 photo字段 + category.photo.forEach((photo, i) => { + res.data.categoryList[index].photo[i] = settings.state.listPath + photo // 把绝对路径加上 + }) + }) commit('setCategoryList', res.data.categoryList) } else { commit('setCategoryList', []) @@ -637,6 +642,12 @@ const store = new Vuex.Store({ async fetchSpuList ({ commit }) { const res = await api.get('getSpuList', 'Admin') if (res.data.status === 1) { + res.data.spuList.forEach((spu, index) => { + spu.photo = JSON.parse(spu.photo)// 反序列化 photo字段 + spu.photo.forEach((photo, i) => { + res.data.spuList[index].photo[i] = settings.state.spuPath + photo // 把绝对路径加上 + }) + }) commit('setSpuList', res.data.spuList) } else { commit('setSpuList', []) @@ -804,6 +815,12 @@ const store = new Vuex.Store({ async fetchSkuList ({ commit }) { const res = await api.get('getSkuList', 'Admin') if (res.data.status === 1) { + res.data.skuList.forEach((sku, index) => { + sku.photo = JSON.parse(sku.photo)// 反序列化 photo字段 + sku.photo.forEach((photo, i) => { + res.data.skuList[index].photo[i] = settings.state.skuPath + photo // 把绝对路径加上 + }) + }) commit('setSkuList', res.data.skuList) } else { commit('setSkuList', []) diff --git a/src/store/modules/settings.js b/src/store/modules/settings.js index ed97536..de300b2 100644 --- a/src/store/modules/settings.js +++ b/src/store/modules/settings.js @@ -4,6 +4,9 @@ const { title, host, baseURL, + listPath, + spuPath, + skuPath, apiPlanePath, apiAdminPath, apiLoginPath, @@ -17,6 +20,9 @@ const state = { title: title, host: host, baseURL: baseURL, + listPath: listPath, + spuPath: spuPath, + skuPath: skuPath, apiPlanePath: apiPlanePath, apiAdminPath: apiAdminPath, apiLoginPath: apiLoginPath, diff --git a/src/views/layout/components/main/category/index.vue b/src/views/layout/components/main/category/index.vue index 326a40a..2a47faa 100644 --- a/src/views/layout/components/main/category/index.vue +++ b/src/views/layout/components/main/category/index.vue @@ -73,8 +73,8 @@ :before-upload="beforeAvatarUpload"> - +