ソースを参照

新增授权弹窗

Limengbo 6 年 前
コミット
5b5210cfc1

+ 27 - 0
compontents/dialog/dialog.js

@@ -0,0 +1,27 @@
+// compontents/dialog/dialog.js
+Component({
+  /**
+   * 组件的属性列表
+   */
+  properties: {
+
+  },
+
+  /**
+   * 组件的初始数据
+   */
+  data: {
+    flag: true,
+  },
+
+  /**
+   * 组件的方法列表
+   */
+  methods: {
+    impower: function () {
+      var myEventDetail = {} // detail对象,提供给事件监听函数
+      var myEventOption = {} // 触发事件的选项
+      this.triggerEvent('myevent', myEventDetail, myEventOption)
+    }
+  }
+})

+ 4 - 0
compontents/dialog/dialog.json

@@ -0,0 +1,4 @@
+{
+  "component": true,
+  "usingComponents": {}
+}

+ 8 - 0
compontents/dialog/dialog.wxml

@@ -0,0 +1,8 @@
+<!--compontents/dialog/dialog.wxml-->
+<view class="dialog">
+    <view class="dialog-contain">
+        <text>登录后可继续操作</text>
+        <button class="btn" type="primary" open-type="getUserInfo" bindgetuserinfo="impower">授权微信后登录</button>
+    </view>
+</view>
+

+ 30 - 0
compontents/dialog/dialog.wxss

@@ -0,0 +1,30 @@
+/* compontents/dialog/dialog.wxss */
+.dialog {
+    position: fixed;
+    left: 0;
+    top: 0;
+    width: 100%;
+    height: 100%;
+    background: rgba(0, 0, 0, .4);
+    z-index:100;
+}
+
+.dialog-contain {
+    position: absolute;
+    left: 0;
+    top: 0;
+    bottom: 0;
+    right: 0;
+    width: 80%;
+    height: 200rpx;
+    background: #fff;
+    margin: auto;
+    border-radius: 20rpx;
+    text-align: center;
+    padding: 0 40rpx;
+    box-sizing: border-box;
+    display: flex;
+    flex-direction: column;
+    justify-content: space-around;
+    font-size: 32rpx;
+}

+ 56 - 13
pages/index/index.js

@@ -18,7 +18,8 @@ Page({
     rankData: {},
     share: false,
     studyLog: [],
-    height: ''
+    height: '',
+    flag: true
   },
   
   lower: function (e) {
@@ -36,6 +37,57 @@ Page({
     // }
   },
 
+  jurisdiction: function () {
+    //登录页信息
+    login.getOpenidSessionKey(res => {
+      //隐藏弹框
+      this.setData({
+        flag: !this.data.flag
+      })
+
+      APIClient.getMySchedule({
+        uid: res.data.data.uid
+      }).success(res => {
+        console.log(res)
+        this.setData({
+          data: res.data.data,
+          grade: util.gradeUpper(res.data.data.users.grade),
+          test:util.day(),
+          time: util.day(res.data.data.timeSpend),
+          studyLog: util.studyTime(res.data.data.studyLog)
+        })
+        
+        if(res.data.data.studyLog.length > 10) {
+          this.setData({
+            height: '700'
+          })
+        }
+      })
+      //获取排名
+      APIClient.getFriendSchedule('wx/friendsRank/user', {
+        uid: res.data.data.uid
+      }).success(res => {
+        console.log(res)
+        this.setData({
+          rankData: res.data.data,
+        })
+
+      })
+    }, function() { 
+      wx.showModal({
+        title: '提示',
+        content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除小学王者班后再次扫码进入,允许授权后可正常使用',
+        showCancel: false,
+        success: function (res) {
+          if (res.confirm) {
+            console.log('用户点击确定')
+          } else if (res.cancel) {
+            console.log('用户点击取消')
+          }
+        }
+      })
+    });  
+  },
   onLoad: function (options) {
     //获取分享过来的值跳转页面
     const ind  = options.ind;
@@ -86,18 +138,9 @@ Page({
         })
 
       })
-    }, function() {
-      wx.showModal({
-        title: '提示',
-        content: '需要获取您的公开信息(昵称、头像等),请从小程序列表删除小学王者班后再次扫码进入,允许授权后可正常使用',
-        showCancel: false,
-        success: function (res) {
-          if (res.confirm) {
-            console.log('用户点击确定')
-          } else if (res.cancel) {
-            console.log('用户点击取消')
-          }
-        }
+    }, () => {
+      this.setData({
+        flag: !this.data.flag
       })
     });  
   },

+ 2 - 1
pages/index/index.json

@@ -4,6 +4,7 @@
      "tarbar": "/compontents/tarbar/tarbar",
      "curriculum": "/compontents/curriculum/curriculum",
      "recommend": "../recommend/recommend",
-     "art": "../art/art"
+     "art": "../art/art",
+     "dialog": "/compontents/dialog/dialog"
     }
   }

+ 3 - 0
pages/index/index.wxml

@@ -102,4 +102,7 @@
           </view>
       </scroll-view>
   </view>
+  <view hidden="{{flag}}">
+    <dialog bindmyevent="jurisdiction"/>
+  </view>
 </view>