.
This commit is contained in:
parent
00031ab2b6
commit
d8eba3c7c4
12
api/login.js
12
api/login.js
@ -1,7 +1,7 @@
|
|||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
|
|
||||||
// 登录方法
|
// 登录方法
|
||||||
export function login(username, password, code, uuid) {
|
export function login(username, password, code, uuid, forceLogin = false) {
|
||||||
return request({
|
return request({
|
||||||
url: '/auth/loginApp',
|
url: '/auth/loginApp',
|
||||||
headers: {
|
headers: {
|
||||||
@ -12,7 +12,8 @@ export function login(username, password, code, uuid) {
|
|||||||
username,
|
username,
|
||||||
password,
|
password,
|
||||||
code,
|
code,
|
||||||
uuid
|
uuid,
|
||||||
|
forceLogin
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -26,7 +27,7 @@ export function getCodePhone(data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//手机号登录
|
//手机号登录
|
||||||
export function phoneLogin(mobilePhone,code, uuid,appType) {
|
export function phoneLogin(mobilePhone, code, uuid, appType, forceLogin = false) {
|
||||||
return request({
|
return request({
|
||||||
url: '/auth/loginPhone',
|
url: '/auth/loginPhone',
|
||||||
headers: {
|
headers: {
|
||||||
@ -34,10 +35,11 @@ export function phoneLogin(mobilePhone,code, uuid,appType) {
|
|||||||
},
|
},
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: {
|
data: {
|
||||||
mobilePhone,
|
username,
|
||||||
|
password,
|
||||||
code,
|
code,
|
||||||
uuid,
|
uuid,
|
||||||
appType
|
forceLogin
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -510,7 +510,7 @@
|
|||||||
</custom-popup>
|
</custom-popup>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import plugins from "../../plugins";
|
import plugins from "@/plugins";
|
||||||
import * as DevOpsApi from "@/api/dev-ops/index.js"
|
import * as DevOpsApi from "@/api/dev-ops/index.js"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -77,7 +77,7 @@
|
|||||||
onLoad,
|
onLoad,
|
||||||
} from "@dcloudio/uni-app"
|
} from "@dcloudio/uni-app"
|
||||||
import store from '@/store'
|
import store from '@/store'
|
||||||
import plugin from "@/plugins"
|
import plugins from "@/plugins";
|
||||||
import {
|
import {
|
||||||
loginHandle
|
loginHandle
|
||||||
} from '@/utils/login.js'
|
} from '@/utils/login.js'
|
||||||
@ -251,7 +251,8 @@
|
|||||||
url: "Login",
|
url: "Login",
|
||||||
data: {
|
data: {
|
||||||
loginName: loginObj.loginName,
|
loginName: loginObj.loginName,
|
||||||
password: loginObj.password
|
password: loginObj.password,
|
||||||
|
forceLogin: loginObj.forceLogin || false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -260,7 +261,8 @@
|
|||||||
data: {
|
data: {
|
||||||
mobilePhone: loginObj.phone,
|
mobilePhone: loginObj.phone,
|
||||||
uuid: loginObj.uuid,
|
uuid: loginObj.uuid,
|
||||||
code: loginObj.code
|
code: loginObj.code,
|
||||||
|
forceLogin: loginObj.forceLogin || false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -283,9 +285,26 @@
|
|||||||
url: '/pages/index',
|
url: '/pages/index',
|
||||||
});
|
});
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
proxy.$toast(error);
|
if (error === 'error409') {
|
||||||
|
forceLogin();
|
||||||
|
} else {
|
||||||
|
proxy.$toast(error);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function forceLogin() {
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: '该账号已登录,是否强制登录?',
|
||||||
|
success: function(res) {
|
||||||
|
if (res.confirm) {
|
||||||
|
loginForm.value.forceLogin = true;
|
||||||
|
handleLogin();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
@ -67,8 +67,9 @@ const user = {
|
|||||||
const password = userInfo.password
|
const password = userInfo.password
|
||||||
const code = userInfo.code
|
const code = userInfo.code
|
||||||
const uuid = userInfo.uuid
|
const uuid = userInfo.uuid
|
||||||
|
const forceLogin = userInfo.forceLogin || false
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
login(loginName, password, code, uuid)
|
login(loginName, password, code, uuid, forceLogin)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
setToken(res.data.access_token)
|
setToken(res.data.access_token)
|
||||||
commit("SET_TOKEN", res.data.access_token)
|
commit("SET_TOKEN", res.data.access_token)
|
||||||
@ -98,8 +99,9 @@ const user = {
|
|||||||
const mobilePhone = data.mobilePhone;
|
const mobilePhone = data.mobilePhone;
|
||||||
const code = data.code;
|
const code = data.code;
|
||||||
const uuid = data.uuid;
|
const uuid = data.uuid;
|
||||||
|
const forceLogin = userInfo.forceLogin || false
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
phoneLogin(mobilePhone,code, uuid,2)
|
phoneLogin(mobilePhone, code, uuid, 2, forceLogin)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
setToken(res.data.access_token)
|
setToken(res.data.access_token)
|
||||||
commit("SET_TOKEN", res.data.access_token)
|
commit("SET_TOKEN", res.data.access_token)
|
||||||
|
@ -66,6 +66,8 @@ const request = config => {
|
|||||||
}
|
}
|
||||||
} else if (code === 601) {
|
} else if (code === 601) {
|
||||||
reject(res.data)
|
reject(res.data)
|
||||||
|
} else if (code === 409) {
|
||||||
|
reject("error409")
|
||||||
} else if (code !== 200) {
|
} else if (code !== 200) {
|
||||||
// toast(msg)
|
// toast(msg)
|
||||||
reject(msg)
|
reject(msg)
|
||||||
|
Loading…
Reference in New Issue
Block a user