init project
This commit is contained in:
172
pages/facialCapturing/index.js
Normal file
172
pages/facialCapturing/index.js
Normal file
@@ -0,0 +1,172 @@
|
||||
// pages/facialCapturing/index.js
|
||||
const app = getApp();
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
image: '../../images/19@3x.png',
|
||||
isPass: false,
|
||||
isDetail: false,
|
||||
info: {}
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function(options) {
|
||||
this.setData({
|
||||
isPass: options.isPass ? true : false,
|
||||
isDetail: options.isDetail ? true : false,
|
||||
})
|
||||
this.getData()
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow: function() {},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom: function() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage: function() {
|
||||
return {
|
||||
title: '智慧云馆'
|
||||
}
|
||||
},
|
||||
|
||||
// 拍照
|
||||
photograph() {
|
||||
this.getImage("camera")
|
||||
},
|
||||
|
||||
// 相册
|
||||
photoAlbum() {
|
||||
this.getImage("album")
|
||||
},
|
||||
|
||||
// 拍照或相册
|
||||
getImage(val) {
|
||||
let that = this;
|
||||
wx.chooseImage({
|
||||
count: 1,
|
||||
sizeType: ['compressed'],
|
||||
sourceType: [val],
|
||||
success: function(res) {
|
||||
wx.showLoading({
|
||||
title: '正在上传...',
|
||||
mask: true,
|
||||
})
|
||||
app.$api.memberFaceInfo({
|
||||
filePath: res.tempFilePaths[0]
|
||||
}).then(res => {
|
||||
wx.showToast({
|
||||
title: '上传成功',
|
||||
duration: 2000
|
||||
})
|
||||
that.getData()
|
||||
// if (that.data.isPass) {
|
||||
// setTimeout(function() {
|
||||
// that.pass();
|
||||
// }, 2000)
|
||||
// }
|
||||
}, err => {})
|
||||
},
|
||||
fail: function(res) {
|
||||
wx.hideLoading()
|
||||
},
|
||||
})
|
||||
},
|
||||
|
||||
// 获取数据
|
||||
getData() {
|
||||
app.$api.memberFaceInfoInfos({}).then(res => {
|
||||
this.setData({
|
||||
info: res.info,
|
||||
image: res.info.faceUrl ? res.info.faceUrl : '../../images/19@3x.png'
|
||||
})
|
||||
}, err => {
|
||||
|
||||
})
|
||||
},
|
||||
|
||||
// 跳过
|
||||
pass() {
|
||||
let route = wx.getStorageSync('history');
|
||||
wx.removeStorageSync('history');
|
||||
if (!route || route == '/pages/login/index') {
|
||||
|
||||
const pages = getCurrentPages();
|
||||
if (pages.length > 1) {
|
||||
wx.navigateBack()
|
||||
} else {
|
||||
return wx.redirectTo({
|
||||
url: '/pages/mine/index',
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
wx.redirectTo({
|
||||
url: route,
|
||||
})
|
||||
},
|
||||
|
||||
saveClick() {
|
||||
if (this.data.isPass) {
|
||||
const _this = this;
|
||||
wx.showModal({
|
||||
title: '上传完成',
|
||||
content: '您已完成所有手机注册流程,请直接站在门禁人脸识别区域进行人脸识别入场',
|
||||
showCancel: false,
|
||||
success: function() {
|
||||
_this.pass();
|
||||
}
|
||||
})
|
||||
} else {
|
||||
wx.navigateBack()
|
||||
}
|
||||
|
||||
|
||||
// const pages = getCurrentPages();
|
||||
// const page = pages[pages.length - 2];
|
||||
// page.enter();
|
||||
//
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user