healthCode.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <view class="">
  3. <u-modal @confirm="infoConfirm" title="身份信息" :mask-close-able="false" v-model="infoShow" >
  4. <view class="slot-content" style="margin: 20rpx;">
  5. <u-form label-width="150" ref="uForm">
  6. <u-form-item label="姓名" ><u-input v-model="personInfo.name" disabled /></u-form-item>
  7. <u-form-item label="身份证号"><u-input v-model="personInfo.idNumber" /></u-form-item>
  8. </u-form>
  9. </view>
  10. </u-modal>
  11. <view v-if="loading" class="bg-white" style="padding: 0 50rpx;">
  12. <image src="https://gdyjht.com.cn/loading.gif" mode="aspectFit" class="gif-white response" style="height:600upx;padding-top: 200rpx;"></image>
  13. </view>
  14. <view class="flex flex-direction justify-between" v-else style="height: 100vh;">
  15. <view class="codeBox" :class="{ 'bg-red': healthCode.color=='red', 'bg-blue': healthCode.color=='green'}" >
  16. <view class="timeBar">{{hideName}}</view>
  17. <view class="timeBar">{{nowStr}}</view>
  18. <image class="code" :src="healthCode.code"></image>
  19. <view v-if="healthCode.color=='green'" class="timeBar" style="height: 250rpx;letter-spacing: 20rpx;">
  20. <icon type="success" size="30"/>
  21. 未见异常
  22. </view>
  23. <view v-if="healthCode.color=='red'" class="timeBar" style="height: 250rpx;letter-spacing: 20rpx;">
  24. <icon type="warn" size="30"/>
  25. 体温异常
  26. </view>
  27. </view>
  28. <view class="tips">{{tips}}</view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. export default {
  34. data() {
  35. return {
  36. loading:true,
  37. infoShow:false,
  38. hideName:'',
  39. personInfo: {
  40. name: "*",
  41. idNumber: "*"
  42. },
  43. timer: '',
  44. nowStr: "",
  45. healthCode: {},
  46. tips: "按照目前掌握的防疫相关数据,暂未发现您存在与防疫相关异常健康状况。防疫相关数据会随着疫情发展及时更新。此次查询并不会排除您的防疫相关健康风险。"
  47. }
  48. },
  49. onLoad() {
  50. console.log(this.$u.sys());
  51. this.getDateStr()
  52. this.init()
  53. },
  54. beforeDestroy() {
  55. clearInterval(this.timer);
  56. },
  57. methods: {
  58. init(){
  59. let member= getApp().globalData.member
  60. this.personInfo.name=member.name
  61. this.personInfo.idNumber=member.idcard
  62. if (this.$isEmpty(this.personInfo.name)) {
  63. uni.showModal({
  64. content:'系统异常',
  65. showCancel:false,
  66. success: (res) => {
  67. uni.navigateBack({
  68. delta:1
  69. })
  70. }
  71. })
  72. return
  73. }
  74. this.hideName=this.handelName(this.personInfo.name)
  75. if (this.$isEmpty(this.personInfo.idNumber)) {
  76. this.infoShow=true
  77. }else{
  78. this.fetchCode()
  79. }
  80. },
  81. infoConfirm(){
  82. if (this.$isEmpty(this.personInfo.idNumber)) {
  83. this.$u.toast('请输入身份证号')
  84. this.infoShow=true
  85. return
  86. }
  87. if (!this.$u.test.idCard(this.personInfo.idNumber)) {
  88. this.$u.toast('请输入正确的身份证号')
  89. this.infoShow=true
  90. return
  91. }
  92. this.fetchCode()
  93. },
  94. fetchCode(){
  95. this.loading=true
  96. let that=this
  97. let operation='health/getCode'
  98. let params={
  99. userName:this.personInfo.name,
  100. idCardNumber:this.personInfo.idNumber
  101. }
  102. getApp().globalData.postRequest(params,operation,function(res){
  103. if (res.data.result_code!=1) {
  104. uni.showModal({
  105. content:res.data.result_msg,
  106. showCancel:false,
  107. success: (res) => {
  108. if (res.confirm) {
  109. uni.navigateBack({
  110. delta:1
  111. })
  112. }
  113. }
  114. })
  115. }
  116. that.healthCode=res.data.result_msg
  117. that.loading=false
  118. })
  119. },
  120. handelName(str,frontLen=0,endLen=1) {
  121. var newStr;
  122. var len = str.length-frontLen-endLen;
  123. if (str.length === 2) {
  124. newStr = str.substring(0, 1) + '*';
  125. } else if (str.length > 2) {
  126. var char = '';
  127. for (let i = 0; i < len; i++) {
  128. char += '*';
  129. }
  130. newStr = str.substring(0, frontLen) + char + str.substring(str.length-endLen);
  131. } else {
  132. newStr = str;
  133. }
  134. return newStr;
  135. },
  136. getDateStr(){this.timer = setInterval(()=>{
  137. this.nowStr = this.$util.dateFormat(new Date(),"yyyy-MM-dd hh:mm:ss");
  138. },1000);
  139. },
  140. navigate(path){
  141. uni.navigateTo({
  142. url:path
  143. })
  144. }
  145. }
  146. }
  147. </script>
  148. <style>
  149. page{
  150. background-color: #FFFFFF;
  151. }
  152. .bg-blue{
  153. background-color: #4594f1;
  154. color: #FFFFFF;
  155. }
  156. .timeBar{
  157. width: 400rpx;
  158. height: 100rpx;
  159. color: white;
  160. display: flex;
  161. align-items: center;
  162. justify-content: center;
  163. font-size: 40rpx;
  164. /* background-color: rgba(255,255,255,0.5); */
  165. }
  166. .code{
  167. background: white;
  168. padding: 5rpx;
  169. width: 350rpx;
  170. height: 350rpx;
  171. }
  172. .codeBox{
  173. width: 100%;
  174. display: flex;
  175. flex-direction: column;
  176. align-items: center;
  177. justify-content: center;
  178. border-radius: 5rpx;
  179. flex-basis: 95%;
  180. }
  181. .tips{
  182. padding: 40rpx 0;
  183. width: 90%;
  184. line-height: 55rpx;
  185. text-indent: 2em;
  186. margin: auto;
  187. color: gray;
  188. /* background: #18B566; */
  189. font-size: 30rpx;
  190. display: flex;
  191. align-items: center;
  192. justify-content: center;
  193. }
  194. .link{
  195. height: 100rpx;
  196. width: 100%;
  197. color: #007AFF;
  198. display: flex;
  199. text-decoration: underline;
  200. font-style: italic;
  201. align-items: center;
  202. justify-content: center;
  203. }
  204. </style>