Lou
2023-12-28 9c4d1e58eede5211bcce32d79cba2c463a7bc427
优化
3 files modified
83 ■■■■ changed files
pages/home/index.vue 23 ●●●●● patch | view | raw | blame | history
store/index.js 52 ●●●●● patch | view | raw | blame | history
utils/func.js 8 ●●●●● patch | view | raw | blame | history
pages/home/index.vue
@@ -8,8 +8,7 @@
                <u-icon name="arrow-down" color="#fff"></u-icon>
            </view>
        </u-navbar> -->
        <u-navbar height="48" :autoBack="false" safeAreaInsetTop placeholder @leftClick="navToSelectSite()"
            bgColor="#017BFC">
            <view slot="left" class="top flex">
@@ -18,16 +17,12 @@
                <u-icon name="arrow-right" color="#fff"></u-icon>
            </view>
        </u-navbar>
        <view class="swiper">
            <u-swiper :list="bannerList" height="320rpx" radius="10"></u-swiper>
        </view>
        <view class="content">
            <view class="">
                <view class="section flex j-c-s-a a-i-c mb-20" v-if="isShowContact && curSelectSite.addressType == 1">
                    <view class="section-item" v-for="(i,k) in contactList" :key="k" v-if="i.name"
                        @click="navigatorPage(`${i.path}?id=${i.id}`)">
@@ -265,8 +260,8 @@
                this.init()
            })
            //选择位置刷新楼盘表
            uni.$on('refreshPage',(val)=>{
                console.log("refreshPage=>",val);
            uni.$on('refreshPage', (val) => {
                console.log("refreshPage=>", val);
                this.curSelectSite = val
                this.getHouseDataList(val.id)
            })
@@ -578,7 +573,7 @@
                if (type == 1) {
                    let index = arr.findIndex(item => item.name == "标签报事")
                    return index;
                } else{
                } else {
                    let index2 = arr.findIndex(item => item.name == "租户上报")
                    return index2
                }
@@ -616,9 +611,9 @@
                            title: "尚无绑定房屋信息",
                            icon: "error"
                        })
                    } else if (path == '/subPackage/workbench/views/cscj'){
                        this.$u.func.globalNavigator(path,"navTo")
                    }else {
                    } else if (path == '/subPackage/workbench/views/cscj') {
                        this.$u.func.globalNavigator(path, "navTo")
                    } else {
                        this.$u.func.globalNavigator(`${path}?houseCode=${this.curHouseCode}`, "navTo")
                    }
                } else {
@@ -628,8 +623,8 @@
                    })
                }
            },
            navToSelectSite(){
            navToSelectSite() {
                this.$u.func.globalNavigator('selectSite', "navTo")
            },
store/index.js
@@ -2,8 +2,8 @@
import Vuex from 'vuex'
Vue.use(Vuex)
import {
        dynamicMenu,
    } from "@/api/system/role.js"
    dynamicMenu,
} from "@/api/system/role.js"
let lifeData = {};
try {
@@ -55,8 +55,8 @@
        // tabbarIndex: uni.getStorageSync("tabbarIndex") || 0,
        hasUpdate: false, //true为不可登录,需要更新,false则是最新版
        menu: [],
        siteInfo:{}    ,//社区信息
        labelMenuList:[]      //标签报事菜单
        siteInfo: {}, //社区信息
        labelMenuList: [] //标签报事菜单
    },
    mutations: {
@@ -120,35 +120,41 @@
            uni.setStorageSync('userInfo', data)
        },
        //设置社区位置
        setSiteInfo(state,val){
        setSiteInfo(state, val) {
            state.siteInfo = val;
            uni.setStorageSync('siteInfo', val)
        },
        //标签报事菜单
        setLabelReporMenutList(state,val){
        setLabelReporMenutList(state, val) {
            state.labelMenuList = val;
            uni.setStorageSync('labelMenuList',val);
            uni.setStorageSync('labelMenuList', val);
        }
    },
    actions:{
        getMenuList({commit}){
    actions: {
        getMenuList({
            commit
        }) {
            // let id = uni.getStorageSync("activeRole").id;
            let { id, roleName } = uni.getStorageSync("activeRole")
            return new Promise((resolve,reject)=>{
                 let param = {
                     roleId:id
                 }
                if(uni.getStorageSync("siteInfo").addressType == 1 && roleName == "居民"){
                    param.labelType = 1;
            let {
                id,
                roleName
            } = uni.getStorageSync("activeRole")
            return new Promise((resolve, reject) => {
                let param = {
                    roleId: id
                }
                console.log("===>",param);
                dynamicMenu(param).then(res=>{
                    if(res.code == 200){
                if (uni.getStorageSync("siteInfo").addressType == 1 || roleName == "居民") {
                    param.labelType = uni.getStorageSync("siteInfo").addressType;
                    param.roleName = roleName;
                }
                console.log("===>", param);
                dynamicMenu(param).then(res => {
                    if (res.code == 200) {
                        let data = res.data;
                        if(!data) return
                        if (!data) return
                        let menu = data.filter(e => e.name == 'app')[0].children;
                        commit("SET_MENU",menu);
                        commit("SET_MENU", menu);
                        // let liveList = menu.filter(item=>item.name == '生活')
                        // let labelList = [];
                        // if(liveList.length && liveList[0].children){
@@ -160,7 +166,7 @@
                        //     }
                        // }
                        resolve(menu)
                    }else {
                    } else {
                        reject("fail")
                    }
                })
utils/func.js
@@ -12,24 +12,22 @@
    // 登录操作 1
    const login = async (userInfo) => {
        vm.$u.vuex('userInfo', userInfo)
        vm.$u.vuex('accessToken', userInfo.access_token)
        vm.$u.vuex('isLogin', true)
        let activeRoleId = userInfo.role_id.split(",")[0]
        const resDetail = await getDetail({
            id: activeRoleId
        })
        console.log("当前激活角色的id:", resDetail.data)
        //添加当前激活的角色(默认取第一个)
        store.commit('setActiveRole', resDetail.data)
        //获取角色菜单
        const {
            data
        } = await dynamicMenu({roleId:activeRoleId})
        } = await dynamicMenu({
            roleId: activeRoleId
        })
        let appMenu = data.filter(e => e.name == 'app')[0].children
        console.log("当前角色菜单:", appMenu)