Ver código fonte

开发android全局点击微信登录

bayi 1 ano atrás
pai
commit
3d641e7325

+ 2 - 1
app.js

@@ -88,6 +88,7 @@ App({
             this.setUser({
                 grade: 'PRIMARY_FIRST_GRADE'
             })
+            getApp().callBack(userRes);
             // #endif
         }
     },
@@ -102,7 +103,7 @@ App({
                     }
                 }
             })
-            
+
         })
     },
     checkIsIos: function () {

+ 16 - 2
app.wxss

@@ -61,9 +61,11 @@ text {
 .seat2 {
     padding-bottom: calc(130rpx + env(safe-area-inset-bottom)) !important;
 }
-.rtext{
+
+.rtext {
     text-align: right;
 }
+
 .isFixed {
     position: fixed;
     z-index: 998;
@@ -113,4 +115,16 @@ text {
         transform: scale(1);
         opacity: 1;
     }
-}
+}
+
+/* #if ANDROID */
+.androidMask {
+    width: 100%;
+    height: 100%;
+    background-color: rgba(200, 255, 0, 0.185);
+    position: fixed;
+    top: 0;
+    left: 0;
+    z-index: 9999;
+}
+/* #endif */

+ 7 - 1
components/navigationBar/index.js

@@ -15,7 +15,8 @@ Component({
     storeBindings: {
         store,
         fields: {
-            userInfo: 'userInfo'
+            userInfo: 'userInfo',
+            androidMask: 'androidMaskFun'
         },
         actions: {
             setUser: 'setUser'
@@ -118,5 +119,10 @@ Component({
         agree(e) {
             console.log("用户同意隐私授权, 接下来可以调用隐私协议中声明的隐私接口")
         },
+        toAndroidLogin() {
+            wx.redirectTo({
+                url: '/pages/donutLogin/index',
+            })
+        }
     }
 })

+ 2 - 1
components/navigationBar/index.less

@@ -110,4 +110,5 @@
             }
         }
     }
-}
+}
+

+ 3 - 0
components/navigationBar/index.wxml

@@ -46,4 +46,7 @@
         </view>
     </view>
 </view>
+<!-- #if ANDROID  -->
+<view class="androidMask" wx:if="{{androidMask}}" bind:tap="toAndroidLogin"></view>
+<!-- #endif -->
 <privacy-popup bind:agree="agree"></privacy-popup>

+ 7 - 1
custom-tab-bar/index.js

@@ -9,7 +9,8 @@ Component({
     storeBindings: {
         store,
         fields: {
-            userInfo: 'userInfo'
+            userInfo: 'userInfo',
+            androidMask: 'androidMaskFun'
         },
     },
     /**
@@ -67,6 +68,11 @@ Component({
                     url
                 });
             }
+        },
+        toAndroidLogin() {
+            wx.redirectTo({
+                url: '/pages/donutLogin/index',
+            })
         }
     }
 })

+ 1 - 0
custom-tab-bar/index.less

@@ -57,6 +57,7 @@
 .bounce {
     animation: elasticity 1.2s linear;
 }
+
 /* Q弹动画关键帧 */
 @keyframes elasticity {
     0% {

+ 12 - 9
custom-tab-bar/index.wxml

@@ -1,10 +1,13 @@
 <view class="tab-bar">
-  <view class="mask" wx:if="{{mask}}"></view>
-  <view wx:for="{{listTab}}" wx:key="index" class="tab-bar-item {{selected === index?'bounce':''}}" data-path="{{item.pagePath}}" data-index="{{index}}"
-    bindtap="switchTab">
-    <view class="noticeTips" wx:if="{{item.pagePath=='/pages/message/index'&&userInfo.mCount>0}}">
-      {{userInfo.mCount}}</view>
-    <image src="{{selected === index ? item.selectedIconPath : item.iconPath}}"></image>
-    <view style="color: {{selected === index ? selectedColor : color}}">{{item.text}}</view>
-  </view>
-</view>
+    <view class="mask" wx:if="{{mask}}"></view>
+    <view wx:for="{{listTab}}" wx:key="index" class="tab-bar-item {{selected === index?'bounce':''}}"
+        data-path="{{item.pagePath}}" data-index="{{index}}" bindtap="switchTab">
+        <view class="noticeTips" wx:if="{{item.pagePath=='/pages/message/index'&&userInfo.mCount>0}}">
+            {{userInfo.mCount}}</view>
+        <image src="{{selected === index ? item.selectedIconPath : item.iconPath}}"></image>
+        <view style="color: {{selected === index ? selectedColor : color}}">{{item.text}}</view>
+    </view>
+</view>
+<!-- #if ANDROID  -->
+<view class="androidMask" wx:if="{{androidMask}}" bind:tap="toAndroidLogin"></view>
+<!-- #endif -->

+ 0 - 7
mixins/event.js

@@ -19,11 +19,4 @@ module.exports = Behavior({
             })
         },
     },
-    methods: {
-        toAndroidLogin() {
-            wx.redirectTo({
-                url: '/pages/donutLogin/index',
-            })
-        }
-    }
 })

