// pages/piano/firmware/firmware.js Page({ /** * 页面的初始数据 */ data: { nvabarData: { showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示 title: '固件信息', //导航栏 中间的标题 }, topList: [{ title: "制造商", name: "Air Smart", }, { title: "产品型号", name: "MW-OTR", }, { title: "MAC地址", name: "4b:45:12:5a:9y:3g", }, ], isUpdated: true, showModal: false, // 控制模态框显示隐藏 progress: 0, // 进度条初始值 }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, // 在需要弹窗的地方调用该函数 toUpdate() { var that = this; wx.showModal({ title: '有新固件可升级', content: '提升体验,操作更流畅', showCancel: true, cancelText: '取消', confirmText: '确定', success: function (res) { if (res.confirm) { console.log('用户点击确定'); that.showUpgradeProgress(); } else if (res.cancel) { console.log('用户点击取消'); } } }); }, // 显示升级进度条模态框 showUpgradeProgress: function () { var that = this; that.setData({ showModal: true }); // 模拟更新进度 let interval = setInterval(() => { var progress = that.data.progress; if (progress < 100) { console.log("gassdfadfasdfaf====" + progress); that.setData({ progress: progress + 0.1, }); } else { clearInterval(interval); // 更新完成后关闭模态框 that.setData({ showModal: false, progress: 0 }); } }, 10); }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })