TopCard.vue 5.8 KB

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