Browse Source

对接接口

master
前端-胡立永 6 months ago
parent
commit
3628dc9ce1
6 changed files with 115 additions and 72 deletions
  1. +17
    -0
      api/api.js
  2. +25
    -18
      pages/index/index.vue
  3. +1
    -1
      pages/subPack/autonym/autonym.vue
  4. +63
    -49
      pages/subPack/human/human.vue
  5. +3
    -0
      store/store.js
  6. +6
    -4
      utils/position.js

+ 17
- 0
api/api.js View File

@ -78,6 +78,23 @@ const config = {
},
// 打卡时间的接口
clockTime: {
url: '/clock/time',
method: 'POST',
showLoading : true,
auth : true,
},
// 人脸识别
clockVerifyFace: {
url: '/clock/verify/face',
method: 'POST',
showLoading : true,
auth : true,
limit : 2000,
loadingTitle : '核验中',
},
// 打卡
clock: {
url: '/clock/in',


+ 25
- 18
pages/index/index.vue View File

@ -27,7 +27,7 @@
<!-- 打卡按钮 -->
<view class="punch-card">
<view @click="callCard" class="circle">
<view @click="toClock" class="circle">
<view class="title">拍照打卡</view>
<view class="time">{{ date.format('YYYY-MM-DD HH:mm:ss') }}</view>
</view>
@ -100,6 +100,22 @@
openBroadside() {
this.$refs.broadside.open()
},
toClock(){
//
this.$api('clockTime', {
lon : this.longitude,
lat : this.latitude
}, res => {
//()
if(res.code == 200){
uni.navigateTo({
// url: "/pages/subPack/face/face"
url: "/pages/subPack/human/human"
})
}
})
},
//
getLocation() {
@ -109,20 +125,19 @@
success: function(res) {
self.longitude = res.longitude;
self.latitude = res.latitude;
self.covers.push({
id: 1,
latitude: res.latitude,
longitude: res.longitude,
iconPath: 'https://tennis-oss.xzaiyp.top/2024-10-22/103fa1db-8524-45e6-8d00-c36a69977a5b.png',
width: 30,
height: 30
})
// self.covers.push({
// id: 1,
// latitude: res.latitude,
// longitude: res.longitude,
// iconPath: 'https://tennis-oss.xzaiyp.top/2024-10-22/103fa1db-8524-45e6-8d00-c36a69977a5b.png',
// width: 30,
// height: 30
// })
},
fail() {
self.checkAndRequestLocationPermission()
}
});
},
checkAndRequestLocationPermission() {
@ -166,14 +181,6 @@
}
});
},
//()
callCard(){
uni.navigateTo({
// url: "/pages/subPack/face/face"
url: "/pages/subPack/human/human"
})
}
}
}
</script>


+ 1
- 1
pages/subPack/autonym/autonym.vue View File

@ -58,7 +58,6 @@
...mapState(['userInfo']),
},
onShow() {
this.$store.commit('getUserInfo')
this.getAuthInfo()
},
methods: {
@ -95,6 +94,7 @@
if(res.result){
this.form.cardNo = res.result.cardNo
this.form.name = res.result.name
this.$store.commit('getUserInfo')
}
})
},


+ 63
- 49
pages/subPack/human/human.vue View File

@ -58,16 +58,21 @@
<!-- 实名认证 -->
<div class="btn"
<view class="btn"
@click="handleTakePhotoClick"
v-if="tipsText == '请拍照' && type == 'auth'">
v-if="tipsText == successText && type == 'auth'">
立即核验
</div>
</view>
<!-- 人脸核验 -->
<view class="btn"
v-else-if="tipsText == successText && !isVerifyFace"
@click="handleTakePhotoClick">
立即核验
</view>
<div class="btn"
@click="handleTakePhotoClick"
v-else-if="tipsText == '请拍照'">
<view class="btn"
v-else-if="tipsText == successText">
<uv-upload
multiple
:maxCount="1"
@ -76,10 +81,10 @@
@afterRead="afterRead">
<view style="display: flex;justify-content: center;
width: 600rpx;">
立即核验
拍照打卡
</view>
</uv-upload>
</div>
</view>
</view>
@ -109,6 +114,10 @@
isAuthCamera: true, //
type : '',
isVerifyFace : false,//
successText : '请保持不动',//
}
},
computed: {
@ -125,8 +134,8 @@
position.getLocationDetail()
.then(res => {
console.log(res);
self.form.lat = res.position.latitude
self.form.lon = res.position.longitude
self.form.lat = res.latitude
self.form.lon = res.longitude
self.form.address = res.address
if(self.isLocationSubmit){
self.submit()
@ -150,39 +159,6 @@
})
})
},
//
photo() {
let self = this
uni.chooseImage({
count: 1, //9
sizeType: ['compressed'], //
// sizeType: ['original', 'compressed'], //
sourceType: ['camera '], //cameraalbum
success: function(res) {
console.log(JSON.stringify(res.tempFilePaths));
//
self.$Oss.ossUpload(res.tempFilePaths[0]).then(url => {
self.form.pic = url
if(self.form.lat){
self.submit()
}else{
uni.showLoading({
title: '定位中...'
})
self.isLocationSubmit = true
}
})
// uni.navigateTo({
// url: "/pages/subPack/punchCard/punchCard"
// })
}
});
},
async submit(){
if (this.$utils.verificationAll(this.form, {
lat : '经纬度缺失,请打开GPS',
@ -212,6 +188,10 @@
},
//
initData() {
let createTime = new Date().getTime()
let num = 0
// #ifdef MP-WEIXIN
@ -246,18 +226,33 @@
roll,
yaw
} = face.angleArray;
const standard = 0.5
let faseP = 0.98
if (Math.abs(pitch) >= standard || Math.abs(roll) >= standard ||
Math.abs(yaw) >= standard) {
this.tipsText = '请平视摄像头'
} else if (face.confArray.global <= 0.8 || face.confArray.leftEye <=
0.8 || face.confArray.mouth <= 0.8 || face.confArray.nose <= 0.8 ||
face.confArray.rightEye <= 0.8) {
} else if (face.confArray.global <= faseP || face.confArray.leftEye <=
faseP || face.confArray.mouth <= faseP || face.confArray.nose <= faseP ||
face.confArray.rightEye <= faseP) {
this.tipsText = '请勿遮挡五官'
} else {
this.tipsText = '请拍照'
this.tipsText = this.successText
//
// this.handleTakePhotoClick()
// if(num > 2){
// uni.showToast({
// title: ''
// })
// return
// }
// if(createTime - new Date().getTime() > 2000){
// }
}
}
},
@ -279,8 +274,8 @@
//
handleTakePhotoClick() {
if (this.tipsText != ""
&& this.tipsText != "请拍照"
if (this.tipsText != ""
&& this.tipsText != this.successText
&& !this.tempImg) {
return;
}
@ -329,7 +324,26 @@
this.form.image = url
if(!this.isVerifyFace){
this.clockVerifyFace()
}
})
}
})
},
//
clockVerifyFace(){
this.$api('clockVerifyFace',
this.form, res => {
if(res.code == 200){
uni.showToast({
title: '核验成功!',
icon: 'icon'
})
this.isVerifyFace = true
}else{
uni.navigateBack(-1)
}
})
},


+ 3
- 0
store/store.js View File

@ -116,6 +116,9 @@ const store = new Vuex.Store({
setAuthInfo(state, data){
state.authInfo = data
},
getLocation(state){
},
},
actions: {},
})


+ 6
- 4
utils/position.js View File

@ -32,11 +32,11 @@ function calculateDistance(lat1, lon1, lat2, lon2, fixed = 0) { //计算两点
}
function getLocation(fn) { //获取用户经纬度
wxGetLocation() //此方法只用于提示用户打开gps
// wxGetLocation() //此方法只用于提示用户打开gps
uni.getLocation({
type: 'gcj02',
isHighAccuracy: true,
highAccuracyExpireTime: 1000,
// highAccuracyExpireTime: 1000,
success: function(position) {
fn(position)
},
@ -50,15 +50,17 @@ function getLocation(fn) { //获取用户经纬度
}
function getLocationDetail() { //获取用户详细地址
wxGetLocation()
// wxGetLocation()
return new Promise((resolve, reject) => {
let key = config.mapKey; //腾讯地图key
uni.getLocation({
type: 'gcj02',
isHighAccuracy: true,
highAccuracyExpireTime: 1000,
// highAccuracyExpireTime: 1000,
success: function(position) {
getUserAddress(position.latitude, position.longitude, key).then(res => {
res.latitude = position.latitude
res.longitude = position.longitude
resolve(res)
})
},


Loading…
Cancel
Save