guoshilong
2023-10-27 2311b03aee9db1bebacdd2ced13c071efda6a011
utils/func.js
@@ -17,76 +17,17 @@
   // 登录操作 1
   const login = (userInfo) => {
      vm.$u.vuex('userInfo', userInfo)
      vm.$u.vuex('accessToken', userInfo.access_token)
      vm.$u.vuex('refreshToken', userInfo.refresh_token)
      vm.$u.vuex('isLogin', true)
      vm.$u.vuex('adCodeBase', userInfo.detail.adCodeBase)
      let role = userInfo.role_id.split(",")
      dynamicMenu(userInfo.role_id, 'app').then(res => {
         if (res.code == 200) {
            let adCodeBase = userInfo.detail.adCodeBase
            if (res.data.length > 2) {
               //当菜单有 首页 工作 我的 时,对用户进行判断
               if (!adCodeBase) {
                  //没有行政区划时 去掉首页
                  res.data.shift()
               }
            }
            store.commit("setTabBarList", res.data)
            store.commit('setActiveRoleId', role[0])
            // uni.switchTab({
            //    url: res.data[0].path
            // })
            let url = res.data[0].path
            let name = ""
            if (url.indexOf("patrol")) {
               name = "责任人首页"
            } else {
               name = "首页"
            }
      //添加当前激活的roleId(默认取第一个)
      vm.$u.vuex('activeRoleId', userInfo.role_id.split(",")[0])
            let params = {
               recipient: userInfo.user_id,
               status: 0
            }
            // #ifdef APP-PLUS
            //2.0
            // 获取App端cid并存入redis
            let pinf = plus.push.getClientInfo();
            console.log(pinf, pinf.clientid, "---------------")
            if (pinf && pinf.clientid) {
               uni.setStorageSync('cid', pinf.clientid);
               saveCId(userInfo.user_id, pinf.clientid)
            } else {
               var obtainingCIDTimer = setInterval(function() {
                  pinf = plus.push.getClientInfo();
                  if (pinf.clientid) {
                     uni.setStorageSync('cid', pinf.clientid);
                     saveCId(userInfo.user_id, pinf.clientid)
                     clearInterval(obtainingCIDTimer);
                  }
               }, 50);
            }
            setTimeout(() => {
               console.log('cid', uni.getStorageSync('cid'));
            }, 500);
            // #endif
            messageCount(params).then(res => {
               updateTabbar(res.data)
               globalNavigator(url, "switchTab", name)
            })
         }
      uni.switchTab({
         url: '/pages/home/index'
      })
   }
   // 退出登录