Browse Source

修复首次领卡时弹窗遮蔽的问题

lighter 2 years ago
parent
commit
b841e12524
1 changed files with 19 additions and 14 deletions
  1. 19 14
      src/utils/check-patient-id.js

+ 19 - 14
src/utils/check-patient-id.js

@@ -3,28 +3,33 @@ import store from '../store'
 import { getPatientIdByOpenId } from '../api/patient-id-cards'
 import { Dialog } from 'vant'
 import Cookies from 'js-cookie'
-
 export function checkPatientId() {
   const openId = getLocalOpenId()
   if (!openId) {
     return
   }
-  getPatientIdByOpenId(openId).then((res) => {
-    if (res.length > 0) {
-      store.commit('SET_PATIENTCARDS', res)
-    } else {
-      setTimeout(() => {
-        Dialog.alert({
-          title: '提示',
-          message: '您的就诊人为空,请前往添加。',
-        }).then(() => {
-          router.push('/myPatientIdCards')
-        })
-      }, 100)
-    }
+  getPatientIdByOpenId(openId).then((cards) => {
+    cards.length > 0 ? commitPatientCards(cards) : showNotification()
   })
 }
 
+function commitPatientCards(cards) {
+  store.commit('SET_PATIENTCARDS', cards)
+}
+
+function showNotification() {
+  setTimeout(() => {
+    if (router.currentRoute.value.fullPath.indexOf('newUserRegForElectronicHealthCard') === -1) {
+      Dialog.alert({
+        title: '提示',
+        message: '您的就诊人为空,请前往添加。',
+      }).then(() => {
+        router.push('/myPatientIdCards')
+      })
+    }
+  }, 100)
+}
+
 export function getLocalOpenId() {
   let openId = Cookies.get('openId')
   openId = openId ? openId : localStorage.openId