detail.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // pages/deviceDetail/detail.js
  2. const BtHelper = require('../../devices/bt_helper');
  3. const { deviceVersion } = require('../../request/deviceListRequest')
  4. import EventManager from '../../utils/event_bus'
  5. Page({
  6. data: {
  7. nvabarData: {
  8. showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
  9. title: '设备详情', //导航栏 中间的标题
  10. },
  11. hasNew: true,
  12. // 页面数据
  13. device: getApp().globalData.device,
  14. btHelper: null,
  15. },
  16. checkOtaVersion(device) {
  17. let _this = this;
  18. deviceVersion(device.clienlType, device.connectType, device.version).then(res => {
  19. console.log(res);
  20. let updateData = res.data;
  21. let hasNewVersion = updateData.isEnforcement === 1 || updateData.isEnforcement === 2;
  22. _this.setData({
  23. hasNew: hasNewVersion,
  24. });
  25. })
  26. },
  27. goToWallpaper: function () {
  28. wx.navigateTo({
  29. url: '/pages/piano/wallpaper/wallpaper'
  30. });
  31. },
  32. goToOta: function () {
  33. wx.navigateTo({
  34. url: '/pages/piano/wallpaper/wallpaper'
  35. });
  36. },
  37. /**
  38. * 生命周期函数--监听页面加载
  39. */
  40. onLoad: function () {
  41. let device = getApp().globalData.device;
  42. if (!device.connect) {
  43. // btHelper
  44. wx.showToast({
  45. title: '设备已经失去连接',
  46. })
  47. return;
  48. }
  49. const btHelper = BtHelper.getInstance();
  50. btHelper.getVersion()
  51. this.data.btHelper = btHelper;
  52. this.checkOtaVersion(device);
  53. EventManager.addNotification(CmdEvent,)
  54. },
  55. })