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 data
}) })
} }
export function loginAppuserName(data) {
return request({
'url': '/userClient/weChat/login',
headers: {
isToken: false
},
method: 'post',
timeout: 20000,
data
})
}
// 使用租户域名(标识),获得租户编号 // 使用租户域名(标识),获得租户编号
export function getTenantIdByWebsite(website) { export function getTenantIdByWebsite(website) {

View File

@ -37,10 +37,11 @@
<script> <script>
import request from '../../utils/request'; import request from '../../utils/request';
import { import {
loginApp, loginAppuserName,
} from '@/api/login.js'; } from '@/api/login.js';
import { import {
setToken, setToken,
getToken,
setTenantId, setTenantId,
removeToken removeToken
} from '@/utils/auth.js' } from '@/utils/auth.js'
@ -87,25 +88,40 @@ export default {
mounted() { mounted() {
}, },
created(){ created(){
//token this.checkIfLogin()
removeToken()
/*2.微信公众平台自动登录*/
let code = this.getUrlCode('code')
if (code !== null && code !== "") {
//
this.getOpenidAndUserinfo(code)
} else {
uni.showToast({
title: '未获取到授权信息,请重新进入!!',
icon: 'none'
})
}
}, },
onShow() { onShow() {
}, },
methods: { 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 * @param {Object} code 用户code
@ -173,18 +189,36 @@ export default {
password: this.wrod, password: this.wrod,
type: 0 type: 0
} }
loginApp(data).then(res => { loginAppuserName(data).then(res => {
if (res.data.needMobile === "1") { if (res.code==200) {
uni.navigateTo({ if(res.data.hasOwnProperty("accessToken")){
url: '/pages/login/bindPhoe' setToken(res.data.accessToken)
}) uni.reLaunch({
uni.setStorageSync('validaCodeToken', res.data.accessToken) url: '/pages/home/home'
})
}else{
uni.showToast({
title: '登录失败',
icon: 'none'
})
}
} else { } else {
setToken(res.data.accessToken) uni.showToast({
uni.reLaunch({ title: res.msg,
url: '/pages/home/home' 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'
// })
// }
}) })
} }