|
@@ -1,9 +1,4 @@
|
|
|
<template>
|
|
|
- <van-swipe :autoplay="3000" indicator-color="white" style="height: 170px" vertical>
|
|
|
- <van-swipe-item v-for="image in images" :key="image">
|
|
|
- <van-image :src="image" height="170px" />
|
|
|
- </van-swipe-item>
|
|
|
- </van-swipe>
|
|
|
<router-view></router-view>
|
|
|
<van-tabbar route>
|
|
|
<van-tabbar-item replace to="/hospitalService" icon="home-o"> 医疗服务 </van-tabbar-item>
|
|
@@ -17,18 +12,11 @@ import Cookies from 'js-cookie'
|
|
|
import { getOpenId, getPatientIdByOpenId } from '../api/patient-id-cards'
|
|
|
import store from '../store'
|
|
|
import { useRouter } from 'vue-router'
|
|
|
-import { getLocalOpenId } from '../utils/check-patient-id'
|
|
|
-import blueprint from '../assets/hospital-blueprint.jpg'
|
|
|
-import hall from '../assets/hall.jpg'
|
|
|
-import nurseStation from '../assets/nurse-station.jpg'
|
|
|
-import childrenCenter from '../assets/children-center.jpg'
|
|
|
import { computed, onMounted } from 'vue'
|
|
|
export default {
|
|
|
name: 'Home',
|
|
|
setup() {
|
|
|
const router = useRouter()
|
|
|
- const openId = getLocalOpenId()
|
|
|
- const images = [blueprint, hall, nurseStation, childrenCenter]
|
|
|
const cardSize = computed(() => {
|
|
|
return store.state.patientCards.length
|
|
|
})
|
|
@@ -41,29 +29,28 @@ export default {
|
|
|
router.push('/' + to)
|
|
|
}
|
|
|
}
|
|
|
- const queryPatientCards = (openId) => {
|
|
|
- getPatientIdByOpenId(openId).then((res) => {
|
|
|
- if (res.length > 0) {
|
|
|
- store.commit('SET_PATIENTCARDS', res)
|
|
|
- }
|
|
|
- toFirstTab()
|
|
|
- })
|
|
|
- }
|
|
|
onMounted(() => {
|
|
|
if (cardSize.value === 0) {
|
|
|
const code = router.currentRoute.value.params.code
|
|
|
- getOpenId(code).then((res) => {
|
|
|
- Cookies.set('openId', res)
|
|
|
- localStorage.openId = res
|
|
|
- queryPatientCards(res)
|
|
|
- })
|
|
|
+ if (code) {
|
|
|
+ getOpenId(code).then((res) => {
|
|
|
+ Cookies.set('openId', res)
|
|
|
+ localStorage.openId = res
|
|
|
+ getPatientIdByOpenId(res).then((cards) => {
|
|
|
+ if (cards.length > 0) {
|
|
|
+ store.commit('SET_PATIENTCARDS', cards)
|
|
|
+ }
|
|
|
+ toFirstTab()
|
|
|
+ })
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ toFirstTab()
|
|
|
+ }
|
|
|
} else {
|
|
|
toFirstTab()
|
|
|
}
|
|
|
})
|
|
|
- return {
|
|
|
- images,
|
|
|
- }
|
|
|
+ return {}
|
|
|
},
|
|
|
}
|
|
|
</script>
|