async otherLogin(e) {
const type = e.target.dataset.logintype
// 使用uni.login获取微信或者qq,微博等第三方登录信息, weixin, qq
await uni.login({provider: type})
// 得到用户信息详情
const userinfo = await uni.getUserInfo({provider: type})
// 把用户信息存入缓存
const result = await uni.setStorage({
key: 'userinfo',
data: userinfo[1].userInfo
})
// 向自己的后端发送信息登录或者注册
uni.request({
url: `${this.service}/users/`,
method: 'POST',
data: userinfo[1].userInfo,
}).then(res => {
// 获取token存入缓存, api的所有请求带上token验证
console.log(res)
}).catch(e => {
console.log(e, 'eee')
})
},
uni-app 第三方登录注册流程
最新推荐文章于 2023-06-26 01:31:12 发布