import selfpatrolservice from "../../../service/selfpatrolservice"; import moment from "../../../utils/moment.min"; const app = getApp() Page({ /** * 页面的初始数据 */ data: { date: '2026年01月20日', promiseText: app.globalData.userSetting.spPromiseContent, showDialog: false, promiseContent: '尊敬的用户:\n签署本承诺书后,您本年度内已上传的有效自巡查记录将无需每月重复上传,系统将视其为长期有效。您仍可随时上传新的巡查记录。\n请确保填写信息准确,承诺内容真实。虚假承诺可能导致服务终止并承担相应责任。', agree: false, confirmBtn: { content: '确认', variant: 'base' }, isReview:false, }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { var now = moment(); this.setData({ date: now.format('YYYY年MM月DD日'), }); // 获取参数:是否是查看承诺书 this.getOpenerEventChannel().on( 'acceptDataFromOpenerPage', (data) => { console.log('acceptDataFromOpenerPage', data); this.setData({ isReview: data.review }) }, ); }, checkboxChange(e) { var a = !this.data.agree; this.setData({ agree: a, }); }, waitAgree() { if (this.data.agree) { return true; } else { wx.showToast({ title: '请勾选同意条款', icon: 'none', }); return false; } }, showCheckDialog() { if (this.waitAgree()) { this.setData({ showDialog: true }) } }, closeCheckDialog() { this.setData({ showDialog: false }) }, /** * 签署自巡查承诺书 */ doPromise() { selfpatrolservice.signPromise(app.globalData.accessToken.userId, { success: res => { // app.globalData.userSetting = res.data this.getOpenerEventChannel().emit('doPromiseDone', { promised: res.data.selfPatrolPromised, promiseTime: res.data.lastPromisedTime, }); wx.navigateBack({ delta: 1, }); } }) }, })