diff --git a/src/common/action.js b/src/common/action.js new file mode 100644 index 00000000..b041b7da --- /dev/null +++ b/src/common/action.js @@ -0,0 +1,23 @@ +const getVuex = () => { + return JSON.parse(uni.getStorageSync('vuex') || {}) +} +const setVuex = vuex => { + uni.setStorageSync("vuex", vuex) +} +export default { + instance: null, + init(instance) { + this.instance = instance + }, + getGridInfo() { + //获取登录着网格员信息 + let vuex = getVuex() + this.instance?.post("/app/appgirdmemberinfo/checkLogOnUser").then(res => { + if (res?.data) { + let {girdId, girdMemberId, girdName, checkType: girdCheckType} = res.data + vuex.user = {...vuex.user, girdId, girdMemberId, girdName, girdCheckType} + setVuex(vuex) + } + }) + } +} diff --git a/src/common/util.js b/src/common/util.js index bac71826..a89810fd 100644 --- a/src/common/util.js +++ b/src/common/util.js @@ -1,6 +1,7 @@ import dict from "./dict"; import dayjs from './monent'; import qs from 'query-string' +import action from './action' const confirm = (content, title, config) => { let ops = {content} @@ -236,7 +237,7 @@ const idCardNoUtil = { /** * 封装权限判断方法 */ -export const $permissions = flag => { +export const permissions = flag => { let buttons = [] if (localStorage.getItem('vuex')) { const vuex = JSON.parse(localStorage.getItem('vuex')) @@ -246,10 +247,11 @@ export const $permissions = flag => { return buttons.some(b => b.id == flag || b.permission == flag) } else return false } -export const $copy = any =>{ - if(any)return JSON.parse(JSON.stringify(any)) +export const copy = any => { + if (any) return JSON.parse(JSON.stringify(any)) else return any } + export default { dict, confirm, @@ -294,6 +296,7 @@ export default { dayjs, idCardNoUtil, qs, - $permissions, - $copy + permissions, + copy, + action } diff --git a/src/main.js b/src/main.js index 52f9ce9f..e6914f4a 100644 --- a/src/main.js +++ b/src/main.js @@ -28,6 +28,7 @@ Vue.prototype.$dayjs = dayjs Vue.prototype.$cdn = 'https://cdn.cunwuyun.cn/dvcp/h5/'; Object.keys(utils).map((e) => (Vue.prototype['$' + e] = utils[e])); utils.dict.init({instance: axios}) +utils.action.init(axios) App.mpType = 'app'; process.env.NODE_ENV == 'development' && new VConsole(); const app = new Vue({ diff --git a/src/store/index.js b/src/store/index.js index e9e01a51..fba76bc7 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -11,7 +11,6 @@ const store = new Vuex.Store({ token: "", corpId: "", openUser: {}, - dicts: [], user: {}, config: {} }, @@ -211,6 +210,7 @@ const store = new Vuex.Store({ return http.post("/admin/user/detail-phone").then(res => { if (res?.code == 0) { state.commit('setUser', res.data) + this.$action.getGridInfo() } }) },