|  | @@ -4,11 +4,11 @@
 | 
	
		
			
				|  |  |        <div class="qr-text-area">
 | 
	
		
			
				|  |  |          <div>
 | 
	
		
			
				|  |  |            <span>
 | 
	
		
			
				|  |  | -            {{ defaultCard.name }}
 | 
	
		
			
				|  |  | +            {{ currentCard.name }}
 | 
	
		
			
				|  |  |            </span>
 | 
	
		
			
				|  |  |            <button @click.stop="showCardPicker = true">切换</button>
 | 
	
		
			
				|  |  |          </div>
 | 
	
		
			
				|  |  | -        <div>ID:{{ defaultCard.patientId }}</div>
 | 
	
		
			
				|  |  | +        <div>ID:{{ currentCard.patientId }}</div>
 | 
	
		
			
				|  |  |        </div>
 | 
	
		
			
				|  |  |        <div class="qr-code-area">
 | 
	
		
			
				|  |  |          <div id="qrcode"></div>
 | 
	
	
		
			
				|  | @@ -55,6 +55,7 @@ import { computed, onMounted, ref, watchEffect } from 'vue'
 | 
	
		
			
				|  |  |  import store from '../../store'
 | 
	
		
			
				|  |  |  import { qrcanvas } from 'qrcanvas'
 | 
	
		
			
				|  |  |  import router from '../../router'
 | 
	
		
			
				|  |  | +import Cookies from 'js-cookie'
 | 
	
		
			
				|  |  |  export default {
 | 
	
		
			
				|  |  |    setup() {
 | 
	
		
			
				|  |  |      const cards = computed(() => {
 | 
	
	
		
			
				|  | @@ -63,13 +64,13 @@ export default {
 | 
	
		
			
				|  |  |      const filterPath = (singleCardPath, multipleCardsPath) => {
 | 
	
		
			
				|  |  |        return cards.value.length === 1 ? singleCardPath + cards.value[0].patientId : multipleCardsPath
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -    const defaultCard = ref({})
 | 
	
		
			
				|  |  | +    const currentCard = ref({})
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      watchEffect(() => {
 | 
	
		
			
				|  |  | -      if (defaultCard.value.patientId) {
 | 
	
		
			
				|  |  | +      if (currentCard.value.patientId) {
 | 
	
		
			
				|  |  |          document.getElementById('qrcode').innerHTML = ''
 | 
	
		
			
				|  |  |          const canvas = qrcanvas({
 | 
	
		
			
				|  |  | -          data: defaultCard.value.patientId,
 | 
	
		
			
				|  |  | +          data: currentCard.value.patientId,
 | 
	
		
			
				|  |  |            size: 64,
 | 
	
		
			
				|  |  |          })
 | 
	
		
			
				|  |  |          document.getElementById('qrcode').appendChild(canvas)
 | 
	
	
		
			
				|  | @@ -77,23 +78,32 @@ export default {
 | 
	
		
			
				|  |  |      })
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      const routeToCard = () => {
 | 
	
		
			
				|  |  | -      router.push('/patientCardInfo/' + defaultCard.value.patientId)
 | 
	
		
			
				|  |  | +      router.push('/patientCardInfo/' + currentCard.value.patientId)
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      const showCardPicker = ref(false)
 | 
	
		
			
				|  |  |      const customFieldName = {
 | 
	
		
			
				|  |  |        text: 'name',
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      const onConfirm = (val) => {
 | 
	
		
			
				|  |  | -      defaultCard.value = val
 | 
	
		
			
				|  |  | +      Cookies.set('chosen-id', val.patientId)
 | 
	
		
			
				|  |  | +      currentCard.value = val
 | 
	
		
			
				|  |  |        showCardPicker.value = false
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      onMounted(() => {
 | 
	
		
			
				|  |  | +      const chosenId = Cookies.get('chosen-id')
 | 
	
		
			
				|  |  |        for (let i = 0; i < cards.value.length; i++) {
 | 
	
		
			
				|  |  |          const card = cards.value[i]
 | 
	
		
			
				|  |  | -        if (card.isDefault === 1) {
 | 
	
		
			
				|  |  | -          defaultCard.value = card
 | 
	
		
			
				|  |  | -          break
 | 
	
		
			
				|  |  | +        if (chosenId) {
 | 
	
		
			
				|  |  | +          if (card.patientId === chosenId) {
 | 
	
		
			
				|  |  | +            currentCard.value = card
 | 
	
		
			
				|  |  | +            break
 | 
	
		
			
				|  |  | +          }
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +          if (card.isDefault === 1) {
 | 
	
		
			
				|  |  | +            currentCard.value = card
 | 
	
		
			
				|  |  | +            break
 | 
	
		
			
				|  |  | +          }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |      })
 | 
	
	
		
			
				|  | @@ -101,7 +111,7 @@ export default {
 | 
	
		
			
				|  |  |      return {
 | 
	
		
			
				|  |  |        cards,
 | 
	
		
			
				|  |  |        filterPath,
 | 
	
		
			
				|  |  | -      defaultCard,
 | 
	
		
			
				|  |  | +      currentCard,
 | 
	
		
			
				|  |  |        routeToCard,
 | 
	
		
			
				|  |  |        showCardPicker,
 | 
	
		
			
				|  |  |        onConfirm,
 | 
	
	
		
			
				|  | @@ -118,7 +128,7 @@ export default {
 | 
	
		
			
				|  |  |    margin-left: 10%;
 | 
	
		
			
				|  |  |    height: 100px;
 | 
	
		
			
				|  |  |    border-radius: 8px;
 | 
	
		
			
				|  |  | -  margin-bottom: 30px;
 | 
	
		
			
				|  |  | +  margin-bottom: 16px;
 | 
	
		
			
				|  |  |    background: url('../../assets/id-qrcode-bg.png');
 | 
	
		
			
				|  |  |    display: flex;
 | 
	
		
			
				|  |  |  }
 | 
	
	
		
			
				|  | @@ -133,6 +143,7 @@ export default {
 | 
	
		
			
				|  |  |  .qr-text-area > div > button {
 | 
	
		
			
				|  |  |    width: 80px;
 | 
	
		
			
				|  |  |    height: 26px;
 | 
	
		
			
				|  |  | +  margin-bottom: 8px;
 | 
	
		
			
				|  |  |    outline: none;
 | 
	
		
			
				|  |  |    margin-left: 16px;
 | 
	
		
			
				|  |  |    border-radius: 16px;
 |