소스 검색

逻辑增加

柒零 1 년 전
부모
커밋
0a05849b06
3개의 변경된 파일45개의 추가작업 그리고 6개의 파일을 삭제
  1. 5 5
      pages/mine/mine.js
  2. 38 1
      pages/scan/scan.js
  3. 2 0
      pages/scan/scan.wxml

+ 5 - 5
pages/mine/mine.js

@@ -34,11 +34,6 @@ Page({
     }]
 
   },
-  showDialog() {
-    this.setData({
-      showAuthorizedDialog: true
-    })
-  },
   onMenuClick(e) {
     console.log(e.currentTarget.dataset);
     const { index } = e.currentTarget.dataset;
@@ -101,6 +96,11 @@ Page({
   
     this.checkAuth()
   },
+  showDialog() {
+    this.setData({
+      showAuthorizedDialog: true
+    })
+  },
   checkAuth() {
     var hasAuth = wx.getStorageSync("hasAuth");
     this.setData({

+ 38 - 1
pages/scan/scan.js

@@ -3,6 +3,8 @@ const util = require('../../utils/util.js')
 
 Page({
   data: {
+    showAuthorizedDialog: false,
+    hasAuth: false,
     activeIcon: "/subpages/icons/ic_selected_radio.svg",
     normalIcon: "/subpages/icons/ic_radio.svg",
     logs: [],
@@ -26,6 +28,10 @@ Page({
   },
   //扫码
   tapScan() {
+    if (!this.data.hasAuth) {
+      this.showDialog();
+      return;
+    }
     if (!this.data.checkedPrivacy) {
       wx.showToast({
         title: '请先阅读并同意《舒眠大健康用户服务协议》和《舒眠大健康隐私保护政策》',
@@ -48,12 +54,43 @@ Page({
   },
   onLoad() {
     console.log("scan页面");
-  }, onShow() {
+  },
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
     const app = getApp();
     app.globalData.selectedTabIndex = 4;
     this.getTabBar().setData({
       selected: 4
     })
+
+    this.checkAuth()
+  },
+  showDialog() {
+    this.setData({
+      showAuthorizedDialog: true
+    })
+  },
+  checkAuth() {
+    var hasAuth = wx.getStorageSync("hasAuth");
+    this.setData({
+      hasAuth: hasAuth
+    })
+    // if (hasAuth) {
+    //   var userInfo = wx.getStorageSync("userInfo");
+    //   this.setData({
+    //     userName: userInfo.userName || "用户登录",
+    //     avatarUrl: userInfo.avatarUrl || defaultAvatarUrl,
+    //     phoneNumber: userInfo.phoneNumber || ""
+    //   })
+    // }
+    return hasAuth;
+  },
+  authorizationSuccessful() {
+    console.log("授权成功");
+    this.setData({ showAuthorizedDialog: false })
+    this.checkAuth();
   },
 
   login: function () {

+ 2 - 0
pages/scan/scan.wxml

@@ -25,4 +25,6 @@
     </view>
 
   </view>
+  <authorized-login-dialog showDialog="{{showAuthorizedDialog}}"
+    bind:authorizationSuccessful="authorizationSuccessful"></authorized-login-dialog>
 </view>