TopCard.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <view class="top-card">
  3. <pub-loading-view :loaded="loaded" height="100%">
  4. <view class="card-top" v-if="info">
  5. <image mode="heightFix" src="/static/image/head.png" />
  6. <view class="card-top-right">
  7. <view class="card-top-right-name">{{info.name}}<text class="iconfont"
  8. @click="onClick">{{ showIcon ? '&#xe8bf;' : '&#xe901;' }}</text></view>
  9. <view>{{info.addr}}<text class="iconfont" @click="jumpAddress">&#xe6ae;</text></view>
  10. <view class="card-top-right-sex">{{info.sex}} | {{info.text}}</view>
  11. </view>
  12. </view>
  13. <view class="card-bottom" v-if="info">
  14. <view>
  15. <view class="label">证件号码</view>
  16. <view>{{info.idCard}}</view>
  17. </view>
  18. <view class="second">
  19. <view class="label">最近就诊</view>
  20. <view>{{info.date}}</view>
  21. </view>
  22. </view>
  23. </pub-loading-view>
  24. </view>
  25. </template>
  26. <script lang="ts" setup>
  27. import { ref, onMounted } from 'vue'
  28. import rest from '@/stores/rest'
  29. import * as link from '@/lib/link'
  30. import {
  31. formatDate,
  32. getSexByCardNo,
  33. maskCardNo,
  34. maskName,
  35. } from '@/lib/util'
  36. import { BasicInfoVO } from '../../lib/type';
  37. const showIcon = ref(false)
  38. const originalInfo = ref({
  39. name: '',
  40. address: '',
  41. addressDetails: '',
  42. addr: '',
  43. sex: '',
  44. text: '近三个月就诊记录',
  45. idCard: '',
  46. date: ''
  47. })
  48. const info = ref({ ...originalInfo.value })
  49. const dataList = ref({
  50. hzsfzh: '510224196901293189',
  51. hzxm: '刘秀碧',
  52. })
  53. const loaded = ref(false)
  54. const onClick = () => {
  55. showIcon.value = !showIcon.value
  56. onUpdate(showIcon.value)
  57. }
  58. // 地址信息拼接
  59. const addressInfSplice = (basic : string, details : string, isShow) => {
  60. if (isShow) {
  61. return basic + details;
  62. } else {
  63. return basic + '*'.repeat(details.length);
  64. }
  65. }
  66. const getInfo = async () => {
  67. loaded.value = true
  68. let basicInfo = await rest.get('/app-api/bmfw/findList', { zjhm: dataList.value.hzsfzh }) as BasicInfoVO
  69. let addressInfo = await rest.get('/default/consignee-info/list', { hzid: dataList.value.hzsfzh }) as BasicInfoVO
  70. loaded.value = false
  71. if (Array.isArray(basicInfo.list) && basicInfo.list.length > 0) {
  72. const firstBasicInfo = basicInfo.list[0]
  73. originalInfo.value.name = dataList.value.hzxm
  74. originalInfo.value.sex = getSexByCardNo(dataList.value.hzsfzh)
  75. originalInfo.value.idCard = dataList.value.hzsfzh
  76. originalInfo.value.date = formatDate(firstBasicInfo.kfrq, '{y}-{m}-{d}')
  77. }
  78. if (Array.isArray(addressInfo.list) && addressInfo.list.length > 0) {
  79. const firstAddressInfo = addressInfo.list[0]
  80. originalInfo.value.address = `${firstAddressInfo.province || ''}${firstAddressInfo.city || ''}${firstAddressInfo.area || ''}`
  81. originalInfo.value.addressDetails = firstAddressInfo.shrdzxxdz
  82. }
  83. onUpdate(false)
  84. }
  85. const onUpdate = (isMasked : boolean) => {
  86. Object.assign(info.value, {
  87. name: isMasked ? maskName(originalInfo.value.name) : originalInfo.value.name,
  88. addr: addressInfSplice(originalInfo.value.address, originalInfo.value.addressDetails, !isMasked),
  89. idCard: isMasked ? maskCardNo(originalInfo.value.idCard) : originalInfo.value.idCard,
  90. sex: getSexByCardNo(originalInfo.value.idCard),
  91. date: originalInfo.value.date
  92. })
  93. }
  94. const jumpAddress = () => {
  95. console.log("内容", originalInfo.value.idCard)
  96. link.goAddressList(originalInfo.value.idCard)
  97. }
  98. onMounted(() => {
  99. dataList.value = uni.getStorageSync("userInfo")
  100. console.log("Top", dataList.value)
  101. getInfo()
  102. })
  103. </script>
  104. <style lang="scss" scoped>
  105. .top-card {
  106. border-radius: 0px 0px $uni-spacing-row-s2 $uni-spacing-row-s2;
  107. background: $uni-color-primary;
  108. padding: $uni-spacing-col-s2 $page-row-spacing $uni-spacing-col-s4;
  109. border: 1px solid $uni-border-color;
  110. min-height: 340rpx;
  111. .card-top {
  112. @include flex;
  113. margin-bottom: $uni-spacing-col-s4;
  114. color: #fff;
  115. image {
  116. width: 140rpx;
  117. height: 140rpx;
  118. display: block;
  119. margin-right: $uni-spacing-row-s4;
  120. }
  121. .card-top-right {
  122. flex: 1;
  123. line-height: $uni-line-height-base;
  124. .iconfont {
  125. margin-left: 8rpx;
  126. }
  127. .card-top-right-name {
  128. font-size: $uni-font-size-xxl;
  129. line-height: $uni-line-height-xxl;
  130. display: flex;
  131. align-items: center;
  132. .iconfont {
  133. line-height: $uni-line-height-xxxl;
  134. font-size: 32rpx;
  135. }
  136. }
  137. .card-top-right-sex {
  138. font-size: $uni-font-size-sm;
  139. line-height: $uni-line-height-sm;
  140. }
  141. }
  142. }
  143. .card-bottom {
  144. background-color: #fff;
  145. color: $uni-text-color;
  146. border-radius: $uni-spacing-row-s2;
  147. padding: $uni-spacing-row-s4;
  148. line-height: $uni-line-height-base;
  149. @include flex;
  150. >view {
  151. flex: 1;
  152. @include flex;
  153. flex-direction: column;
  154. }
  155. .label {
  156. color: $uni-text-color-grey;
  157. margin-bottom: 24rpx;
  158. }
  159. .second {
  160. position: relative;
  161. flex: 0.8;
  162. &::before {
  163. content: '';
  164. position: absolute;
  165. left: 0;
  166. background: $uni-border-color;
  167. width: 1px;
  168. height: 100rpx;
  169. -webkit-transform: scaleX(0.5);
  170. transform: scaleX(0.5);
  171. -webkit-transform-origin: 0 0;
  172. transform-origin: 0 0;
  173. }
  174. }
  175. }
  176. }
  177. </style>