diff --git a/App.vue b/App.vue index e3ba390..fdc290c 100644 --- a/App.vue +++ b/App.vue @@ -2,15 +2,25 @@ export default { // 数据初始化 onLaunch: function(options) { - //从二维码获取站点id 单位id - // 获取参数,如果不存在则使用默认值 - const shopId = options?.query?.s || '2dc23dcfecc05fb1' - const siteId = options?.query?.z || '13' + /* 从二维码获取地块id 单位id 获取参数,如果不存在则使用默认值 */ + // 1. 获取 scene 参数 + const scene = options.query.scene // 示例值: "9egr2wqjwy03ddcc20"前16位shop_id + // 2. 解析 scene 字符串 + let shopId = '2dc23dcfecc05fb1' // 默认值 + let siteId = '13' // 默认值 + if (scene) { + shopId = scene.slice(0, 16) + siteId = scene.slice(16) + } + console.log(shopId) + console.log(siteId) + // 3. 存储到 Vuex this.$store.commit('setShopId', String(shopId)) this.$store.commit('setSiteId', String(siteId)) - //异步加载单位信息 + + /*异步加载单位信息*/ this.$store.dispatch('fetchShopCon') - //异步加载站点列表 + //异步加载地块列表 this.$store.dispatch('fetchSiteList') //异步加载分类列表 this.$store.dispatch('fetchMenuList')