|
@@ -14,7 +14,9 @@ import {
|
|
|
let storeBindings
|
|
|
App({
|
|
|
async onLaunch() {
|
|
|
+ // #if MP
|
|
|
this.updateApplet()
|
|
|
+ // #endif
|
|
|
this.checkIsIos()
|
|
|
this.getNavbarInfo()
|
|
|
await loginLog()
|
|
@@ -60,30 +62,54 @@ App({
|
|
|
getApp().callBack();
|
|
|
}
|
|
|
} else {
|
|
|
- wx.getMiniProgramCode({
|
|
|
+ this.getWXCode().then(async res => {
|
|
|
+ if (res.code) {
|
|
|
+ // 获取openid
|
|
|
+ let data = {
|
|
|
+ code: res.code,
|
|
|
+ userChannelCode
|
|
|
+ }
|
|
|
+ if (shareUid != 'undefined' && shareUid) {
|
|
|
+ data.shareUid = shareUid
|
|
|
+ }
|
|
|
+ let userRes = await userLogin(data)
|
|
|
+ this.setUser(userRes.data)
|
|
|
+ wx.setStorageSync('uid', userRes.data.uid)
|
|
|
+ wx.setStorageSync('user', userRes.data)
|
|
|
+ this.globalData.userInfo = userRes.data
|
|
|
+ this.deviceLogin()
|
|
|
+ if (getApp().callBack) {
|
|
|
+ getApp().callBack(userRes);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getWXCode() {
|
|
|
+ return new Promise((reslove, reject) => {
|
|
|
+ // #if MP
|
|
|
+ wx.login({
|
|
|
success: async (res) => {
|
|
|
if (res.code) {
|
|
|
- // 获取openid
|
|
|
- let data = {
|
|
|
- code: res.code,
|
|
|
- userChannelCode
|
|
|
- }
|
|
|
- if (shareUid != 'undefined' && shareUid) {
|
|
|
- data.shareUid = shareUid
|
|
|
- }
|
|
|
- let userRes = await userLogin(data)
|
|
|
- this.setUser(userRes.data)
|
|
|
- wx.setStorageSync('uid', userRes.data.uid)
|
|
|
- wx.setStorageSync('user', userRes.data)
|
|
|
- this.globalData.userInfo = userRes.data
|
|
|
- this.deviceLogin()
|
|
|
- if (getApp().callBack) {
|
|
|
- getApp().callBack(userRes);
|
|
|
- }
|
|
|
+ reslove(res)
|
|
|
+ } else {
|
|
|
+ reject(res.errMsg)
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
- }
|
|
|
+ // #elif ANDROID
|
|
|
+ wx.getMiniProgramCode({
|
|
|
+ success(res) {
|
|
|
+ if (res.code) {
|
|
|
+ reslove(res)
|
|
|
+ } else {
|
|
|
+ console.log('获取小程序 code 失败!' + res.errMsg)
|
|
|
+ reject(res.errMsg)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // #endif
|
|
|
+ })
|
|
|
},
|
|
|
checkIsIos: function () {
|
|
|
wx.getSystemInfo({
|