+ 0 - 10
pages/donutLogin/index.js

@@ -11,7 +11,6 @@ let storeBindings
 Page({
     data: {
         checkedAgree: false,
-        loginSuccess: false, // 标记是否登录成功
     },
     onLoad() {
         if (!this.storeBindings) {
@@ -26,12 +25,6 @@ Page({
      */
     onUnload() {
         this.storeBindings.destroyStoreBindings()
-        const eventChannel = this.getOpenerEventChannel();
-        if (eventChannel) {
-            eventChannel.emit('__donutLogin__', {
-                success: this.data.loginSuccess
-            });
-        }
     },
 
     /**
@@ -40,9 +33,6 @@ Page({
     onTapWeixinMiniProgramLogin() {
         wx.weixinMiniProgramLogin({
             success: () => {
-                this.setData({
-                    loginSuccess: true
-                });
                 wx.getMiniProgramCode({
                     success: async (res) => {
                         console.log(res);

+ 1 - 14
pages/index/index.js

@@ -26,10 +26,8 @@ Page({
         listOptions: {},
         subscribeShow: false,
         tmplIds: [],
-        androidMask: false
     },
     onLoad(options) {
-        // #if MP
         this.getLocUserInfo()
         if (Object.keys(this.data.userInfo).length > 0) {
             this.requestAgain()
@@ -53,10 +51,6 @@ Page({
                 })
             }, 6000)
         }
-        // #elif ANDROID
-        this.getLocUserInfo()
-        this.requestAgain()
-        // #endif
     },
     onShow() {
         if (typeof this.getTabBar === 'function') {
@@ -75,17 +69,10 @@ Page({
         this.storeBindings = createStoreBindings(this, {
             store,
             fields: {
-                userInfo: 'userInfo'
+                userInfo: 'userInfo',
             },
         })
         this.storeBindings.updateStoreBindings()
-        // #if ANDROID
-        if (!wx.getStorageSync('uid')) {
-            this.setData({
-                androidMask: true
-            })
-        }
-        // #endif
     },
     async getCategoryList() {
         let grade = this.data.userInfo.grade

+ 0 - 9
pages/index/index.less

@@ -77,12 +77,3 @@
     width: 100vw;
     height: 100vh;
 }
-
-.androidMask {
-    position: fixed;
-    left: 0;
-    top: 0;
-    width: 100vw;
-    height: 100vh;
-    background-color: rgba(255, 166, 0, 0.123);
-}

+ 0 - 4
pages/index/index.wxml

@@ -29,8 +29,4 @@
     </view>
 </view>
 <view class="subscribe" wx:if="{{subscribeShow}}" bindtap="requestMessage"></view>
-<!-- #if ANDROID  -->
-to
-<view class="androidMask" wx:if="{{androidMask}}" bind:tap="toAndroidLogin"></view>
-<!-- #endif -->
 <canvas id='share' type="2d"> </canvas>

+ 0 - 8
pages/index/index.wxss

@@ -68,11 +68,3 @@
   width: 100vw;
   height: 100vh;
 }
-.androidMask {
-  position: fixed;
-  left: 0;
-  top: 0;
-  width: 100vw;
-  height: 100vh;
-  background-color: rgba(255, 166, 0, 0.123);
-}

+ 2 - 2
store/index.js

@@ -12,8 +12,8 @@ export const store = observable({
   //pk数据,包括被pk人的身份信息与录音得分
   pkData: {},
   // 计算属性
-  get sum() {
-    return this.numA + this.numB
+  get androidMaskFun() {
+    return !wx.getStorageSync('uid')
   },
   // actions
   setUser: action(function (step) {