Browse Source

pref: modify loading navLoading

wangyuan 2 years ago
parent
commit
f7479f75b6
3 changed files with 12 additions and 29 deletions
  1. 5 13
      pages/index/index.js
  2. 2 10
      pages/my/my.js
  3. 5 6
      pages/report/report.js

+ 5 - 13
pages/index/index.js

@@ -11,9 +11,6 @@ Page({
   data: {
     useNumber: 0, // 剩余预约次数
     documentVos: [], // 档案信息
-    cardNo: '',
-    cardSecret: '',
-    scanTimer: null,
     baseStr: 'data:image/jpg;base64,',
     QRCodeBase64: '',
     qrcodeDialog: false,
@@ -22,10 +19,10 @@ Page({
     userAuthShow: false,
     avatarUrl: '',
     nickName: '',
-    isRefreshPage: false,
     showTopBar: false,
     topBarObj: null,
-    homepageImg: ''
+    homepageImg: '',
+    pageHasRequested: false // 页面数据是否已经请求过
   },
 
   /**
@@ -77,7 +74,6 @@ Page({
     const that = this
     const _isNeedPhone = wx.getStorageSync('isNeedPhone')
     const _headImg = wx.getStorageSync('headImg')
-    console.log(_isNeedPhone, _headImg, '79');
     if (!_isNeedPhone && _headImg !== '') {
       app.globalData.userInfo.login = true
       wx.setStorageSync('login', true)
@@ -209,14 +205,11 @@ Page({
     })
   },
   async initIndexData () {
-    wx.showLoading({
-      title: '加载中...',
-      mask: true
-    })
+    wx.showNavigationBarLoading()
     await this.awaitHomePage()
     await this.awaitAppointmentList()
     await this.awaitAppGetConfigImg()
-    wx.hideLoading()
+    wx.hideNavigationBarLoading()
   },
   // 获取首页档案信息 剩余次数
   awaitHomePage () {
@@ -230,8 +223,7 @@ Page({
         })
         that.setData({
           useNumber: hoemRes.data.useNumber,
-          documentVos: response,
-          isRefreshPage: true
+          documentVos: response
         })
         app.globalData.useNumber = hoemRes.data.useNumber
         reslove(hoemRes)

+ 2 - 10
pages/my/my.js

@@ -96,20 +96,20 @@ Page({
   },
 
   async initMyPage () {
+    wx.showNavigationBarLoading()
     await this.getAccountNmberFn()
     await this.appointmentListFn()
     await this.getAppGetConfigImg()
+    wx.hideNavigationBarLoading()
   },
 
   getAppGetConfigImg() {
     const that = this
-    wx.showNavigationBarLoading()
     // 类型  【1.关于我的 2.用户协议 3.我的 4.实体卡兑换说明 】
     return new Promise((reslove,rej) => {
       appGetConfigImg({
         'imgType': '3'
       }).then(configRes => {
-        wx.hideNavigationBarLoading()
         that.setData({
           imageList: configRes.data || []
         })
@@ -158,21 +158,17 @@ Page({
 
   // 获取用户预约信息
   appointmentListFn () {
-    wx.showNavigationBarLoading()
     return new Promise((resolve, reject) => {
       appointmentList({
         status: 1,
         currentPage: 1
       }).then(res => {
-        wx.hideNavigationBarLoading()
         if (res.data.vos.length !== 0) {
           app.globalData.hasAppointment = true
         } else {
           app.globalData.hasAppointment = false
         }
         resolve(res)
-      }).catch(e => {
-        wx.hideNavigationBarLoading()
       })
     })
   },
@@ -180,18 +176,14 @@ Page({
   // 获取用户剩余检测机会
   getAccountNmberFn () {
     var that = this
-    wx.showNavigationBarLoading()
     return new Promise((resolve, reject) => {
       getAccountNmber({}).then(res => {
-        wx.hideNavigationBarLoading()
         that.setData({
           count: res.data,
           isFirstGetCount: false
         })
         app.globalData.useNumber = res.data
         resolve(res)
-      }).catch(e => {
-        wx.hideNavigationBarLoading()
       })
     })
   },

+ 5 - 6
pages/report/report.js

@@ -23,8 +23,13 @@ Page({
   },
 
   async initReportPage () {
+    wx.showLoading({
+      title: '加载中...',
+      mask: true
+    })
     await this.getMyReportList()
     await this.appointmentListFn()
+    wx.hideLoading()
   },
 
   appointmentListFn () {
@@ -46,20 +51,14 @@ Page({
   // 我的报告
   getMyReportList () {
     var that = this
-    wx.showLoading({
-      title: '加载中...',
-      mask: true
-    })
     return new Promise((resolve, rejetct) => {
       myReportList({}).then(res => {
-        wx.hideLoading()
         var response = res.data || []
         that.setData({
           reportList: response
         })
         resolve(res)
       }).catch(e => {
-        wx.hideLoading()
         wx.showModal({
           content: e,
           confirmColor: '#333',