账号密码登录

This commit is contained in:
Vinjor 2024-09-24 19:42:08 +08:00
parent ce148f695b
commit b1fa12ccbf
2 changed files with 68 additions and 23 deletions

View File

@ -67,6 +67,17 @@ export function loginApp(data) {
data
})
}
export function loginAppuserName(data) {
return request({
'url': '/userClient/weChat/login',
headers: {
isToken: false
},
method: 'post',
timeout: 20000,
data
})
}
// 使用租户域名(标识),获得租户编号
export function getTenantIdByWebsite(website) {

View File

@ -37,10 +37,11 @@
<script>
import request from '../../utils/request';
import {
loginApp,
loginAppuserName,
} from '@/api/login.js';
import {
setToken,
getToken,
setTenantId,
removeToken
} from '@/utils/auth.js'
@ -87,9 +88,29 @@ export default {
mounted() {
},
created(){
//token
removeToken()
/*2.微信公众平台自动登录*/
this.checkIfLogin()
},
onShow() {
},
methods: {
checkIfLogin(){
if(getToken()){
//
uni.reLaunch({
url: '/pages/home/home'
})
}else{
//
// this.checkIfCode()
}
},
/**
*判断是否有code
* */
checkIfCode(){
let code = this.getUrlCode('code')
if (code !== null && code !== "") {
//
@ -101,11 +122,6 @@ export default {
})
}
},
onShow() {
},
methods: {
/**
* 微信自动登录
* @param {Object} code 用户code
@ -173,18 +189,36 @@ export default {
password: this.wrod,
type: 0
}
loginApp(data).then(res => {
if (res.data.needMobile === "1") {
uni.navigateTo({
url: '/pages/login/bindPhoe'
})
uni.setStorageSync('validaCodeToken', res.data.accessToken)
} else {
loginAppuserName(data).then(res => {
if (res.code==200) {
if(res.data.hasOwnProperty("accessToken")){
setToken(res.data.accessToken)
uni.reLaunch({
url: '/pages/home/home'
})
}else{
uni.showToast({
title: '登录失败',
icon: 'none'
})
}
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
// if (res.data.needMobile === "1") {
// uni.navigateTo({
// url: '/pages/login/bindPhoe'
// })
// uni.setStorageSync('validaCodeToken', res.data.accessToken)
// } else {
// setToken(res.data.accessToken)
// uni.reLaunch({
// url: '/pages/home/home'
// })
// }
})
}