Explorar o código

开发android登录

bayi hai 1 ano
pai
achega
278dcedcd4
Modificáronse 2 ficheiros con 27 adicións e 13 borrados
  1. 12 13
      app.js
  2. 15 0
      pages/index/index.js

+ 12 - 13
app.js

@@ -62,6 +62,7 @@ App({
                 getApp().callBack();
             }
         } else {
+            // #if MP
             this.getWXCode().then(async res => {
                 if (res.code) {
                     // 获取openid
@@ -83,11 +84,11 @@ App({
                     }
                 }
             })
+            // #endif
         }
     },
     getWXCode() {
         return new Promise((reslove, reject) => {
-            // #if MP
             wx.login({
                 success: async (res) => {
                     if (res.code) {
@@ -97,18 +98,16 @@ App({
                     }
                 }
             })
-            // #elif ANDROID
-            wx.getMiniProgramCode({
-                success(res) {
-                    if (res.code) {
-                        reslove(res)
-                    } else {
-                        console.log('获取小程序 code 失败!' + res.errMsg)
-                        reject(res.errMsg)
-                    }
-                }
-            })
-            // #endif
+            /*  wx.getMiniProgramCode({
+                 success(res) {
+                     if (res.code) {
+                         reslove(res)
+                     } else {
+                         console.log('获取小程序 code 失败!' + res.errMsg)
+                         reject(res.errMsg)
+                     }
+                 }
+             }) */
         })
     },
     checkIsIos: function () {

+ 15 - 0
pages/index/index.js

@@ -27,6 +27,7 @@ Page({
         tmplIds: []
     },
     onLoad(options) {
+        // if MP
         this.getLocUserInfo()
         if (Object.keys(this.data.userInfo).length > 0) {
             this.requestAgain()
@@ -50,6 +51,10 @@ Page({
                 })
             }, 6000)
         }
+        // elif ANDROID
+        this.getLocUserInfo()
+        this.requestAgain()
+        // endif
     },
     onShow() {
         if (typeof this.getTabBar === 'function') {
@@ -72,6 +77,16 @@ Page({
             },
         })
         this.storeBindings.updateStoreBindings()
+        // if ANDROID
+        console.log(this.data.userInfo.grade);
+        if(!this.data.userInfo.grade){
+            this.setData({
+                userInfo:{
+                    grade:"PRIMARY_FIRST_GRADE"
+                }
+            })
+        }
+        // endif
     },
     async getCategoryList() {
         let grade = this.data.userInfo.grade