用户登录流程开发接口对接

This commit is contained in:
唐明明
2021-08-09 17:20:38 +08:00
parent 3c3d946eb5
commit bfea54eb8f
37 changed files with 8399 additions and 8539 deletions

View File

@@ -1,84 +0,0 @@
/**
* Web唐明明
* 匆匆数载恍如梦,岁月迢迢华发增。
* 碌碌无为枉半生,一朝惊醒万事空。
* moduleName: 一键登录
*/
import { auth } from '@/apis/interfaces/auth'
import store from '@/store/index'
import { router } from '@/router'
class keyPhone {
constructor(config) {
this.config = {
fullScreen: true,
authButton: {
normalColor: "#c82626",
borderRadius: 0
},
buttons: {
list: [{
provider: "微信",
iconPath: "/static/icons/wechat.png"
}]
},
otherLoginButton: {
borderColor: "#c82626",
title: "其他手机号码登录",
borderRadius: 0,
textColor: "#c82626"
},
privacyTerm: {
privacyItems: [{
url: "https://baidu.com",
title: "用户服务协议"
}]
}
}
}
// 一键登录
keyAuth() {
return new Promise((resolve, reject) => {
wx.login({
provider : 'univerify',
univerifyStyle : this.config,
success : phoneToken => {
let data = phoneToken.authResult
auth({
access_token: data.access_token,
openid : data.openid
}).then(res => {
store.commit('setToken', res.token_type + ' ' + res.access_token)
resolve({
is_new: res.is_new
})
uni.closeAuthView()
})
},
fail : err => {
switch(err.code) {
case '30002':
console.log('其他登录方式')
// router.push({name: 'Sms'})
break
case '30008':
this.wxAuth()
break
}
}
})
})
}
// 微信登录
wxAuth() {
uni.showToast({
title: '微信登录',
icon : 'none'
})
}
}
export default new keyPhone()

33
public/userAuth.js Normal file
View File

@@ -0,0 +1,33 @@
/**
* Web唐明明
* 匆匆数载恍如梦,岁月迢迢华发增。
* 碌碌无为枉半生,一朝惊醒万事空。
* moduleName: 登录
*/
import { router } from '../router'
class userAuth {
constructor() {
}
// 预登录
Login(){
uni.preLogin({
provider: "univerify",
success : res=> {
console.log(res)
},
fail : err=> {
router.push({name: "Login"})
}
})
}
// 一键登录
keyLogin(){
console.log('一键登录')
}
}
export default userAuth