|
@@ -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
|