firmware.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. console.log("gassdfadfasdfaf====" + progress);
  70. that.setData({
  71. progress: progress + 0.1,
  72. });
  73. } else {
  74. clearInterval(interval);
  75. // 更新完成后关闭模态框
  76. that.setData({
  77. showModal: false,
  78. progress: 0
  79. });
  80. }
  81. }, 10);
  82. },
  83. /**
  84. * 生命周期函数--监听页面隐藏
  85. */
  86. onHide() {
  87. },
  88. /**
  89. * 生命周期函数--监听页面卸载
  90. */
  91. onUnload() {
  92. },
  93. /**
  94. * 页面相关事件处理函数--监听用户下拉动作
  95. */
  96. onPullDownRefresh() {
  97. },
  98. /**
  99. * 页面上拉触底事件的处理函数
  100. */
  101. onReachBottom() {
  102. },
  103. /**
  104. * 用户点击右上角分享
  105. */
  106. onShareAppMessage() {
  107. }
  108. })