bayi пре 1 година
родитељ
комит
d39e563289
5 измењених фајлова са 39 додато и 5 уклоњено
  1. 2 0
      api/user.js
  2. 35 2
      app.js
  3. 0 1
      components/navigationBar/index.js
  4. 1 1
      pages/index/index.js
  5. 1 1
      utils/filter.wxs

+ 2 - 0
api/user.js

@@ -37,4 +37,6 @@ module.exports = {
     bindPhone: data => request('/v3/user/bindMobile', 'post', data),
     // 获取邀请的用户列表
     getInviteList: data => request('/v3/user/invite', 'get', data),
+    // 绑定音箱端
+    bindDevice: data => request('/v3/user/deviceCode', 'post', data),
 }

+ 35 - 2
app.js

@@ -2,7 +2,8 @@
 import {
     loginLog,
     userLogin,
-    getMyInfo
+    getMyInfo,
+    bindDevice
 } from '~/api/user'
 import {
     createStoreBindings
@@ -26,11 +27,12 @@ App({
             })
         }
         let shareUid = options.query.uid || ''
-        console.log(shareUid,'shareUid');
+        console.log(shareUid, 'shareUid');
         let uid = wx.getStorageSync('uid')
         if (uid) {
             let userInfo = await getMyInfo()
             this.setUser(userInfo.user)
+            this.deviceLogin()
             if (getApp().callBack) {
                 getApp().callBack();
             }
@@ -52,6 +54,7 @@ App({
                     wx.setStorageSync('uid', userRes.data.uid)
                     wx.setStorageSync('user', userRes.data)
                     this.globalData.userInfo = userRes.data
+                    this.deviceLogin()
                     if (getApp().callBack) {
                         getApp().callBack(userRes);
                     }
@@ -86,6 +89,36 @@ App({
             }
         })
     },
+    // 音箱端登录
+    deviceLogin() {
+        let {
+            scene,
+            query
+        } = wx.getLaunchOptionsSync()
+        let types = [1047, 1048]
+        var gradeObj = Object.keys({
+            "PRESCHOOL": "学前班",
+            "PRIMARY_FIRST_GRADE": "一年级",
+            "PRIMARY_SECOND_GRADE": "二年级",
+            "PRIMARY_THREE_GRADE": "三年级",
+            "PRIMARY_SENIOR_GRADE": "四年级",
+            "PRIMARY_FIVE_GRADE": "五年级",
+            "PRIMARY_SIX_GRADE": "六年级",
+        })
+        // 1047	扫描小程序码	1048长按图片识别小程序码
+        if (query.scene && types.includes(scene)) {
+            let params = decodeURIComponent(query.scene).split('&')
+            console.log('eee', params, gradeObj[params[2]]);
+            bindDevice({
+                deviceCode: params[0],
+                channelCode: params[1],
+                grade: gradeObj[params[2]],
+                uid: wx.getStorageSync('uid')
+            }).then(res => {
+                console.log(res);
+            })
+        }
+    },
     getNavbarInfo() {
         // 获取系统信息
         const systemInfo = wx.getSystemInfoSync();

+ 0 - 1
components/navigationBar/index.js

@@ -109,7 +109,6 @@ Component({
       let res = await setUserInfo({
         grade
       }, 'put')
-      console.log(res);
       this.setUser(res)
       this.closeGrade()
       setTimeout(() => {

+ 1 - 1
pages/index/index.js

@@ -28,7 +28,7 @@ Page({
         categoryList: [],
         bannerList: []
     },
-    onLoad() {
+    onLoad(options) {
         this.getLocUserInfo()
         if (Object.keys(this.data.userInfo).length > 0) {
             this.requestAgain()

+ 1 - 1
utils/filter.wxs

@@ -38,13 +38,13 @@ function gradeFilter(grade) {
         return '暂无'
     }
     var gradeObj = {
+        "PRESCHOOL": "学前班",
         "PRIMARY_FIRST_GRADE": "一年级",
         "PRIMARY_SECOND_GRADE": "二年级",
         "PRIMARY_THREE_GRADE": "三年级",
         "PRIMARY_SENIOR_GRADE": "四年级",
         "PRIMARY_FIVE_GRADE": "五年级",
         "PRIMARY_SIX_GRADE": "六年级",
-        "PRESCHOOL": "学前班",
     }
     return gradeObj[grade]
 }