// pages/recordPages/yyjl/yyjl.js import { xcxqxyy, xcxyyhh, xcxsxph } from "../../../apis/index" Page({ /** * 页面的初始数据 */ data: { infos: {}, nowTime: "", timer: null, khh: false }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { let that = this that.init(options) that.setData({ nowTime: that.getTime() }) }, init(e) { let that = this if (e) { if (e.infos) { let infos = JSON.parse(e.infos) that.setData({ infos: infos }) if (infos.ztDm == 2 || infos.ztDm == 3) { that.chageNum() } if (infos.ztDm == 0) { let datetime = { date: that.data.infos.yybsrq, time: that.data.infos.yysjd } that.setData({ khh: that.timeFormat(datetime) }) } } } }, getTime() { let date = new Date() let y = date.getFullYear() let m = date.getMonth() + 1 < 10 ? '0' + (date.getMonth()) + 1 : date.getMonth() + 1 let d = date.getDate() < 10 ? '0' + date.getDate() : date.getDate() let h = date.getHours() < 10 ? '0' + date.getHours() : date.getHours() let mm = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes() let ss = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds() return y + '-' + m + '-' + d + ' ' + h + ':' + mm + ':' + ss }, cansole() { let that = this wx.showLoading({ title: '正在取消...', }) xcxqxyy({ yymxxh: that.data.infos.yymxxh }).then(res => { wx.hideLoading() if (res.code == 200) { wx.showToast({ title: '取消成功', duration: 2000 }) setTimeout(() => { wx.navigateBack() }, 2000); } else { wx.showToast({ title: res.msg || res.message, icon: "none", duration: 5000 }) } }) }, timeFormat(e) { let date = e.date let time1 = e.time1 let time2 = e.time2 let date1 = date + 'T' + time1 let date2 = date + 'T' + time2 let timestamp1 = new Date(date1).getTime() let timestamp2 = new Date(date2).getTime() let nowstamp = new Date().getTime() if (nowstamp >= timestamp1 && nowstamp < timestamp2) { return true } else { return false } }, chageNum() { let that = this let datetime = { date: that.data.infos.yybsrq, time1: that.data.infos.yyqpkssj, time2: that.data.infos.yyqpjssj } if (that.timeFormat(datetime)) { wx.showLoading({ title: '', }) let form = { unionid: wx.getStorageSync('PUBLIC_ID').unionid, yymxxh: that.data.infos.yymxxh } xcxyyhh(form).then(res => { wx.hideLoading() if (res.code == 200) { res.data.ztDm = 2 that.setData({ infos: { ...that.data.infos, ...res.data } }) } else if (res.code == 201) { res.data.ztDm = 2 that.setData({ infos: { ...that.data.infos, ...res.data } }) } else { wx.showToast({ title: res.msg || res.message, icon: "none", duration: 5000 }) } }) } }, brush() { let that = this let infos = that.data.infos wx.showLoading({ title: '正在刷新...', }) xcxsxph({ bsfwtDm: infos.bsfwtDm, phhm: infos.ticketNum, qpsj: infos.createTime }).then(res => { wx.hideLoading() if (res.code == 200) { if (res.data.phzt == 0) { that.setData({ infos: { ...that.data.infos, ...res.data } }) } else { that.setData({ infos: { ...that.data.infos, ...res.data } }) if (res.data.fwztDm == 0) { wx.showModal({ title: '提示', content: '当前已叫到您的号码,请立即前往' + res.data.ckhm + "窗口进行办理业务。", }) } else { wx.showModal({ title: '提示', content: '当前号码已经叫过了,请前往' + res.data.ckhm + "窗口进行咨询。" }) } } } else { wx.showToast({ title: res.msg || res.message, icon: "none", duration: 5000 }) } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { let that = this let timer = that.data.timer clearInterval(timer) timer = setInterval(() => { that.setData({ nowTime: that.getTime() }) if (that.data.infos.ztDm == 0) { let datetime = { date: that.data.infos.yybsrq, time: that.data.infos.yysjd } that.setData({ khh: that.timeFormat(datetime) }) } }, 1000); that.setData({ timer: timer }) }, /** * 生命周期函数--监听页面隐藏 */ onHide() { let that = this let timer = that.data.timer clearInterval(timer) that.setData({ timer: null }) }, /** * 生命周期函数--监听页面卸载 */ onUnload() { let that = this let timer = that.data.timer clearInterval(timer) that.setData({ timer: null }) }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })