普兆健康管家前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

267 lines
5.8 KiB

  1. <template>
  2. <view class="page__view">
  3. <navbar title="人脸验证" leftClick @leftClick="$utils.navigateBack" color="#191919" bgColor="#FFFFFF" />
  4. <view class="main">
  5. <view class="card">
  6. <view class="card-header">
  7. <view>为保证本人操作请进行人脸验证</view>
  8. <view class="card-desc">请保持正脸在取景框根据屏幕提示完成识别</view>
  9. </view>
  10. <view class="camera-box">
  11. <!-- todo: check clear -->
  12. <image class="camera-bg" src="@/pages_order/static/order/camera-bg.png" mode="scaleToFill" />
  13. <template v-if="countdown">
  14. <view class="camera-countdown">
  15. <uv-count-down
  16. :time="3 * 1000"
  17. autoStart
  18. @change="onCountDownChange"
  19. @finish="onCountDownFinish"
  20. >
  21. <view class="camera-countdown-text">{{ timeData.seconds }}s</view>
  22. </uv-count-down>
  23. </view>
  24. </template>
  25. <template v-if="scanning">
  26. <view class="flex camera-fg">
  27. <view style="position: relative;">
  28. <camera class="camera" device-position="front" flash="auto" @initdone="onCameraInited" @error="onCameraError"></camera>
  29. <cover-image class="camera-tag" src="@/pages_order/static/order/tag.png"></cover-image>
  30. </view>
  31. </view>
  32. </template>
  33. <!-- todo: delete -->
  34. <template v-else-if="src">
  35. <view class="flex camera-fg">
  36. <image class="camera" :src="src" mode="scaleToFill" />
  37. </view>
  38. </template>
  39. </view>
  40. <view class="flex tips">
  41. <view class="flex flex-column tips-item">
  42. <image class="tips-icon" src="@/pages_order/static/order/tips-1.png" mode="widthFix"></image>
  43. <view class="tips-text">保持光线充足</view>
  44. </view>
  45. <view class="flex flex-column tips-item">
  46. <image class="tips-icon" src="@/pages_order/static/order/tips-2.png" mode="widthFix"></image>
  47. <view class="tips-text">脸在取景框内</view>
  48. </view>
  49. <view class="flex flex-column tips-item">
  50. <image class="tips-icon" src="@/pages_order/static/order/tips-3.png" mode="widthFix"></image>
  51. <view class="tips-text">面部正对平面</view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="bottom">
  57. <button class="btn" @click="onVerify">开始识别</button>
  58. </view>
  59. </view>
  60. </template>
  61. <script>
  62. export default {
  63. data() {
  64. return {
  65. src: null,
  66. scanning: false,
  67. countdown: false,
  68. timeData: {},
  69. }
  70. },
  71. methods: {
  72. onVerify() {
  73. // todo
  74. this.scanning = true
  75. },
  76. onCameraInited() {
  77. this.countdown = true
  78. },
  79. onCountDownChange(e) {
  80. this.timeData = e
  81. },
  82. onCountDownFinish() {
  83. this.countdown = false
  84. this.takePhoto()
  85. },
  86. takePhoto() {
  87. const ctx = uni.createCameraContext();
  88. ctx.takePhoto({
  89. quality: 'high',
  90. success: (res) => {
  91. this.src = res.tempImagePath
  92. this.scanning = false
  93. // todo: fetch match
  94. setTimeout(() => {
  95. this.$utils.navigateBack()
  96. }, 1500)
  97. }
  98. });
  99. },
  100. onCameraError(e) {
  101. console.log(e.detail);
  102. }
  103. },
  104. }
  105. </script>
  106. <style lang="scss" scoped>
  107. .page__view {
  108. width: 100vw;
  109. min-height: 100vh;
  110. background-color: $uni-bg-color;
  111. position: relative;
  112. /deep/ .nav-bar__view {
  113. position: fixed;
  114. top: 0;
  115. left: 0;
  116. }
  117. }
  118. .main {
  119. padding: calc(var(--status-bar-height) + 144rpx) 32rpx 224rpx 32rpx;
  120. }
  121. .card {
  122. padding: 32rpx;
  123. background: #FAFAFF;
  124. border: 2rpx solid #FFFFFF;
  125. border-radius: 32rpx;
  126. & + & {
  127. margin-top: 40rpx;
  128. }
  129. &-header {
  130. font-family: PingFang SC;
  131. font-weight: 500;
  132. font-size: 36rpx;
  133. line-height: 1.4;
  134. color: #252545;
  135. margin-bottom: 48rpx;
  136. }
  137. &-desc {
  138. margin-top: 4rpx;
  139. font-family: PingFang SC;
  140. font-weight: 400;
  141. font-size: 26rpx;
  142. line-height: 1.4;
  143. color: #4E4E69;
  144. }
  145. }
  146. .camera {
  147. &-box {
  148. width: 622rpx;
  149. height: 678rpx;
  150. position: relative;
  151. }
  152. &-bg {
  153. width: 100%;
  154. height: 100%;
  155. }
  156. &-countdown {
  157. position: absolute;
  158. top: 14rpx;
  159. left: 50%;
  160. transform: translateX(-50%);
  161. &-text {
  162. font-family: PingFang SC;
  163. font-weight: 600;
  164. font-size: 72rpx;
  165. line-height: 1.4;
  166. color: $uni-color;
  167. }
  168. }
  169. &-fg {
  170. position: absolute;
  171. top: 0;
  172. left: 0;
  173. width: 100%;
  174. height: 100%;
  175. }
  176. & {
  177. width: 310rpx;
  178. height: 310rpx;
  179. border-radius: 50%;
  180. }
  181. &-tag {
  182. position: absolute;
  183. left: 50%;
  184. bottom: 0;
  185. transform: translate(-50%, 60%);
  186. width: 248rpx;
  187. height: 160rpx;
  188. }
  189. }
  190. .tips {
  191. margin-top: 32rpx;
  192. padding: 0 32rpx;
  193. column-gap: 24rpx;
  194. &-item {
  195. flex: 1;
  196. row-gap: 24rpx;
  197. }
  198. &-icon {
  199. width: 72rpx;
  200. height: auto;
  201. }
  202. &-text {
  203. font-family: PingFang SC;
  204. font-weight: 400;
  205. font-size: 22rpx;
  206. line-height: 1.4;
  207. color: #989898;
  208. }
  209. }
  210. .bottom {
  211. position: fixed;
  212. left: 0;
  213. bottom: 0;
  214. width: 100vw;
  215. height: 200rpx;
  216. padding: 24rpx 40rpx;
  217. background: #FFFFFF;
  218. box-sizing: border-box;
  219. .btn {
  220. width: 100%;
  221. padding: 16rpx 0;
  222. box-sizing: border-box;
  223. font-family: PingFang SC;
  224. font-weight: 500;
  225. font-size: 36rpx;
  226. line-height: 1;
  227. color: #FFFFFF;
  228. background-image: linear-gradient(to right, #4B348F, #845CFA);
  229. border-radius: 41rpx;
  230. }
  231. }
  232. </style>