guoshilong
2023-10-27 31e6b27fc0b7fb2ae715efa4287d8f5539f33d78
store/index.js
@@ -48,10 +48,12 @@
      // 如果version无需保存到本地永久存储,无需lifeData.version方式
      version: '1.0.0',
      activeRoleId: "",
      tabBarList: [],
      // tabBarList: [],
      adCodeBase: {},
      tabbarIndex: uni.getStorageSync("tabbarIndex") || 0,
      // tabbarIndex: uni.getStorageSync("tabbarIndex") || 0,
      hasUpdate: false, //true为不可登录,需要更新,false则是最新版
      menu: [],
   },
   mutations: {
@@ -75,31 +77,37 @@
         // 保存变量到本地,见顶部函数定义
         saveLifeData(saveKey, state[saveKey])
      },
      // 设置菜单
      setTabBarList(state, data) {
         let i = 0
         if (state.tabBarList.length > 0) {
            i = state.tabBarList.length
         }
         data.forEach(e => {
            e.i = i
            i++
         })
      // // 设置菜单
      // setTabBarList(state, data) {
      //    let i = 0
      //    if (state.tabBarList.length > 0) {
      //       i = state.tabBarList.length
      //    }
      //    data.forEach(e => {
      //       e.i = i
      //       i++
      //    })
         state.tabBarList = data;
         uni.setStorageSync('tabBarList', data)
         // console.log(uni.getStorageSync('tabBarList'))
      },
      //    state.tabBarList = data;
      //    uni.setStorageSync('tabBarList', data)
      //    // console.log(uni.getStorageSync('tabBarList'))
      // },
      //设置当前激活的角色
      setActiveRoleId(state, roleId) {
         state.activeRoleId = roleId
         uni.setStorageSync('activeRoleId', roleId)
      },
      //设置底部导航栏索引
      SET_TABBAT_INDEX(state, index) {
         state.tabbarIndex = index
         uni.setStorageSync('tabbarIndex', index)
      SET_MENU(state, menuList) {
         state.menu = menuList
         uni.setStorageSync('menu', menuList)
      },
      //设置底部导航栏索引
      // SET_TABBAT_INDEX(state, index) {
      //    state.tabbarIndex = index
      //    uni.setStorageSync('tabbarIndex', index)
      // },
      SET_HAS_UPDATE(state, val) {
         state.hasUpdate = val
         uni.setStorageSync('hasUpdate', val)