【类 型】:style
【主 题】:取消多余判断 【描 述】: [原因]:入口时直接请求接口 获取数据 不用判断有没有 [过程]: [影响]: 【结 束】 # 类型 包含: # feat:新功能(feature) # fix:修补bug # docs:文档(documentation) # style: 格式(不影响代码运行的变动) # refactor:重构(即不是新增功能,也不是修改bug的代码变动) # test:增加测试 # chore:构建过程或辅助工具的变动
This commit is contained in:
parent
be06835a6d
commit
1efa9308f2
10
App.vue
10
App.vue
@ -3,27 +3,17 @@
|
|||||||
// 数据初始化
|
// 数据初始化
|
||||||
onLaunch: function() {
|
onLaunch: function() {
|
||||||
//异步加载商铺信息
|
//异步加载商铺信息
|
||||||
if (Object.keys(this.$store.state.shopCon).length === 0) {
|
|
||||||
this.$store.dispatch('fetchShopCon')
|
this.$store.dispatch('fetchShopCon')
|
||||||
}
|
|
||||||
//异步加载站点列表
|
//异步加载站点列表
|
||||||
if (this.$store.state.siteList.length === 0) {
|
|
||||||
this.$store.dispatch('fetchSiteList')
|
this.$store.dispatch('fetchSiteList')
|
||||||
}
|
|
||||||
//异步加载分类列表
|
//异步加载分类列表
|
||||||
if (this.$store.state.menuList.length === 0) {
|
|
||||||
this.$store.dispatch('fetchMenuList')
|
this.$store.dispatch('fetchMenuList')
|
||||||
}
|
|
||||||
// 创建一个数组存放两个需要等待的异步操作的 Promise
|
// 创建一个数组存放两个需要等待的异步操作的 Promise
|
||||||
const promises = [];
|
const promises = [];
|
||||||
//异步获取spu列表
|
//异步获取spu列表
|
||||||
if (this.$store.state.spuList.length === 0) {
|
|
||||||
promises.push(this.$store.dispatch('fetchSpuList'))
|
promises.push(this.$store.dispatch('fetchSpuList'))
|
||||||
}
|
|
||||||
//异步获取sku列表
|
//异步获取sku列表
|
||||||
if (this.$store.state.skuList.length === 0) {
|
|
||||||
promises.push(this.$store.dispatch('fetchSkuList'))
|
promises.push(this.$store.dispatch('fetchSkuList'))
|
||||||
}
|
|
||||||
//等sku spu获取全部数据之后
|
//等sku spu获取全部数据之后
|
||||||
Promise.all(promises).then(() => {
|
Promise.all(promises).then(() => {
|
||||||
this.$store.commit('addMinPriceToSpuList') //给spu添加最低价格字段
|
this.$store.commit('addMinPriceToSpuList') //给spu添加最低价格字段
|
||||||
|
Loading…
Reference in New Issue
Block a user