|
@@ -26,7 +26,24 @@ App({
|
|
|
actions: ['setUser']
|
|
|
})
|
|
|
}
|
|
|
- let shareUid = options.query.uid || ''
|
|
|
+ let {
|
|
|
+ path,
|
|
|
+ scene,
|
|
|
+ query
|
|
|
+ } = wx.getEnterOptionsSync()
|
|
|
+
|
|
|
+ let types = [1047, 1048]
|
|
|
+ if (query.scene && types.includes(scene) && path == 'pages/index/index') {
|
|
|
+ let params = decodeURIComponent(query.scene).split('&')
|
|
|
+ if (params.length == 1) {
|
|
|
+ this.login(params[0])
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ let shareUid = options.query.uid || ''
|
|
|
+ this.login(shareUid)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ async login(shareUid) {
|
|
|
let uid = wx.getStorageSync('uid')
|
|
|
if (uid) {
|
|
|
let userInfo = await getMyInfo()
|
|
@@ -37,30 +54,27 @@ App({
|
|
|
getApp().callBack();
|
|
|
}
|
|
|
} else {
|
|
|
- this.login(shareUid)
|
|
|
- }
|
|
|
- },
|
|
|
- login(shareUid) {
|
|
|
- wx.login({
|
|
|
- success: async (res) => {
|
|
|
- if (res.code) {
|
|
|
- // 获取openid
|
|
|
- let data = {
|
|
|
- code: res.code,
|
|
|
- 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);
|
|
|
+ wx.login({
|
|
|
+ success: async (res) => {
|
|
|
+ if (res.code) {
|
|
|
+ // 获取openid
|
|
|
+ let data = {
|
|
|
+ code: res.code,
|
|
|
+ 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);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- })
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
checkIsIos: function () {
|
|
|
wx.getSystemInfo({
|
|
@@ -109,15 +123,17 @@ App({
|
|
|
})
|
|
|
if (query.scene && types.includes(scene) && path == 'pages/index/index') {
|
|
|
let params = decodeURIComponent(query.scene).split('&')
|
|
|
- console.log('音箱端参数', params);
|
|
|
- bindDevice({
|
|
|
- deviceCode: params[0],
|
|
|
- channelCode: params[1],
|
|
|
- grade: gradeObj[params[2]],
|
|
|
- uid: wx.getStorageSync('uid')
|
|
|
- }).then(res => {
|
|
|
- console.log(res);
|
|
|
- })
|
|
|
+ if (params.length > 1) {
|
|
|
+ console.log('音箱端参数', params);
|
|
|
+ bindDevice({
|
|
|
+ deviceCode: params[0],
|
|
|
+ channelCode: params[1],
|
|
|
+ grade: gradeObj[params[2]],
|
|
|
+ uid: wx.getStorageSync('uid')
|
|
|
+ }).then(res => {
|
|
|
+ console.log(res);
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
getNavbarInfo() {
|