<template>
  <view>
    <!-- #ifdef MP-WEIXIN -->
    <healthCardUsers
        @select="select"
        @addCard="addCard"
        @manageCard="manageCard"
        type="auth">
    </healthCardUsers>
    <!-- #endif -->
    <!-- #ifndef MP-WEIXIN -->
    <view class="intro">请在微信小程序中使用电子健康卡功能</view>
    <!-- #endif -->
  </view>
</template>

<script lang="ts" setup>
import { correlationHealthCard_V2 } from '@/pagesPersonal/service/patientManagement';
import { common } from '@/utils';
import { onLoad } from '@dcloudio/uni-app';

const app = getApp();

const select = async (e: any) => {
    let data = e.detail;
    if (!data.code) {
      common.showToast('选卡失败');
      return;
    }
    let { healthCode } = data;

    let querData = {
      HealthCode: healthCode
    };
    let { resData } = await correlationHealthCard_V2(querData);
    
    if(resData.RespCode == 10000){   
      common.goToUrl('/pagesPersonal/st1/business/patientManagement/memberList/memberList');
    }
};

const addCard = () => {
    common.goToUrl('/pagesPersonal/st1/business/patientManagement/addMember/addMember?pageType=addHealthCard');
};

const manageCard = (e: any) => {
    console.log('manageCard', e);
};
</script>

<style lang="scss" scoped>
.intro {
  margin: 30px;
  text-align: center;
}
</style>
