Merge remote-tracking branch 'origin/master'

This commit is contained in:
zhaotianfeng 2024-09-24 19:48:11 +08:00
commit 0b3558b3d2
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,25 +88,40 @@ export default {
mounted() {
},
created(){
//token
removeToken()
/*2.微信公众平台自动登录*/
let code = this.getUrlCode('code')
if (code !== null && code !== "") {
//
this.getOpenidAndUserinfo(code)
} else {
uni.showToast({
title: '未获取到授权信息,请重新进入!!',
icon: 'none'
})
}
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 !== "") {
//
this.getOpenidAndUserinfo(code)
} else {
uni.showToast({
title: '未获取到授权信息,请重新进入!!',
icon: 'none'
})
}
},
/**
* 微信自动登录
* @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)
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 {
setToken(res.data.accessToken)
uni.reLaunch({
url: '/pages/home/home'
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'
// })
// }
})
}