登录流程接口对接

This commit is contained in:
唐明明
2022-01-06 14:54:22 +08:00
parent 4709ff0c4a
commit 53a6f0b149
10 changed files with 202 additions and 60 deletions

View File

@@ -2,8 +2,10 @@
<view class="content">
<!-- tool -->
<view class="tool-flex">
<view class="tool-flex-item">关闭</view>
<view class="tool-flex-item" @click="onKeyAuth()">一键登录</view>
<view class="tool-flex-item" @click="$Router.back()">
<uni-icons type="closeempty" size="22" color="#666"></uni-icons>
</view>
<view class="tool-flex-item" @click="onKeyAuth()" v-if="$Route.query.keyPhone === '1'">一键登录</view>
</view>
<!-- 欢迎使用 -->
<view class="header">
@@ -32,7 +34,7 @@
<script>
import { getSms, smsAuth } from '@/apis/interfaces/auth'
// import userAuth from '@/public/userAuth'
import userAuth from '@/public/userAuth'
export default {
data() {
return {
@@ -41,19 +43,13 @@
smsTime : 60,
getSms : false
}
},
onShow(){
this.parentId = getApp().globalData.parentId
},
methods: {
// 用户登录
login() {
smsAuth({
mobileNo : this.phone,
code : this.code,
parent_id : this.parentId
code : this.code
}).then(res => {
this.$store.commit('setToken', res.token_type + ' ' + res.access_token)
if(this.$Route.toName){
@@ -96,36 +92,9 @@
},
// 一键登录
onKeyAuth(){
uni.showLoading({
title: "加载中..."
})
uni.preLogin({
provider: 'univerify',
success : res=> {
let userLogin = new userAuth()
userLogin.keyLogin().then(res => {
if(this.$Route.toName){
this.$Router.back()
}else{
this.$Router.replaceAll({name: 'Index'})
}
}).catch(err => {
uni.showToast({
title: err.message,
icon : 'none'
})
})
},
fail : err=> {
uni.showToast({
title: '当前设备环境暂不支持一键登录',
icon : 'none'
})
},
complete() {
uni.hideLoading()
}
})
const Auth = new userAuth()
this.$Router.back()
Auth.Login()
}
}
}