一键登录流程
This commit is contained in:
@@ -58,11 +58,21 @@ const secretService = (name) =>{
|
||||
})
|
||||
}
|
||||
|
||||
// 一键登录
|
||||
const keyAuth = (data) => {
|
||||
return request({
|
||||
url: 'user/socialite/login/unicloud/app',
|
||||
method: 'POST',
|
||||
data: data
|
||||
}, true)
|
||||
}
|
||||
|
||||
export {
|
||||
smsAuth,
|
||||
getInvitationSms,
|
||||
getSms,
|
||||
userFigure,
|
||||
createUser,
|
||||
secretService
|
||||
secretService,
|
||||
keyAuth
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<view class="auth-agreement">
|
||||
登录即表示同意<navigator hover-class="none" url="/pages/vip/agreement?id=3">用户协议</navigator>和<navigator hover-class="none" url="/pages/vip/agreement?id=4">隐私政策</navigator>
|
||||
</view>
|
||||
<view class="auth-other">
|
||||
<view class="auth-other" v-if="isKeyAuth">
|
||||
<button @click="login('Akey')">使用本机号码一键登录</button>
|
||||
</view>
|
||||
</view>
|
||||
@@ -32,7 +32,8 @@
|
||||
<script>
|
||||
import {
|
||||
smsAuth,
|
||||
getInvitationSms
|
||||
getInvitationSms,
|
||||
keyAuth
|
||||
} from '@/apis/interfaces/auth.js'
|
||||
export default {
|
||||
data() {
|
||||
@@ -42,11 +43,18 @@
|
||||
parentId : '',
|
||||
getSms : false,
|
||||
sendCode : '获取验证码',
|
||||
isShowParent: false
|
||||
isShowParent: false,
|
||||
isKeyAuth : false
|
||||
};
|
||||
},
|
||||
created() {
|
||||
|
||||
created () {
|
||||
// 预登录
|
||||
uni.preLogin({
|
||||
provider: 'univerify',
|
||||
success: res => {
|
||||
this.isKeyAuth = true
|
||||
}
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
// 获取验证码
|
||||
@@ -95,14 +103,7 @@
|
||||
code : this.code,
|
||||
parent_id : this.parentId
|
||||
}).then((res) => {
|
||||
this.$store.commit('setToken', res.token_type + ' ' + res.access_token);
|
||||
if(res.is_new){
|
||||
uni.setStorageSync('isnew', 0)
|
||||
this.$Router.replace({name: 'AuthRole'})
|
||||
return
|
||||
}
|
||||
uni.setStorageSync('isnew', 1)
|
||||
this.$Router.pushTab({name: 'Life'})
|
||||
this.setAuthToken(res.token_type + ' ' + res.access_token, res.is_new)
|
||||
uni.hideLoading()
|
||||
}).catch((err) => {
|
||||
uni.showToast({
|
||||
@@ -138,13 +139,39 @@
|
||||
checkedImage: require('@/static/icon/checked-icon.png')
|
||||
}
|
||||
},
|
||||
success: res => {
|
||||
console.log(res)
|
||||
success: Result => {
|
||||
if(Result.errMsg === 'login:ok'){
|
||||
let {access_token, openid} = Result.authResult
|
||||
keyAuth({
|
||||
access_token,
|
||||
openid
|
||||
}).then(res => {
|
||||
this.setAuthToken(res.token_type + ' ' + res.access_token, res.is_new)
|
||||
uni.closeAuthView()
|
||||
}).catch(err => {
|
||||
uni.showToast({
|
||||
title: '登录失败:' + err.message,
|
||||
icon : 'none'
|
||||
})
|
||||
uni.closeAuthView()
|
||||
})
|
||||
}
|
||||
},
|
||||
fail: err => {
|
||||
console.log(err)
|
||||
}
|
||||
})
|
||||
},
|
||||
// setToken
|
||||
setAuthToken(token, isNew){
|
||||
this.$store.commit('setToken', token);
|
||||
if(isNew){
|
||||
uni.setStorageSync('isnew', 0)
|
||||
this.$Router.replace({name: 'AuthRole'})
|
||||
return
|
||||
}
|
||||
uni.setStorageSync('isnew', 1)
|
||||
this.$Router.pushTab({name: 'Life'})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +90,6 @@
|
||||
success : e => {
|
||||
if(e.confirm){
|
||||
this.$store.commit('setToken', '');
|
||||
this.$store.commit('setIsNew', 0);
|
||||
this.$Router.replaceAll({name: 'Auth'});
|
||||
}
|
||||
}
|
||||
|
||||
7651
unpackage/dist/dev/app-plus/app-service.js
vendored
7651
unpackage/dist/dev/app-plus/app-service.js
vendored
File diff suppressed because one or more lines are too long
154
unpackage/dist/dev/app-plus/app-view.js
vendored
154
unpackage/dist/dev/app-plus/app-view.js
vendored
File diff suppressed because one or more lines are too long
2
unpackage/dist/dev/app-plus/manifest.json
vendored
2
unpackage/dist/dev/app-plus/manifest.json
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user