123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- // pages/faceRecognition/faceRecognition.js
- const util = require('../../utils/util.js');
- Page({
- data: {
- photo: ''
- },
- uploadPhoto() {
- wx.showLoading({
- title: '上传中',
- })
- wx.chooseImage({
- count: 1,
- sizeType: ['compressed'],
- sourceType: ['camera'],
- success: (res) => {
- let tempFilePaths = res.tempFilePaths
- wx.uploadFile({
- url: util.globalData.publicUrl + '/sys/user/upload',
- filePath: tempFilePaths[0],
- name: 'uploadFile',
- formData: {
- "user": "test",
- },
- header: {
- appletsId: wx.getStorageSync('openId'),
- },
- success: (res) => {
- let datas = JSON.parse(res.data)
- this.setData({
- photo: datas.data
- })
- console.log(this.data.photo)
- }
- })
- },
- complete: (e) => {
- wx.hideLoading();
- }
- })
- },
- submit() {
- wx.showLoading({
- title: '上传中',
- })
- wx.request({
- url: util.globalData.publicUrl + '/user/userFaceComparison',
- method: "post",
- header: {
- appletsId: wx.getStorageSync('openId')
- },
- data: {
- photoPath: this.data.photo
- },
- success: (res) => {
- wx.hideLoading();
- console.log(res)
- if (res.data.code == 0) {
- wx.showModal({
- showCancel: false,
- content: '比对成功',
- success(res) {
- if (res.confirm) {
- wx.switchTab({
- url: '/pages/index/index',
- })
- }
- }
- })
- }else{
- wx.hideLoading();
- wx.showToast({
- title: '面部识别不通过,请重新上传',
- icon: 'none',
- duration: 2000,
- })
- }
- },
- // complete:()=>{
- // wx.hideLoading();
- // }
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|