From f69f6e7c62fa33909cfb65f8f0454e863e17a964 Mon Sep 17 00:00:00 2001 From: szdot Date: Mon, 12 May 2025 02:16:53 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=B1=BB=20=20=E5=9E=8B=E3=80=91?= =?UTF-8?q?=EF=BC=9Afeat=20=E3=80=90=E5=8E=9F=20=20=E5=9B=A0=E3=80=91?= =?UTF-8?q?=EF=BC=9A=E4=BB=8E=E6=8E=A5=E5=8F=A3=E6=8B=BFbanner=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=95=B0=E6=8D=AE=20=E5=8F=82=E6=95=B0=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E9=87=8C=E9=9D=A2=E5=8A=A0banner?= =?UTF-8?q?=E7=9A=84=E8=B7=AF=E5=BE=84=E5=8F=82=E6=95=B0=20=E3=80=90?= =?UTF-8?q?=E8=BF=87=20=20=E7=A8=8B=E3=80=91=EF=BC=9A=20=E3=80=90=E5=BD=B1?= =?UTF-8?q?=20=20=E5=93=8D=E3=80=91=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # 类型 包含: # feat:新功能(feature) # fix:修补bug # docs:文档(documentation) # style: 格式(不影响代码运行的变动) # refactor:重构(即不是新增功能,也不是修改bug的代码变动) # test:增加测试 # chore:构建过程或辅助工具的变动 --- App.vue | 9 +++++++++ settings.js | 3 +++ store/index.js | 27 +++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/App.vue b/App.vue index 35e8216..992697f 100644 --- a/App.vue +++ b/App.vue @@ -11,6 +11,8 @@ this.$store.dispatch('fetchSiteList') //异步加载分类列表 this.$store.dispatch('fetchMenuList') + //异步获取banner列表 + this.$store.dispatch('fetchBannerList') // 创建一个数组存放两个需要等待的异步操作的 Promise const promises = [] //异步获取spu列表 @@ -372,6 +374,10 @@ .h100 { height: 100%; } + + .h80{ + height: 80%; + } .vw100 { width: 100vw; @@ -380,6 +386,9 @@ .w100 { width: 100%; } + .w80{ + width: 80%; + } .w-80rpx { width: 80rpx; diff --git a/settings.js b/settings.js index cd77ae5..e7bf089 100644 --- a/settings.js +++ b/settings.js @@ -1,6 +1,7 @@ const host = 'https://szdot.top' const baseURL = host + '/flycube.php' const listPath = host + '/Data/UploadFiles/category/' +const bannerPath = host + '/Data/UploadFiles/banner/' const spuPath = host + '/Data/UploadFiles/spu/' const skuPath = host + '/Data/UploadFiles/sku/' const sitePath = host + '/Data/UploadFiles/site/' @@ -11,6 +12,7 @@ export default { * host 主站 * api接口地址 * 分类列表路径 + * banner图片路径 * spu产品图片路径 * sku产品图片路径 * 站点图片路径 @@ -19,6 +21,7 @@ export default { "host": host, "baseURL": baseURL, "listPath": listPath, + "bannerPath": bannerPath, "spuPath": spuPath, "skuPath": skuPath, "sitePath": sitePath, diff --git a/store/index.js b/store/index.js index 50740e6..21f97b9 100644 --- a/store/index.js +++ b/store/index.js @@ -10,6 +10,7 @@ const { host, baseURL, listPath, + bannerPath, spuPath, skuPath, sitePath, @@ -35,6 +36,7 @@ const store = new Vuex.Store({ menuList: [], //分类列表 spuList: [], //spu列表 skuList: [], //sku列表 + bannerList: [], //banner列表 shopCon: {}, //商铺信息 cartList: [], //购物车列表 结构:[{"spu_id":"id","skuG":[sku_id,sku_id],"conutG":[数量,数量],"priceG":[单价,单价]},{.....}] @@ -102,6 +104,10 @@ const store = new Vuex.Store({ setSkuList(state, list) { state.skuList = list }, + //设置banner列表 + setBannerList(state, list) { + state.bannerList = list + }, //设置商铺信息 setShopCon(state, obj) { state.shopCon = obj @@ -270,6 +276,27 @@ const store = new Vuex.Store({ } }) }, + //获取banner列表 + async fetchBannerList({ + state, + commit + }) { + await uni.$u.http.get('/Api/Normal/getBannerList', { + params: { + shop_id: state.shop_id + } + }).then(res => { + if (res.data.status === 1) { + res.data.bannerList.forEach(banner => { + banner.photo = bannerPath + banner.photo + }) + //更新数据 + commit('setBannerList', res.data.bannerList) + } else { + commit('setBannerList', []) + } + }) + }, // 获取spu列表 fetchSpuList({ state,