firmware.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. showInfo: true
  25. },
  26. /**
  27. * 生命周期函数--监听页面加载
  28. */
  29. onLoad(options) {
  30. },
  31. /**
  32. * 生命周期函数--监听页面初次渲染完成
  33. */
  34. onReady() {
  35. },
  36. /**
  37. * 生命周期函数--监听页面显示
  38. */
  39. onShow() {
  40. },
  41. // 在需要弹窗的地方调用该函数
  42. toUpdate() {
  43. var that = this;
  44. wx.showModal({
  45. title: '有新固件可升级',
  46. content: '提升体验,操作更流畅',
  47. showCancel: true,
  48. cancelText: '取消',
  49. confirmText: '确定',
  50. success: function (res) {
  51. if (res.confirm) {
  52. console.log('用户点击确定');
  53. that.showUpgradeProgress();
  54. } else if (res.cancel) {
  55. console.log('用户点击取消');
  56. }
  57. }
  58. });
  59. },
  60. // 显示升级进度条模态框
  61. showProgressModal: function () {
  62. var that = this;
  63. that.setData({
  64. showModal: true
  65. });
  66. // 模拟更新进度
  67. let interval = setInterval(() => {
  68. var progress = that.data.progress;
  69. if (progress < 100) {
  70. console.log("gassdfadfasdfaf====" + progress);
  71. that.setData({
  72. progress: progress + 1,
  73. });
  74. } else {
  75. clearInterval(interval);
  76. // 更新完成后关闭模态框
  77. that.setData({
  78. showModal: false,
  79. progress: 0
  80. });
  81. }
  82. }, 100);
  83. },
  84. /**
  85. * 生命周期函数--监听页面隐藏
  86. */
  87. onHide() {
  88. },
  89. /**
  90. * 生命周期函数--监听页面卸载
  91. */
  92. onUnload() {
  93. },
  94. /**
  95. * 页面相关事件处理函数--监听用户下拉动作
  96. */
  97. onPullDownRefresh() {
  98. },
  99. /**
  100. * 页面上拉触底事件的处理函数
  101. */
  102. onReachBottom() {
  103. },
  104. /**
  105. * 用户点击右上角分享
  106. */
  107. onShareAppMessage() {
  108. }
  109. })