feat: 蓝星登录
This commit is contained in:
@@ -49,6 +49,9 @@
|
||||
<view class="remember-wrap">
|
||||
<u-checkbox v-model="remember"><span class="remember-text">记住账号密码</span></u-checkbox>
|
||||
</view>
|
||||
<view class="remember-wrap">
|
||||
<u-checkbox v-model="isCertify"><span class="remember-text">是否认证</span></u-checkbox>
|
||||
</view>
|
||||
<view class="loginBtnBox">
|
||||
<u-button @click="login" type="primary" :loading="loading">{{ loading ? "登录中...":"登录"}}
|
||||
</u-button>
|
||||
@@ -119,6 +122,7 @@
|
||||
<script>
|
||||
import {
|
||||
login,
|
||||
socialLogin,
|
||||
getPermissionInfo,
|
||||
getByName,
|
||||
getCallback,
|
||||
@@ -134,10 +138,12 @@
|
||||
useUserStore
|
||||
} from '@/store/modules/user'
|
||||
import logoImg from '@/static/logo.png'
|
||||
let unique = 0
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
remember: false,
|
||||
isCertify: false,
|
||||
logoImg,
|
||||
imgUrl: '',
|
||||
loading: false,
|
||||
@@ -508,7 +514,19 @@
|
||||
// jnpf_ticket: this.ssoTicket,
|
||||
// grant_type: 'password',
|
||||
// }
|
||||
let query = {
|
||||
if(this.isCertify){
|
||||
// 认证登录
|
||||
this.certifyLogin()
|
||||
}else {
|
||||
this.getLogin()
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
},
|
||||
// 普通登录
|
||||
getLogin(){
|
||||
let query = {
|
||||
tenantName: this.formData.tenantName,
|
||||
username: this.formData.username,
|
||||
password: this.formData.password,
|
||||
@@ -555,8 +573,53 @@
|
||||
this.changeCode()
|
||||
this.loading = false
|
||||
})
|
||||
}
|
||||
},
|
||||
// 认证登录
|
||||
certifyLogin(){
|
||||
lx.biz.getAuthCode({
|
||||
appId: "8889088-16130048", // AppID
|
||||
success: (res) => {
|
||||
console.log('免登授权码:', res.authCode)
|
||||
this.exchangeToken(res.authCode)
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('获取免登授权码失败:', err)
|
||||
uni.showToast({
|
||||
title: '免登失败,请重试',
|
||||
icon: 'none'
|
||||
})
|
||||
this.loading = false
|
||||
}
|
||||
})
|
||||
},
|
||||
async exchangeToken(authCode) {
|
||||
try {
|
||||
const type = '110'
|
||||
const code = authCode
|
||||
const state = this.uuid()
|
||||
const res = await socialLogin(type, code, state)
|
||||
|
||||
const userStore = useUserStore()
|
||||
// 存储Token和用户信息
|
||||
userStore.setToken(res)
|
||||
uni.switchTab({
|
||||
url: '/pages/index/indexWork'
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('换取Token失败:', err)
|
||||
uni.showToast({
|
||||
title: '登录失败,请重试',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
uuid() {
|
||||
const time = Date.now()
|
||||
const random = Math.floor(Math.random() * 1000000000)
|
||||
unique++
|
||||
return 'qrcode_' + random + unique + String(time)
|
||||
},
|
||||
ssoLogin() {
|
||||
getTicket().then(res => {
|
||||
|
||||
Reference in New Issue
Block a user