1234567891011121314151617181920212223242526272829303132333435363738394041 |
- const app = getApp(),
- {
- globalData: {
- util: {
- regeneratorRuntime,
- api: { login },
- showTip,
- request: {
- post
- },
- navigateBack
- }
- }
- } = app
- Page({
- data: {
- tab: ['微信授权登录']
- },
- onLoad() {
- const identity = wx.getStorageSync("identity") | 0
- this.setData({
- identity: this.identity = identity
- })
- },
- select: function ({ currentTarget: { dataset: { identity } } }) {
- this.setData({ identity })
- },
- async wxLogin({ detail: { userInfo } }) {
- wx.setStorageSync('userInfo', userInfo)
- // const { data: { identity = 0 } } = this,
- // code = await new Promise(_ => wx.login({ success: ({ code }) => _(code) })),
- // { userId, _err } = await post(login, { userInfo: { ...userInfo, identity }, code });
- // if (_err) return _err.status && showTip('登录失败');
- // showTip('登录成功')
- // wx.setStorageSync('userId', app.globalData.userId = userId)
- // identity != this.identity && wx.setStorageSync('identity', identity)
- navigateBack()
- },
- })
|