You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

194 lines
4.9 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. // pagesA/faceinfo/faceinfo.js
  2. import moment from '../../utils/moment'
  3. const WXAPI = require('../../utils/request')
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. deviceinfo: {},
  10. startdate: moment().format('YYYY-MM-DD HH:mm:ss'),
  11. enddate: moment().format('YYYY-MM-DD HH:mm:ss'),
  12. minDate: new Date().getTime(),
  13. currentDate: new Date().getTime(),
  14. selectDateStatus:false,
  15. selectDateStatus1:false,
  16. dateIndex:1,
  17. currentDate1:new Date().getTime(),
  18. facemessage: {}
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad: function (options) {
  24. var facemessage = wx.getStorageSync('facemessage')
  25. var deviceinfo = wx.getStorageSync('deviceinfo')
  26. console.log(facemessage);
  27. if(facemessage){
  28. let info = JSON.parse(facemessage.content)
  29. this.setData({
  30. facemessage,
  31. deviceinfo,
  32. startdate: moment(info.passwordStartTime * 1000).format('YYYY-MM-DD HH:mm:ss'),
  33. enddate: moment(info.passwordEndTime * 1000).format('YYYY-MM-DD HH:mm:ss'),
  34. })
  35. }
  36. },
  37. // 时间选择
  38. selectTimeMethods(event){
  39. console.log(event)
  40. if(event.currentTarget.dataset.index == 1){
  41. this.setData({
  42. dateIndex:event.currentTarget.dataset.index,
  43. selectDateStatus:true
  44. })
  45. }else if(event.currentTarget.dataset.index == 2){
  46. this.setData({
  47. dateIndex:event.currentTarget.dataset.index,
  48. selectDateStatus1:true
  49. })
  50. }
  51. },
  52. // 选择凭证有效期
  53. confirmMethods(event){
  54. let time = moment(event.detail).format("YYYY-MM-DD HH:mm:ss")
  55. if(this.data.dateIndex == 1){
  56. this.setData({
  57. startdate:time,
  58. currentDate: event.detail,
  59. minDate:event.detail
  60. })
  61. }else if(this.data.dateIndex == 2){
  62. this.setData({
  63. enddate:time,
  64. currentDate1: event.detail,
  65. })
  66. }
  67. this.setData({
  68. selectDateStatus: false,
  69. selectDateStatus1:false
  70. });
  71. },
  72. cancelMethods(event){
  73. this.setData({
  74. selectDateStatus: false,
  75. selectDateStatus1:false
  76. });
  77. },
  78. // 确定修改人脸时间
  79. sendface() {
  80. console.log(this.data.facemessage)
  81. var face = this.data.facemessage
  82. var content = JSON.parse(face.content)
  83. var startTime = moment(this.data.startdate).format('x') / 1000
  84. var endTime = moment(this.data.enddate).format('x') / 1000
  85. wx.showLoading({
  86. title: '修改凭证中...',
  87. })
  88. var dataface = {
  89. code: "lwj/faceOperate",
  90. data: {
  91. faceIndex: content.index,
  92. action: 3,
  93. endTime: endTime,
  94. faceData: content.faceData,
  95. lockerId: this.data.deviceinfo.deviceNum,
  96. lockerUserId: content.userPassword,
  97. startTime: startTime,
  98. operateMode: 21,
  99. order: 6221
  100. }
  101. }
  102. WXAPI.sendCommand(dataface).then(res => {
  103. console.log(res);
  104. if(res.success){
  105. content.operateMode = 21
  106. content.order = 6221
  107. content.passwordStartTime = startTime
  108. content.passwordEndTime = endTime
  109. let data1 = {
  110. id: face.id,
  111. content: JSON.stringify(content),
  112. startTime: startTime,
  113. endTime: endTime
  114. }
  115. WXAPI.updateCertificates(data1).then(res1 => {
  116. console.log(res1);
  117. if(res1.success){
  118. wx.hideLoading()
  119. wx.showToast({
  120. title: '修改凭证成功',
  121. icon: 'none',
  122. duration: 2000
  123. })
  124. setTimeout(() => {
  125. wx.navigateTo({
  126. url: '/pagesA/facepeople/facepeople',
  127. })
  128. }, 500)
  129. }else{
  130. wx.hideLoading()
  131. wx.showToast({
  132. title: '修改凭证失败',
  133. icon: "none",
  134. duration: 2000
  135. })
  136. }
  137. })
  138. }
  139. })
  140. },
  141. onChange(e) {
  142. this.data.facemessage.pzname = e.detail
  143. },
  144. /**
  145. * 生命周期函数--监听页面初次渲染完成
  146. */
  147. onReady: function () {
  148. },
  149. /**
  150. * 生命周期函数--监听页面显示
  151. */
  152. onShow: function () {
  153. },
  154. /**
  155. * 生命周期函数--监听页面隐藏
  156. */
  157. onHide: function () {
  158. },
  159. /**
  160. * 生命周期函数--监听页面卸载
  161. */
  162. onUnload: function () {
  163. },
  164. /**
  165. * 页面相关事件处理函数--监听用户下拉动作
  166. */
  167. onPullDownRefresh: function () {
  168. },
  169. /**
  170. * 页面上拉触底事件的处理函数
  171. */
  172. onReachBottom: function () {
  173. },
  174. /**
  175. * 用户点击右上角分享
  176. */
  177. onShareAppMessage: function () {
  178. }
  179. })