From 84bd68fa2a4edf7a0e3ec379eb1dc260d7b7c10d Mon Sep 17 00:00:00 2001 From: aixianling Date: Fri, 6 May 2022 17:34:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A8=E5=B1=80=E5=A2=9E=E5=8A=A0=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=B7=A5=E5=85=B7=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/action.js | 23 +++++++++++++++++++++++ src/common/util.js | 13 ++++++++----- src/main.js | 1 + src/store/index.js | 2 +- 4 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 src/common/action.js 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() } }) },