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,