Browse Source

修改首页获取推荐医生信息为异步。

lighter 4 years ago
parent
commit
27076b3a1c
1 changed files with 32 additions and 5 deletions
  1. 32 5
      src/views/hospital-service/HospitalServiceHome.vue

+ 32 - 5
src/views/hospital-service/HospitalServiceHome.vue

@@ -68,6 +68,9 @@
       <van-tag size="large" type="warning">名医直达</van-tag>
     </div>
     <div :style="swipeStyle">
+      <div :style="loadingStyle" v-show="loading">
+        <van-loading size="24px" type="spinner" vertical></van-loading>
+      </div>
       <van-swipe :autoplay="10000" :show-indicators="false" vertical style="height: 100%">
         <van-swipe-item v-for="(arr, index) in doctors" :key="index">
           <div :style="swipeRowStyle" v-for="item in arr" :key="item.doctorCode" @click="clickDoctor(item)">
@@ -91,12 +94,12 @@
 </template>
 
 <script>
-import { computed, onMounted } from 'vue'
+import { computed, onMounted, ref } from 'vue'
 import store from '../../store'
-import { selectHomePageDoctors } from '../../api/home-page'
 import { getDate } from '../../utils/date'
 import router from '../../router'
 import { Dialog } from 'vant'
+import axios from 'axios'
 export default {
   setup() {
     const windowSize = store.state.windowSize
@@ -121,6 +124,14 @@ export default {
       color: 'white',
     }
 
+    const loadingStyle = {
+      position: 'fixed',
+      top: 400 + swipeStyle.h / 2 - 32 + 'px',
+      left: 0,
+      right: 0,
+      bottom: '50px',
+    }
+
     const portraitHeight = swipeRowStyle.h - 10 + 'px'
     const portraitWidth = swipeRowStyle.h * 0.65 + 'px'
 
@@ -168,11 +179,13 @@ export default {
       })
       // routeTo(filterPath('/covidVaccinate/', '/selectCovidVaccinatePatient'))
     }
-
+    const loading = ref(false)
     onMounted(() => {
       if (doctors.value.length === 0) {
-        selectHomePageDoctors().then((res) => {
-          store.commit('SET_HOMEPAGEDOCTORS', res)
+        loading.value = true
+        axios('http://218.104.151.241:8805/wxserver/homepage/selectHomePageDoctors').then((res) => {
+          store.commit('SET_HOMEPAGEDOCTORS', res.data.data)
+          loading.value = false
         })
       }
     })
@@ -188,6 +201,8 @@ export default {
       specialtyStyle,
       routeTo,
       toVaccinateAppointment,
+      loadingStyle,
+      loading,
     }
   },
 }
@@ -250,4 +265,16 @@ export default {
   color: #333;
   /* color:#048a9e; */
 }
+
+.doctor-loading-box {
+  position: fixed;
+  display: inline-block;
+  width: 120px;
+  padding: 15px 0;
+  vertical-align: middle;
+  background-color: #fff;
+  border-radius: 4px;
+  border: 1px solid #ebeef5;
+  box-shadow: 1px 2px 9px 5px rgba(0, 0, 0, 0.1);
+}
 </style>