firmware.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. // pages/piano/firmware/firmware.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. nvabarData: {
  8. showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
  9. title: '固件信息', //导航栏 中间的标题
  10. },
  11. topList: [{
  12. title: "制造商",
  13. name: "Air Smart",
  14. }, {
  15. title: "产品型号",
  16. name: "MW-OTR",
  17. }, {
  18. title: "MAC地址",
  19. name: "4b:45:12:5a:9y:3g",
  20. }, ],
  21. isUpdated: true,
  22. showModal: false, // 控制模态框显示隐藏
  23. progress: 0, // 进度条初始值
  24. },
  25. /**
  26. * 生命周期函数--监听页面加载
  27. */
  28. onLoad(options) {
  29. },
  30. /**
  31. * 生命周期函数--监听页面初次渲染完成
  32. */
  33. onReady() {
  34. },
  35. /**
  36. * 生命周期函数--监听页面显示
  37. */
  38. onShow() {
  39. },
  40. // 在需要弹窗的地方调用该函数
  41. toUpdate() {
  42. var that = this;
  43. wx.showModal({
  44. title: '有新固件可升级',
  45. content: '提升体验,操作更流畅',
  46. showCancel: true,
  47. cancelText: '取消',
  48. confirmText: '确定',
  49. success: function (res) {
  50. if (res.confirm) {
  51. console.log('用户点击确定');
  52. that.showUpgradeProgress();
  53. } else if (res.cancel) {
  54. console.log('用户点击取消');
  55. }
  56. }
  57. });
  58. },
  59. // 显示升级进度条模态框
  60. showUpgradeProgress: function () {
  61. var that = this;
  62. that.setData({
  63. showModal: true
  64. });
  65. // 模拟更新进度
  66. let interval = setInterval(() => {
  67. var progress = that.data.progress;
  68. if (progress < 100) {
  69. that.setData({
  70. progress: progress + 0.1,
  71. });
  72. } else {
  73. clearInterval(interval);
  74. // 更新完成后关闭模态框
  75. that.setData({
  76. showModal: false,
  77. progress: 0
  78. });
  79. }
  80. }, 10);
  81. },
  82. /**
  83. * 生命周期函数--监听页面隐藏
  84. */
  85. onHide() {
  86. },
  87. /**
  88. * 生命周期函数--监听页面卸载
  89. */
  90. onUnload() {
  91. },
  92. /**
  93. * 页面相关事件处理函数--监听用户下拉动作
  94. */
  95. onPullDownRefresh() {
  96. },
  97. /**
  98. * 页面上拉触底事件的处理函数
  99. */
  100. onReachBottom() {
  101. },
  102. /**
  103. * 用户点击右上角分享
  104. */
  105. onShareAppMessage() {
  106. }
  107. })