// pagesA/faceinfo/faceinfo.js import moment from '../../utils/moment' const WXAPI = require('../../utils/request') Page({ /** * 页面的初始数据 */ data: { deviceinfo: {}, startdate: moment().format('YYYY-MM-DD HH:mm:ss'), enddate: moment().format('YYYY-MM-DD HH:mm:ss'), minDate: new Date().getTime(), currentDate: new Date().getTime(), selectDateStatus:false, selectDateStatus1:false, dateIndex:1, currentDate1:new Date().getTime(), facemessage: {} }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var facemessage = wx.getStorageSync('facemessage') var deviceinfo = wx.getStorageSync('deviceinfo') console.log(facemessage); if(facemessage){ let info = JSON.parse(facemessage.content) this.setData({ facemessage, deviceinfo, startdate: moment(info.passwordStartTime * 1000).format('YYYY-MM-DD HH:mm:ss'), enddate: moment(info.passwordEndTime * 1000).format('YYYY-MM-DD HH:mm:ss'), }) } }, // 时间选择 selectTimeMethods(event){ console.log(event) if(event.currentTarget.dataset.index == 1){ this.setData({ dateIndex:event.currentTarget.dataset.index, selectDateStatus:true }) }else if(event.currentTarget.dataset.index == 2){ this.setData({ dateIndex:event.currentTarget.dataset.index, selectDateStatus1:true }) } }, // 选择凭证有效期 confirmMethods(event){ let time = moment(event.detail).format("YYYY-MM-DD HH:mm:ss") if(this.data.dateIndex == 1){ this.setData({ startdate:time, currentDate: event.detail, minDate:event.detail }) }else if(this.data.dateIndex == 2){ this.setData({ enddate:time, currentDate1: event.detail, }) } this.setData({ selectDateStatus: false, selectDateStatus1:false }); }, cancelMethods(event){ this.setData({ selectDateStatus: false, selectDateStatus1:false }); }, // 确定修改人脸时间 sendface() { console.log(this.data.facemessage) var face = this.data.facemessage var content = JSON.parse(face.content) var startTime = moment(this.data.startdate).format('x') / 1000 var endTime = moment(this.data.enddate).format('x') / 1000 wx.showLoading({ title: '修改凭证中...', }) var dataface = { code: "lwj/faceOperate", data: { faceIndex: content.index, action: 3, endTime: endTime, faceData: content.faceData, lockerId: this.data.deviceinfo.deviceNum, lockerUserId: content.userPassword, startTime: startTime, operateMode: 21, order: 6221 } } WXAPI.sendCommand(dataface).then(res => { console.log(res); if(res.success){ content.operateMode = 21 content.order = 6221 content.passwordStartTime = startTime content.passwordEndTime = endTime let data1 = { id: face.id, content: JSON.stringify(content), startTime: startTime, endTime: endTime } WXAPI.updateCertificates(data1).then(res1 => { console.log(res1); if(res1.success){ wx.hideLoading() wx.showToast({ title: '修改凭证成功', icon: 'none', duration: 2000 }) setTimeout(() => { wx.navigateTo({ url: '/pagesA/facepeople/facepeople', }) }, 500) }else{ wx.hideLoading() wx.showToast({ title: '修改凭证失败', icon: "none", duration: 2000 }) } }) } }) }, onChange(e) { this.data.facemessage.pzname = e.detail }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })