LinkHealthCardResult.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <window-size>
  3. <div style="width: 100%; text-align: center; margin-top: 50px">
  4. <div v-if="resultCode === 0">
  5. <span style="
  6. border-radius: 25px;
  7. background-color: rgb(10,199,111);
  8. color: white;
  9. font-size: 34px;
  10. text-align: center;
  11. padding: 7px 9px;
  12. ">
  13. <van-icon name="success"/>
  14. </span>
  15. <div style="font-size: 20px; font-weight: bold; margin-top: 30px">
  16. 健康卡添加成功
  17. </div>
  18. <div style="margin-top: 100px">
  19. <van-button type="primary" plain style="width: 120px" @click="linkDone">完成</van-button>
  20. </div>
  21. </div>
  22. <div v-if="resultCode === -1">
  23. <span style="
  24. border-radius: 25px;
  25. background-color: rgb(250,66,66);
  26. color: white;
  27. font-size: 34px;
  28. text-align: center;
  29. padding: 7px 9px;
  30. ">
  31. <van-icon name="cross" />
  32. </span>
  33. <div style="font-size: 20px; font-weight: bold; margin-top: 30px">
  34. {{ resultMessage }}
  35. </div>
  36. <div style="margin-top: 100px">
  37. <van-button type="primary" plain style="width: 120px" @click="goLastPage">返回上一页</van-button>
  38. </div>
  39. </div>
  40. </div>
  41. </window-size>
  42. </template>
  43. <script>
  44. import {onMounted, ref} from "vue";
  45. import {useRouter} from "vue-router";
  46. import {linkHealthCard} from '../../../api/electronic-health-card'
  47. export default {
  48. setup() {
  49. const router = useRouter()
  50. const resultCode = ref(null)
  51. const resultMessage = ref(null)
  52. const healthCodeAction = (val) => {
  53. switch (val) {
  54. case 0:
  55. case '0':
  56. const isvAppId = '4c84fdd3b55e43c780f407a49d4d0cd4';
  57. const redirectUri = encodeURI('http://staticweb.hnthyy.cn/newUserRegForElectronicHealthCard')
  58. window.location.href = `https://health.tengmed.com/open/getUserCode?apiVersion=3&type=register&isvAppId=${isvAppId}&redirect_uri=${redirectUri}`
  59. break;
  60. case -1:
  61. case '-1':
  62. router.go(-1)
  63. break;
  64. default:
  65. linkHealthCard(val, localStorage.getItem('openId')).then(res => {
  66. if (res.healthCardId) {
  67. resultCode.value = 0
  68. }
  69. }).catch(e => {
  70. resultCode.value = -1
  71. resultMessage.value = e
  72. })
  73. break;
  74. }
  75. }
  76. const linkDone = () => {
  77. router.push('/electronicHealthCardHome')
  78. }
  79. const goLastPage = () => {
  80. router.go(-1)
  81. }
  82. onMounted(() => {
  83. const pathSplit = router.currentRoute.value.fullPath.split('?')
  84. if (pathSplit.length > 1) {
  85. const rawParams = pathSplit[1].split('&')
  86. rawParams.forEach(param => {
  87. const paramKeyVal = param.split('=')
  88. if (paramKeyVal[0] === 'healthCode') {
  89. healthCodeAction(paramKeyVal[1])
  90. }
  91. })
  92. }
  93. })
  94. return {
  95. resultCode,
  96. resultMessage,
  97. linkDone,
  98. goLastPage,
  99. }
  100. }
  101. }
  102. </script>