|
@@ -7,7 +7,6 @@ import {
|
|
|
USER_NAME,
|
|
USER_NAME,
|
|
|
USER_INFO
|
|
USER_INFO
|
|
|
} from "@/common/util/constants"
|
|
} from "@/common/util/constants"
|
|
|
-
|
|
|
|
|
Vue.use(Vuex)
|
|
Vue.use(Vuex)
|
|
|
|
|
|
|
|
export default new Vuex.Store({
|
|
export default new Vuex.Store({
|
|
@@ -56,7 +55,7 @@ export default new Vuex.Store({
|
|
|
}
|
|
}
|
|
|
//授权第二步
|
|
//授权第二步
|
|
|
api.authorize(params).then(response2 => {
|
|
api.authorize(params).then(response2 => {
|
|
|
- if (response.data.state == 200) {
|
|
|
|
|
|
|
+ if (response2.data.state == 200) {
|
|
|
let auparams = {
|
|
let auparams = {
|
|
|
authorize_code: response2.data.data,
|
|
authorize_code: response2.data.data,
|
|
|
client_id: 'ibps',
|
|
client_id: 'ibps',
|
|
@@ -64,35 +63,27 @@ export default new Vuex.Store({
|
|
|
grant_type: 'authorization_code'
|
|
grant_type: 'authorization_code'
|
|
|
}
|
|
}
|
|
|
//授权第三步
|
|
//授权第三步
|
|
|
- api.authentication(auparams).then(res => {
|
|
|
|
|
- if (res.data.state == 200) {
|
|
|
|
|
|
|
+ api.authentication(auparams).then(response3 => {
|
|
|
|
|
+ if (response3.data.state == 200) {
|
|
|
|
|
+ let dataAuparams = response3.data.data
|
|
|
//将返回的token给到
|
|
//将返回的token给到
|
|
|
- uni.setStorageSync(ACCESS_TOKEN, res
|
|
|
|
|
- .data.data.access_token);
|
|
|
|
|
- uni.setStorageSync("refresh_token", res
|
|
|
|
|
- .data.data.refresh_token);
|
|
|
|
|
|
|
+ uni.setStorageSync(ACCESS_TOKEN, dataAuparams.access_token);
|
|
|
|
|
+ uni.setStorageSync("refresh_token", dataAuparams.refresh_token);
|
|
|
//获取用户信息
|
|
//获取用户信息
|
|
|
api.context(username).then(res => {
|
|
api.context(username).then(res => {
|
|
|
if (res.data.state == 200) {
|
|
if (res.data.state == 200) {
|
|
|
- let info = res.data
|
|
|
|
|
- .data
|
|
|
|
|
- uni.setStorageSync(
|
|
|
|
|
- USER_INFO, info
|
|
|
|
|
- )
|
|
|
|
|
- if (info.user.id ==
|
|
|
|
|
- '1100364672239927296' ||
|
|
|
|
|
- info.user.id ==
|
|
|
|
|
- '1100468240921919488'
|
|
|
|
|
- ) {
|
|
|
|
|
- uni.setStorageSync(
|
|
|
|
|
- 'administrator',
|
|
|
|
|
- true)
|
|
|
|
|
|
|
+ let info = res.data.data
|
|
|
|
|
+ uni.setStorageSync(USER_INFO, info)
|
|
|
|
|
+ if (info.user.id == '1100364672239927296' || info.user.id == '1100468240921919488') {
|
|
|
|
|
+ uni.setStorageSync('administrator', true)
|
|
|
resolve(res)
|
|
resolve(res)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- if (info.org.id !=
|
|
|
|
|
- '1041786072788369408'
|
|
|
|
|
- ) {
|
|
|
|
|
|
|
+ if (info && info.org && info.org.id == '1041786072788369408') {
|
|
|
|
|
+ uni.setStorageSync('administrator', false)
|
|
|
|
|
+ resolve(res)
|
|
|
|
|
+ return
|
|
|
|
|
+ } else {
|
|
|
uni.showToast({
|
|
uni.showToast({
|
|
|
title: '该账户不是客户账号',
|
|
title: '该账户不是客户账号',
|
|
|
icon: 'none',
|
|
icon: 'none',
|
|
@@ -101,16 +92,12 @@ export default new Vuex.Store({
|
|
|
reject(res)
|
|
reject(res)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- uni.setStorageSync(
|
|
|
|
|
- 'administrator',
|
|
|
|
|
- false)
|
|
|
|
|
- resolve(res)
|
|
|
|
|
} else {
|
|
} else {
|
|
|
reject(res)
|
|
reject(res)
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
} else {
|
|
} else {
|
|
|
- reject(res)
|
|
|
|
|
|
|
+ reject(response3)
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
} else {
|
|
} else {
|
|
@@ -237,9 +224,6 @@ export default new Vuex.Store({
|
|
|
resolve(response2)
|
|
resolve(response2)
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
} else {
|
|
} else {
|
|
|
reject(response)
|
|
reject(response)
|
|
|
}
|
|
}
|