Browse Source

开发音箱端扫码进入页面

bayi 1 year ago
parent
commit
ae296385a9
6 changed files with 107 additions and 99 deletions
  1. 3 4
      app.js
  2. 4 1
      pages/my/index.less
  3. 3 0
      pages/my/index.wxss
  4. 91 90
      pages/pkPage/index.js
  5. 3 1
      pages/reading/index.js
  6. 3 3
      utils/request.js

+ 3 - 4
app.js

@@ -92,11 +92,10 @@ App({
     // 音箱端登录
     deviceLogin() {
         let {
+            path,
             scene,
             query
         } = wx.getEnterOptionsSync()
-        console.log(scene,
-            query, '启动参数');
         let types = [1047, 1048]
         var gradeObj = Object.keys({
             "PRESCHOOL": "学前班",
@@ -108,9 +107,9 @@ App({
             "PRIMARY_SIX_GRADE": "六年级",
         })
         // 1047	扫描小程序码	1048长按图片识别小程序码
-        if (query.scene && types.includes(scene)) {
+        if (query.scene && types.includes(scene) && path == 'pages/index/index') {
             let params = decodeURIComponent(query.scene).split('&')
-            console.log('音箱端参数', params, gradeObj[params[2]]);
+            console.log('音箱端参数', params);
             bindDevice({
                 deviceCode: params[0],
                 channelCode: params[1],

+ 4 - 1
pages/my/index.less

@@ -202,10 +202,13 @@
     .goodsList {
         position: absolute;
         margin-top: 40rpx;
+        left: 0;
+        padding-left: 20rpx;
         width: 100%;
         height: 310rpx;
         white-space: nowrap;
-
+        box-sizing: border-box;
+        
         .payBox {
             position: relative;
             margin-right: 22rpx;

+ 3 - 0
pages/my/index.wxss

@@ -171,9 +171,12 @@
 .container .goodsList {
   position: absolute;
   margin-top: 40rpx;
+  left: 0;
+  padding-left: 20rpx;
   width: 100%;
   height: 310rpx;
   white-space: nowrap;
+  box-sizing: border-box;
 }
 .container .goodsList .payBox {
   position: relative;

+ 91 - 90
pages/pkPage/index.js

@@ -1,100 +1,101 @@
 import behavior from '~/mixins/video'
 import share from '~/mixins/share'
 import {
-  getreadInfo
+    getreadInfo
 } from '~/api/video'
 import {
-  getPkRecord
+    getPkRecord
 } from '~/api/works'
 Page({
-  behaviors: [behavior, share],
-  data: {
-    videoInfo: '',
-    videoId: '',
-    isShare: false,
-    recordList: [],
-    // 播放的音频
-    audioPath: ''
-  },
-  /**
-   * 生命周期函数--监听页面加载
-   */
-  onLoad(options) {
-    console.log(options, 'options');
-    let videoId = options.videoId
-    this.setData({
-      videoId,
-      isShare: options.isShare
-    })
-    this.getreadInfo(videoId)
-    this.getPkRecord()
-  },
-  async getreadInfo(videoId) {
-    let videoInfo = await getreadInfo(videoId)
-    wx.setNavigationBarTitle({
-      title: !this.data.isShare ? videoInfo.userRead.title : '推荐'
-    })
-    if (videoInfo.userReadExtend.resourcesType == 1) {
-      this.playAudio({
-        currentTarget: {
-          dataset: {
-            id: videoId,
-            audio: videoInfo.userRead.audioPath
-          }
+    behaviors: [behavior, share],
+    data: {
+        videoInfo: '',
+        videoId: '',
+        isShare: false,
+        recordList: [],
+        // 播放的音频
+        audioPath: ''
+    },
+    /**
+     * 生命周期函数--监听页面加载
+     */
+    onLoad(options) {
+        let videoId = null
+        let params = decodeURIComponent(options.scene).split('&')
+        videoId = !options.scene ? options.videoId : params[0]
+        this.setData({
+            videoId,
+            isShare: !options.scene ? options.isShare : true
+        })
+        this.getreadInfo(videoId)
+        this.getPkRecord()
+    },
+    async getreadInfo(videoId) {
+        let videoInfo = await getreadInfo(videoId)
+        wx.setNavigationBarTitle({
+            title: !this.data.isShare ? videoInfo.userRead.title : '推荐'
+        })
+        if (videoInfo.userReadExtend.resourcesType == 1) {
+            this.playAudio({
+                currentTarget: {
+                    dataset: {
+                        id: videoId,
+                        audio: videoInfo.userRead.audioPath
+                    }
+                }
+            })
         }
-      })
-    }
-    this.setData({
-      videoInfo,
-      audioPath: videoInfo.userRead.audioPath,
-      currentId: videoId
-    })
-  },
-  // pkPage页面示范朗读
-  pkPageAudio({
-    detail
-  }) {
-    this.setData({
-      audioPath: detail.currentTarget.dataset.audio,
-    })
-    this.playAudio(detail)
-  },
-  async getPkRecord() {
-    let recordList = await getPkRecord({
-      userReadId: this.data.videoId
-    })
-    this.setData({
-      recordList
-    })
-  },
-  jumpUserInfo({
-    currentTarget
-  }) {
-    wx.navigateTo({
-      url: `/pages/personal/index?uid=${currentTarget.dataset.uid}&type=user`,
-    })
-  },
-  jumpIndex() {
-    wx.switchTab({
-      url: '/pages/index/index',
-    })
-  },
-  addCommentNum() {
-    this.setData({
-      ['videoInfo.userRead.commentAmount']: ++this.data.videoInfo.userRead.commentAmount
-    })
-  },
-  onShareTimeline: function () {
-    return {
-      title: '终于找到适合孩子的朗读神器了!动画配音,边玩边学!',
-      query: `uid=${wx.getStorageSync('uid')}&videoId=1676021823219008`,
-      imageUrl: 'http://reader-wx.ai160.com/images/reader/v3/yuwen.jpg'
+        this.setData({
+            videoInfo,
+            audioPath: videoInfo.userRead.audioPath,
+            currentId: videoId
+        })
+    },
+    // pkPage页面示范朗读
+    pkPageAudio({
+        detail
+    }) {
+        this.setData({
+            audioPath: detail.currentTarget.dataset.audio,
+        })
+        this.playAudio(detail)
+    },
+    async getPkRecord() {
+        let recordList = await getPkRecord({
+            userReadId: this.data.videoId
+        })
+        this.setData({
+            recordList
+        })
+    },
+    jumpUserInfo({
+        currentTarget
+    }) {
+        wx.navigateTo({
+            url: `/pages/personal/index?uid=${currentTarget.dataset.uid}&type=user`,
+        })
+    },
+    jumpIndex() {
+        wx.switchTab({
+            url: '/pages/index/index',
+        })
+    },
+    addCommentNum() {
+        this.setData({
+            ['videoInfo.userRead.commentAmount']: ++this.data.videoInfo.userRead.commentAmount
+        })
+    },
+    /*   onShareTimeline: function () {
+        return {
+          title: '终于找到适合孩子的朗读神器了!动画配音,边玩边学!',
+          query: `uid=${wx.getStorageSync('uid')}&videoId=1676021823219008`,
+          imageUrl: 'http://reader-wx.ai160.com/images/reader/v3/yuwen.jpg'
+        }
+      }, */
+    onUnload() {
+        this.resetAudio()
+        this.setData({
+            currentId: ''
+        })
     }
-  },
-  onUnload() {
-    this.resetAudio()
-    this.setData({
-      currentId: ''
-    })
-  }
 })

+ 3 - 1
pages/reading/index.js

@@ -78,7 +78,9 @@ Page({
         tempFilePath: ""
     },
     onLoad(options) {
-        let videoId = options.videoId
+        let videoId = null
+        let params = decodeURIComponent(options.scene).split('&')
+        videoId = !options.scene ? options.videoId : params[0]
         wx.setNavigationBarTitle({
             title: options.navBarTitle
         })

+ 3 - 3
utils/request.js

@@ -6,13 +6,13 @@ const {
         envVersion
     }
 } = wx.getAccountInfoSync();
-if (envVersion == 'develop') {
+/* if (envVersion == 'develop') {
     baseUrl = 'https://reader-api.efunbox.cn/wx'
     oldUrl = 'https://reader-api.efunbox.cn'
-} else {
+} else { */
     baseUrl = 'https://reader-api.ai160.com/wx'
     oldUrl = 'https://reader-api.ai160.com'
-}
+// }
 
 function request(url, method, data, oldBaseUrl = false, intercept = true) {
     let header = {