标题
- 技术栈:
- 项目亮点:
1.使用mixins封装登录;
import * as AuthApi from '../api/auth' //引入封装的接口
const app = getApp()
export default {
methods: {
async getUserInfo(res) {
const { sessionId } = app.globalData
if (!sessionId) {
uni.showToast({
title: '缺少sessionId',
icon: 'none'
})
return
}
const data = {
encryptedData: res.encryptedData,
iv: res.iv,
rawData: res.rawData,
sessionId: sessionId,
signature: res.signature
}
try {
//接口,
const info = await AuthApi.userinfo(data)
app.globalData.userInfo = info
console.log('AuthApi.getUserInfo:', info)
return info
} catch (e) {
await app.setMpSession()
uni.showToast({
title: '授权失败请重试',
icon: 'none'
})
}
}
}
}