全局增加接口工具类
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 dict from "./dict";
|
||||||
import dayjs from './monent';
|
import dayjs from './monent';
|
||||||
import qs from 'query-string'
|
import qs from 'query-string'
|
||||||
|
import action from './action'
|
||||||
|
|
||||||
const confirm = (content, title, config) => {
|
const confirm = (content, title, config) => {
|
||||||
let ops = {content}
|
let ops = {content}
|
||||||
@@ -236,7 +237,7 @@ const idCardNoUtil = {
|
|||||||
/**
|
/**
|
||||||
* 封装权限判断方法
|
* 封装权限判断方法
|
||||||
*/
|
*/
|
||||||
export const $permissions = flag => {
|
export const permissions = flag => {
|
||||||
let buttons = []
|
let buttons = []
|
||||||
if (localStorage.getItem('vuex')) {
|
if (localStorage.getItem('vuex')) {
|
||||||
const vuex = JSON.parse(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)
|
return buttons.some(b => b.id == flag || b.permission == flag)
|
||||||
} else return false
|
} else return false
|
||||||
}
|
}
|
||||||
export const $copy = any =>{
|
export const copy = any => {
|
||||||
if(any)return JSON.parse(JSON.stringify(any))
|
if (any) return JSON.parse(JSON.stringify(any))
|
||||||
else return any
|
else return any
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
dict,
|
dict,
|
||||||
confirm,
|
confirm,
|
||||||
@@ -294,6 +296,7 @@ export default {
|
|||||||
dayjs,
|
dayjs,
|
||||||
idCardNoUtil,
|
idCardNoUtil,
|
||||||
qs,
|
qs,
|
||||||
$permissions,
|
permissions,
|
||||||
$copy
|
copy,
|
||||||
|
action
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ Vue.prototype.$dayjs = dayjs
|
|||||||
Vue.prototype.$cdn = 'https://cdn.cunwuyun.cn/dvcp/h5/';
|
Vue.prototype.$cdn = 'https://cdn.cunwuyun.cn/dvcp/h5/';
|
||||||
Object.keys(utils).map((e) => (Vue.prototype['$' + e] = utils[e]));
|
Object.keys(utils).map((e) => (Vue.prototype['$' + e] = utils[e]));
|
||||||
utils.dict.init({instance: axios})
|
utils.dict.init({instance: axios})
|
||||||
|
utils.action.init(axios)
|
||||||
App.mpType = 'app';
|
App.mpType = 'app';
|
||||||
process.env.NODE_ENV == 'development' && new VConsole();
|
process.env.NODE_ENV == 'development' && new VConsole();
|
||||||
const app = new Vue({
|
const app = new Vue({
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ const store = new Vuex.Store({
|
|||||||
token: "",
|
token: "",
|
||||||
corpId: "",
|
corpId: "",
|
||||||
openUser: {},
|
openUser: {},
|
||||||
dicts: [],
|
|
||||||
user: {},
|
user: {},
|
||||||
config: {}
|
config: {}
|
||||||
},
|
},
|
||||||
@@ -211,6 +210,7 @@ const store = new Vuex.Store({
|
|||||||
return http.post("/admin/user/detail-phone").then(res => {
|
return http.post("/admin/user/detail-phone").then(res => {
|
||||||
if (res?.code == 0) {
|
if (res?.code == 0) {
|
||||||
state.commit('setUser', res.data)
|
state.commit('setUser', res.data)
|
||||||
|
this.$action.getGridInfo()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user