【PT.SCC实名制管理系统】24.10.01 -30天,考勤打卡小程序
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.

242 lines
5.2 KiB

6 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
  1. <!-- 人脸识别 -->
  2. <template>
  3. <view class="human-face">
  4. <!-- 自定义导航栏 -->
  5. <uni-nav-bar dark :fixed="true" shadow background-color="var(--main-color)" status-bar left-icon="left"
  6. title="人脸识别" @clickLeft="$utils.navigateBack" />
  7. <!-- 人脸识别说明标题 -->
  8. <view class="human-face-title">为保证本人操作请进行人脸验证</view>
  9. <!-- 人脸识别图片 -->
  10. <view class="human-face-img">
  11. <image v-if="!isPhoto"
  12. src="https://tennis-oss.xzaiyp.top/2024-10-22/508376c5-64b2-472f-8e25-a2469b632a39.png" mode="widthFix">
  13. </image>
  14. </view>
  15. <!-- 人脸识别说明 -->
  16. <view class="human-face-desc">
  17. 人脸认证仅能由<text class="name">{{ userInfo.auth.name }}</text>本人完成验证时请将镜头对准您的脸部
  18. </view>
  19. <!-- 说明 -->
  20. <view class="desc">
  21. <view class="desc-item">
  22. <image src="https://tennis-oss.xzaiyp.top/2024-10-22/a0bf2da9-c25a-4d5c-8c77-7318bd86227d.png"
  23. mode="widthFix"></image>
  24. <view class="text">避免遮挡</view>
  25. </view>
  26. <view class="desc-item">
  27. <image src="https://tennis-oss.xzaiyp.top/2024-10-22/feb72bfb-8271-4e48-8081-d72811543918.png"
  28. mode="widthFix"></image>
  29. <view class="text">光线充足</view>
  30. </view>
  31. <view class="desc-item">
  32. <image src="https://tennis-oss.xzaiyp.top/2024-10-22/5fd8a6a7-a13e-44d6-acf1-a7ada94c699d.png"
  33. mode="widthFix"></image>
  34. <view class="text">正对充足</view>
  35. </view>
  36. </view>
  37. <div class="btn">
  38. <uv-upload
  39. multiple
  40. :maxCount="1"
  41. capture="camera"
  42. height="180rpx"
  43. @afterRead="afterRead">
  44. <view style="display: flex;justify-content: center;
  45. width: 600rpx;">
  46. 立即核验
  47. </view>
  48. </uv-upload>
  49. </div>
  50. </view>
  51. </template>
  52. <script>
  53. import position from '@/utils/position.js'
  54. import {
  55. mapState
  56. } from 'vuex'
  57. export default {
  58. name: "HumanFace",
  59. data() {
  60. return {
  61. isPhoto: false,
  62. form : {
  63. pic : '',
  64. },
  65. isLocationSubmit : false,
  66. }
  67. },
  68. computed: {
  69. ...mapState(['teamList', 'userInfo']),
  70. },
  71. onShow() {
  72. let self = this
  73. position.getLocationDetail()
  74. .then(res => {
  75. console.log(res);
  76. self.form.lat = res.position.latitude
  77. self.form.lon = res.position.longitude
  78. self.form.address = res.address
  79. if(self.isLocationSubmit){
  80. self.submit()
  81. }
  82. })
  83. },
  84. methods: {
  85. afterRead(e) {
  86. let self = this
  87. e.file.forEach(file => {
  88. self.$Oss.ossUpload(file.url).then(url => {
  89. self.form.pic = url
  90. if(self.form.lat){
  91. self.submit()
  92. }else{
  93. uni.showLoading({
  94. title: '定位中...'
  95. })
  96. self.isLocationSubmit = true
  97. }
  98. })
  99. })
  100. },
  101. // 人脸认证通过后拍照
  102. photo() {
  103. let self = this
  104. uni.chooseImage({
  105. count: 1, //默认9
  106. sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
  107. // sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  108. sourceType: ['camera '], //这要注意,camera掉拍照,album是打开手机相册
  109. success: function(res) {
  110. console.log(JSON.stringify(res.tempFilePaths));
  111. //后续在这里上传文件
  112. self.$Oss.ossUpload(res.tempFilePaths[0]).then(url => {
  113. self.form.pic = url
  114. if(self.form.lat){
  115. self.submit()
  116. }else{
  117. uni.showLoading({
  118. title: '定位中...'
  119. })
  120. self.isLocationSubmit = true
  121. }
  122. })
  123. // uni.navigateTo({
  124. // url: "/pages/subPack/punchCard/punchCard"
  125. // })
  126. }
  127. });
  128. },
  129. submit(){
  130. if (this.$utils.verificationAll(this.form, {
  131. lat : '经纬度缺失,请打开GPS',
  132. lon : '经纬度缺失,请打开GPS',
  133. address : '获取地址失败',
  134. pic : '请拍照',
  135. })) {
  136. return
  137. }
  138. this.$api('clock', this.form, res => {
  139. if(res.code == 200){
  140. uni.showToast({
  141. title: '打卡成功',
  142. icon:'none'
  143. })
  144. setTimeout(uni.navigateBack, 1000, -1)
  145. }
  146. })
  147. },
  148. }
  149. }
  150. </script>
  151. <style lang="scss" scoped>
  152. .human-face {
  153. min-height: 100vh;
  154. background: white;
  155. // 人脸识别说明标题
  156. .human-face-title {
  157. font-size: 35rpx;
  158. font-weight: bold;
  159. margin: 60rpx 0rpx;
  160. text-align: center;
  161. }
  162. // 人脸识别图片
  163. .human-face-img {
  164. display: flex;
  165. justify-content: center;
  166. image {
  167. width: 70%;
  168. }
  169. }
  170. // 人脸识别说明
  171. .human-face-desc {
  172. color: #707070;
  173. width: 55%;
  174. font-size: 30rpx;
  175. margin: 30rpx auto;
  176. text-align: center;
  177. .name {
  178. color: $main-color;
  179. }
  180. }
  181. // 说明
  182. .desc {
  183. width: 80%;
  184. display: flex;
  185. flex-wrap: wrap;
  186. margin: 100rpx auto;
  187. .desc-item {
  188. width: 33.33%;
  189. display: flex;
  190. flex-direction: column;
  191. align-items: center;
  192. justify-content: center;
  193. image {
  194. width: 50%;
  195. }
  196. .text {
  197. font-size: 30rpx;
  198. color: #707070;
  199. margin-top: 10rpx;
  200. }
  201. }
  202. }
  203. // 立即核验
  204. .btn {
  205. display: flex;
  206. align-items: center;
  207. justify-content: center;
  208. width: 83%;
  209. background: $main-color;
  210. color: white;
  211. height: 100rpx;
  212. border-radius: 50rpx;
  213. margin: 0rpx auto;
  214. }
  215. }
  216. </style>