bayi hai 1 ano
pai
achega
1fd37ed4d5
Modificáronse 2 ficheiros con 48 adicións e 36 borrados
  1. 48 32
      app.js
  2. 0 4
      components/createPoster/index.js

+ 48 - 32
app.js

@@ -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() {

+ 0 - 4
components/createPoster/index.js

@@ -13,7 +13,6 @@ Component({
                 page: "pages/index/index",
                 scene: wx.getStorageSync('uid')
             })
-            console.log(qrCode);
             this.setData({
                 state: true,
                 qrCode
@@ -35,7 +34,6 @@ Component({
                 }).exec(async (res) => {
                     canvas = res[0].node;
                     const ctx = canvas.getContext('2d');
-                    const dpr = wx.getSystemInfoSync().pixelRatio;
                     canvas.width = 646;
                     canvas.height = 959;
                     let pic = canvas.createImage();
@@ -43,10 +41,8 @@ Component({
                     pic.onload = () => {
                         ctx.drawImage(pic, 0, 0, 646, 959);
                         let pl = canvas.createImage();
-                        console.log(this.data.qrCode);
                         pl.src = this.data.qrCode
                         pl.onload = async () => {
-                            console.log('11');
                             ctx.drawImage(pl, 29, 756, 170, 170)
                             let {
                                 tempFilePath