TopCard.vue 5.6 KB

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