|
|
@@ -37,53 +37,32 @@ export default new Vuex.Store({
|
|
|
}
|
|
|
},
|
|
|
actions: {
|
|
|
- /**
|
|
|
- *
|
|
|
- const result = response.data.result
|
|
|
- const userInfo = result.userInfo
|
|
|
- uni.setStorageSync(ACCESS_TOKEN,result.token);
|
|
|
- uni.setStorageSync(USER_INFO,userInfo);
|
|
|
- commit('SET_TOKEN', result.token)
|
|
|
- commit('SET_NAME', { username: userInfo.username,realname: userInfo.realname})
|
|
|
- commit('SET_AVATAR', userInfo.avatar)
|
|
|
- resolve(response)
|
|
|
- */
|
|
|
-
|
|
|
-
|
|
|
// 登录
|
|
|
mLogin({
|
|
|
commit
|
|
|
}, userInfo) {
|
|
|
-
|
|
|
return new Promise((resolve, reject) => {
|
|
|
var username = userInfo.username;
|
|
|
api.login(userInfo).then(response => {
|
|
|
if (response.data.state == 200) {
|
|
|
const result = response.data
|
|
|
const userInfo = response.data.data
|
|
|
-
|
|
|
- // uni.setStorageSync(USER_INFO,userInfo);
|
|
|
- console.log("userInfo", userInfo)
|
|
|
commit('SET_TOKEN', "")
|
|
|
commit('SET_AVATAR', null)
|
|
|
commit('SET_NAME', userInfo)
|
|
|
-
|
|
|
- let params = {};
|
|
|
- params.login_state = userInfo;
|
|
|
- params.client_id = "ibps";
|
|
|
+ let params = {
|
|
|
+ login_state: userInfo,
|
|
|
+ client_id: 'ibps'
|
|
|
+ }
|
|
|
//授权第二步
|
|
|
api.authorize(params).then(response2 => {
|
|
|
- //console.log(response2)
|
|
|
- console.log(33)
|
|
|
if (response.data.state == 200) {
|
|
|
- let auparams = {};
|
|
|
- auparams.authorize_code = response2.data.data;
|
|
|
- auparams.client_id = "ibps";
|
|
|
- //写死的client_secret
|
|
|
- auparams.client_secret =
|
|
|
- "58b65297-3467-0859-8337-8cbaf81ef68a"
|
|
|
-
|
|
|
- auparams.grant_type = "authorization_code"
|
|
|
+ let auparams = {
|
|
|
+ authorize_code: response2.data.data,
|
|
|
+ client_id: 'ibps',
|
|
|
+ client_secret: '58b65297-3467-0859-8337-8cbaf81ef68a',
|
|
|
+ grant_type: 'authorization_code'
|
|
|
+ }
|
|
|
//授权第三步
|
|
|
api.authentication(auparams).then(res => {
|
|
|
if (res.data.state == 200) {
|
|
|
@@ -95,32 +74,59 @@ export default new Vuex.Store({
|
|
|
//获取用户信息
|
|
|
api.context(username).then(res => {
|
|
|
if (res.data.state == 200) {
|
|
|
-
|
|
|
let info = res.data
|
|
|
- .data;
|
|
|
+ .data
|
|
|
uni.setStorageSync(
|
|
|
- USER_INFO, info);
|
|
|
-
|
|
|
+ USER_INFO, info
|
|
|
+ )
|
|
|
+ if (info.user.id ==
|
|
|
+ '1100364672239927296' ||
|
|
|
+ info.user.id ==
|
|
|
+ '1100468240921919488'
|
|
|
+ ) {
|
|
|
+ uni.setStorageSync(
|
|
|
+ 'administrator',
|
|
|
+ true)
|
|
|
+ resolve(res)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (info.org.id !=
|
|
|
+ '1041786072788369408'
|
|
|
+ ) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '该账户不是客户账号',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ reject(res)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ uni.setStorageSync(
|
|
|
+ 'administrator',
|
|
|
+ false)
|
|
|
resolve(res)
|
|
|
} else {
|
|
|
- resolve(res)
|
|
|
+ reject(res)
|
|
|
}
|
|
|
})
|
|
|
- resolve(res)
|
|
|
} else {
|
|
|
- resolve(res)
|
|
|
+ reject(res)
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
- resolve(response2)
|
|
|
+ reject(response2)
|
|
|
}
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
- resolve(response)
|
|
|
+ uni.showToast({
|
|
|
+ title: response.data.cause,
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ })
|
|
|
+ reject(response)
|
|
|
}
|
|
|
}).catch(error => {
|
|
|
- console.log("catch===>response")
|
|
|
reject(error)
|
|
|
})
|
|
|
})
|
|
|
@@ -147,7 +153,6 @@ export default new Vuex.Store({
|
|
|
params.client_id = "ibps";
|
|
|
|
|
|
api.authorize(params).then(response2 => {
|
|
|
- //console.log(response2)
|
|
|
if (response.data.state == 200) {
|
|
|
let auparams = {};
|
|
|
auparams.authorize_code = response2.data.data;
|
|
|
@@ -175,14 +180,10 @@ export default new Vuex.Store({
|
|
|
resolve(response)
|
|
|
}
|
|
|
})
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
} else {
|
|
|
resolve(response)
|
|
|
}
|
|
|
}).catch(error => {
|
|
|
- console.log("catch===>response", error)
|
|
|
reject(error)
|
|
|
})
|
|
|
})
|
|
|
@@ -194,17 +195,6 @@ export default new Vuex.Store({
|
|
|
return new Promise((resolve, reject) => {
|
|
|
api.phoneNoLogin(userInfo).then(response => {
|
|
|
if (response.data.state == 200) {
|
|
|
-
|
|
|
- /* const result = response.data.result
|
|
|
- const userInfo = result.userInfo
|
|
|
- uni.setStorageSync(ACCESS_TOKEN,result.token);
|
|
|
- uni.setStorageSync(USER_INFO,userInfo);
|
|
|
- commit('SET_TOKEN', result.token)
|
|
|
- commit('SET_NAME', { username: userInfo.username,realname: userInfo.realname})
|
|
|
- commit('SET_AVATAR', userInfo.avatar)
|
|
|
- resolve(response)
|
|
|
- */
|
|
|
-
|
|
|
const result = response.data
|
|
|
const userInfo = response.data.data
|
|
|
uni.setStorageSync(ACCESS_TOKEN, "ashdgajd");
|
|
|
@@ -220,7 +210,6 @@ export default new Vuex.Store({
|
|
|
|
|
|
|
|
|
api.authorize(params).then(response2 => {
|
|
|
- //console.log(response2)
|
|
|
if (response.data.state == 200) {
|
|
|
let auparams = {};
|
|
|
auparams.authorize_code = response2.data.data;
|
|
|
@@ -268,11 +257,7 @@ export default new Vuex.Store({
|
|
|
let logoutToken = state.token;
|
|
|
commit('SET_TOKEN', '')
|
|
|
uni.removeStorageSync(ACCESS_TOKEN)
|
|
|
- console.log("退出")
|
|
|
api.logout(logoutToken).then(() => {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
resolve()
|
|
|
}).catch(() => {
|
|
|
resolve()
|
|
|
@@ -306,4 +291,4 @@ export default new Vuex.Store({
|
|
|
},
|
|
|
},
|
|
|
|
|
|
-})
|
|
|
+})
|