healthcode.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <view>
  3. <view v-if="loading" class="bg-white" style="padding: 0 50rpx;">
  4. <image src="https://gdyjht.com.cn/loading.gif" mode="aspectFit" class="gif-white response" style="height:600upx;padding-top: 200rpx;"></image>
  5. </view>
  6. <view class="flex flex-direction justify-between" style="height: 100vh;" v-else>
  7. <view class="codeBox" :class="{ 'bg-red': healthCode.color=='red', 'bg-blue': healthCode.color=='green'}" >
  8. <view class="timeBar">{{hideName}}</view>
  9. <view class="timeBar">{{nowStr}}</view>
  10. <image class="code" :src="healthCode.code"></image>
  11. <view v-if="healthCode.color=='green'" class="timeBar" style="height: 250rpx;letter-spacing: 20rpx;">
  12. <icon type="success" size="30"/>
  13. 未见异常
  14. </view>
  15. <view v-if="healthCode.color=='red'" class="timeBar" style="height: 250rpx;letter-spacing: 20rpx;">
  16. <icon type="warn" size="30"/>
  17. 体温异常
  18. </view>
  19. </view>
  20. <view class="tips">{{tips}}</view>
  21. <view class="link" @click="navigate('/pages/index/staff-temperature/list')"> 测温记录</view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. import util from "@/utils/util.js"
  27. export default {
  28. data() {
  29. return {
  30. loading:false,
  31. hideName:'',
  32. personInfo: {
  33. name: "*",
  34. idNumber: "*"
  35. },
  36. timer: '',
  37. nowStr: "",
  38. healthCode: {},
  39. tips: "按照目前掌握的防疫相关数据,暂未发现您存在与防疫相关异常健康状况。防疫相关数据会随着疫情发展及时更新。此次查询并不会排除您的防疫相关健康风险。"
  40. }
  41. },
  42. async onLoad() {
  43. this.loading=true
  44. //获取员工是信息
  45. let phone = uni.getStorageSync("phone");
  46. let staffRes=await this.$api.enterprisestaff.page({phone});
  47. this.personInfo.name = staffRes.data.records[0].realName;
  48. this.personInfo.idNumber = staffRes.data.records[0].idcard;
  49. //隐藏的姓名
  50. this.hideName=this.handelName(this.personInfo.name)
  51. //获取实时时间
  52. this.getDateStr();
  53. //获取健康码
  54. let codeRes=await this.$api.healthCode.getCode({idCardNumber: this.personInfo.idNumber,userName: this.personInfo.name});
  55. this.healthCode.code = codeRes.data.code;
  56. this.healthCode.color = codeRes.data.color;
  57. this.loading=false
  58. },
  59. beforeDestroy() {
  60. clearInterval(this.timer);
  61. },
  62. methods: {
  63. handelName(str,frontLen=0,endLen=1) {
  64. var newStr;
  65. var len = str.length-frontLen-endLen;
  66. if (str.length === 2) {
  67. newStr = str.substring(0, 1) + '*';
  68. } else if (str.length > 2) {
  69. var char = '';
  70. for (let i = 0; i < len; i++) {
  71. char += '*';
  72. }
  73. newStr = str.substring(0, frontLen) + char + str.substring(str.length-endLen);
  74. } else {
  75. newStr = str;
  76. }
  77. return newStr;
  78. },
  79. getDateStr(){this.timer = setInterval(()=>{
  80. this.nowStr = util.dateFormat(new Date(),"yyyy-MM-dd hh:mm:ss");
  81. },1000);
  82. },
  83. navigate(path){
  84. uni.navigateTo({
  85. url:path
  86. })
  87. }
  88. }
  89. }
  90. </script>
  91. <style>
  92. page{
  93. background-color: #FFFFFF;
  94. }
  95. .bg-blue{
  96. background-color: #4594f1;
  97. color: #FFFFFF;
  98. }
  99. .timeBar{
  100. width: 400rpx;
  101. height: 100rpx;
  102. color: white;
  103. display: flex;
  104. align-items: center;
  105. justify-content: center;
  106. font-size: 40rpx;
  107. /* background-color: rgba(255,255,255,0.5); */
  108. }
  109. .code{
  110. background: white;
  111. padding: 5rpx;
  112. width: 350rpx;
  113. height: 350rpx;
  114. }
  115. .codeBox{
  116. width: 100%;
  117. display: flex;
  118. flex-direction: column;
  119. align-items: center;
  120. justify-content: center;
  121. border-radius: 5rpx;
  122. flex-basis: 95%;
  123. }
  124. .tips{
  125. padding: 40rpx 0;
  126. width: 90%;
  127. line-height: 55rpx;
  128. text-indent: 2em;
  129. margin: auto;
  130. color: gray;
  131. /* background: #18B566; */
  132. font-size: 30rpx;
  133. display: flex;
  134. align-items: center;
  135. justify-content: center;
  136. }
  137. .link{
  138. margin-bottom: 40rpx;
  139. width: 100%;
  140. color: #007AFF;
  141. display: flex;
  142. text-decoration: underline;
  143. font-style: italic;
  144. align-items: center;
  145. justify-content: center;
  146. }
  147. </style>