Răsfoiți Sursa

pref: handle all request loading

wangyuan 2 ani în urmă
părinte
comite
45cfef5170
1 a modificat fișierele cu 7 adăugiri și 12 ștergeri
  1. 7 12
      pages/index/index.js

+ 7 - 12
pages/index/index.js

@@ -209,20 +209,21 @@ Page({
     })
   },
   async initIndexData () {
+    wx.showLoading({
+      title: '加载中...',
+      mask: true
+    })
     await this.awaitHomePage()
     await this.awaitAppointmentList()
     await this.awaitAppGetConfigImg()
+    wx.hideLoading()
   },
   // 获取首页档案信息 剩余次数
   awaitHomePage () {
     var that = this
-    wx.showLoading({
-      title: '加载中...',
-      mask: true
-    })
     return new Promise((reslove,reject) => {
       homePage({}).then(hoemRes => {
-        wx.hideLoading()
+        // wx.hideLoading()
         var response = hoemRes.data.documentVos || []
         response.map(item => {
           item.birthDay = item.birthday.split(' ')[0]
@@ -235,7 +236,7 @@ Page({
         app.globalData.useNumber = hoemRes.data.useNumber
         reslove(hoemRes)
       }).catch(e => {
-        wx.hideLoading()
+        // wx.hideLoading()
         wx.showModal({
           content: e,
           confirmColor: '#333',
@@ -247,13 +248,11 @@ Page({
   // 获取待预约次数
   awaitAppointmentList () {
     const that = this
-    wx.showNavigationBarLoading()
     return new Promise((reslove,reject) => {
       appointmentList({
         status: 1,
         currentPage: 1
       }).then(res => {
-        wx.hideNavigationBarLoading()
         if (res.data.vos.length !== 0) {
           const response = res.data.vos || []
           response.map(item => {
@@ -273,26 +272,22 @@ Page({
         reslove(res)
       }).catch(e => {
         reject(e)
-        wx.hideNavigationBarLoading()
       })
     })
   },
   // 获取图片资源
   awaitAppGetConfigImg () {
     const that = this
-    wx.showNavigationBarLoading()
     return new Promise((reslove,reject) => {
       appGetConfigImg({
         'imgType': '5'
       }).then(configRes => {
-        wx.hideNavigationBarLoading()
         that.setData({
           homepageImg: configRes.data[0].imgUrl
         })
         reslove(configRes)
       }).catch(e => {
         reject(e)
-        wx.hideNavigationBarLoading()
       })
     })
   },