全局增加接口工具类
This commit is contained in:
23
src/common/action.js
Normal file
23
src/common/action.js
Normal file
@@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -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 =>{
|
||||
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
|
||||
}
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user