人脸采集功能开发完成,标志着门禁开门记录在小程序彻底开发完成

This commit is contained in:
wuxw 2020-01-07 00:22:58 +08:00
parent b684247dc5
commit 3d300a22cf
7 changed files with 122 additions and 14 deletions

View File

@ -51,6 +51,11 @@ const listApplicationKeys = baseUrl +"app/applicationKey.listApplicationKeys";
//申请访客钥匙
const applyVisitorApplicationKey = baseUrl + "app/applicationKey.applyVisitorApplicationKey";
//上传业主照片
const uploadOwnerPhoto = baseUrl +"app/owner.uploadOwnerPhoto";
const getOwnerPhotoPath = "https://hc.demo.winqi.cn/callComponent/download/getFile/fileByObjId";
module.exports = {
baseUrl: baseUrl,
@ -69,5 +74,7 @@ module.exports = {
listOwnerMachines: listOwnerMachines,
applyApplicationKey: applyApplicationKey,
listApplicationKeys: listApplicationKeys,
applyVisitorApplicationKey: applyVisitorApplicationKey
applyVisitorApplicationKey: applyVisitorApplicationKey,
uploadOwnerPhoto: uploadOwnerPhoto,
getOwnerPhotoPath: getOwnerPhotoPath
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 8.5 KiB

View File

@ -1,11 +1,15 @@
// pages/collectFace/collectFace.js
const context = require("../../context/Java110Context.js");
const constant = context.constant;
const factory = context.factory;
Page({
/**
* 页面的初始数据
*/
data: {
src:''
src:'',
uploadFlag:false
},
/**
@ -64,14 +68,79 @@ Page({
},
takePhoto:function() {
const ctx = wx.createCameraContext()
let _that = this;
_that.setData({
uploadFlag: true
})
const ctx = wx.createCameraContext();
ctx.takePhoto({
quality: 'high',
success: (res) => {
this.setData({
src: res.tempImagePath
wx.getFileSystemManager().readFile({
filePath: res.tempImagePath,
encoding: 'base64',
success: (photoRes) => {
let _baseInfo = photoRes.data;
_that.setData({
src: _baseInfo
});
_that._uploadOwnerPhoto();
wx.hideLoading()
}
});
},
fail:(e)=>{
_that.setData({
uploadFlag:false
})
}
})
},
_uploadOwnerPhoto:function(){
let _that = this;
context.getOwner(function (_owner) {
let _memberId = _owner.memberId;
let _communityId = _owner.communityId;
let obj = {
memberId: _memberId,
communityId: _communityId,
photo: _that.data.src
};
context.request({
url: constant.url.uploadOwnerPhoto,
header: context.getHeaders(),
method: "POST",
data: obj, //动态数据
success: function (res) {
console.log(res);
if (res.statusCode != 200) {
wx.showToast({
title: '人脸上传失败',
icon: 'none',
duration: 2000
});
_that.setData({
uploadFlag: false
});
return;
}
//成功情况下跳转
wx.navigateBack({
delta:1
});
},
fail: function (e) {
wx.showToast({
title: "服务器异常了",
icon: 'none',
duration: 2000
});
_that.setData({
uploadFlag: false
});
}
});
});
}
})

View File

@ -1,10 +1,19 @@
<view>
<camera mode="normal" device-position="front" flash="auto" binderror="error" style="width: 100%; height: 800rpx;">
<cover-view class="controls">
<cover-image class="img" src="../../images/camera.png" style="width:100%; height:100%"/>
<view>
<camera mode="normal" device-position="front" flash="off" binderror="error" style="width: 100%; height: 800rpx;">
<cover-view >
<cover-image class="img" src="../../images/camera.png" style="width:100%; height:800rpx"/>
</cover-view>
<cover-view class="cf_text_na">拿起手机,面向手机</cover-view>
</camera>
<button type="primary" bindtap="takePhoto">人脸采集</button>
<view class="cf_btn">
<view class="cf_btn_v" wx:if="{{uploadFlag == false}}">
<van-button type="primary" block bind:click="takePhoto">人脸采集</van-button>
</view>
<view class="cf_btn_v" wx:else>
<van-button loading type="primary" block loading-text="人像采集中..."/>
</view>
</view>
</view>

View File

@ -5,9 +5,24 @@
.cf_text_na{
font-size: 48rpx;
text-align: center;
margin:80rpx 0rpx;
font-display: 700;
position: absolute;
top: 0rpx;
text-align: center;
width: 100%;
}
.cf_btn{
text-align: center;
width: 100%;
padding:40rpx 0;
background-color: #f8f8f8;
}
.cf_btn .cf_btn_v{
width: 80%;
margin: 0 auto;
}
.noticeTXT{
font-size: 10PX;

View File

@ -159,7 +159,7 @@ Page({
})
} else {
console.log("提交数据", obj);
wx.request({
context.request({
url: constant.url.saveOwnerRepair, // http://hc.demo.winqi.cn:8012/appApi/ownerRepair.saveOwnerRepair
header: context.getHeaders(),
method: "POST",

View File

@ -1,4 +1,6 @@
// pages/viewPersonFace/viewPersonFace.js
const context = require("../../context/Java110Context.js");
const constant = context.constant;
Page({
/**
@ -77,6 +79,12 @@ Page({
* 查询业主人脸
*/
loadOwnerFace:function(){
let _that = this;
context.getOwner(function(_owner){
let _face = constant.url.getOwnerPhotoPath + "?objId=" + _owner.memberId+"&communityId="+_owner.communityId+"&fileTypeCd=10000&time=" + new Date();
_that.setData({
face: _face
});
});
}
})