index.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // pages/deviceConMode/index.js
  2. // const btHelper = require('../../devices/bt_helper');
  3. // const toastUtil = require('../../utils/toast_util');
  4. import routeUtil from '../../utils/route_util'
  5. import route_constant from '../../utils/route_constant.js'
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. scopeBluetooth: false,
  12. userFuzzyLocation: true,
  13. nvabarData: {
  14. showCapsule: 1, //是否显示左上角图标 1表示显示 0表示不显示
  15. title: '连接配网', //导航栏 中间的标题
  16. },
  17. isNotruter: false,
  18. model: 0,
  19. connectDevice: {},
  20. typeList: [
  21. {
  22. "icon": "../../images/device/mode_wifi.png",
  23. "text": "WiFi模式",
  24. "type": 2,
  25. },
  26. {
  27. "icon": "../../images/device/mode_ble.png",
  28. "text": "蓝牙模式",
  29. "type": 1,
  30. },
  31. {
  32. "icon": "../../images/device/mode_g4.png",
  33. "text": "4G模式",
  34. "type": 4,
  35. },
  36. ],
  37. },
  38. getModeName(curItem) {
  39. // 设备类型:1-蓝牙,2-Wifi,3-传统蓝牙,4-4G
  40. var str = "";
  41. if (curItem.deviceMode == 4) {
  42. str = "移动数据模式";
  43. } else if (curItem.deviceMode == 2) {
  44. str = "WiFi模式";
  45. } else if (curItem.deviceMode == 1) {
  46. str = "蓝牙模式";
  47. }
  48. return str;
  49. },
  50. nextTap(e) {
  51. let device = this.data.typeList[0];
  52. let type = device.type ?? 0;
  53. console.log("选择模式", type)
  54. if (type == 1) {
  55. // let device = e.currentTarget.dataset.data
  56. let json = JSON.stringify(this.data.connectDevice)
  57. routeUtil.jumpParam(route_constant.connectBle, json)
  58. // wx.navigateTo({
  59. // url: './../deviceDetail/detail',
  60. // });
  61. } else if (type == 2) {
  62. wx.navigateTo({
  63. url: './../deviceConnect0/deviceConnect0',
  64. });
  65. } else if (type == 3) {
  66. // btHelper.stopSearch()
  67. } else {
  68. }
  69. },
  70. async selectDeviceModelTap(e) {
  71. let device = e.currentTarget.dataset.device;
  72. // console.log(e)
  73. let type = device.type;
  74. if (type == 1) {
  75. // this.getConnectedDevices()
  76. } else if (type == 2) {
  77. } else if (type == 3) {
  78. // btHelper.stopSearch()
  79. } else {
  80. }
  81. var list = []
  82. list.push(device)
  83. this.data.typeList.forEach(element => {
  84. if (element.type != type) {
  85. list.push(element)
  86. }
  87. });
  88. this.setData({
  89. typeList: list,
  90. })
  91. },
  92. onLoad: function (options) {
  93. let json = JSON.parse(options.param)
  94. console.log(json)
  95. let device = json
  96. this.setData({
  97. connectDevice: device
  98. })
  99. if (getApp().globalData.isIOS) {
  100. } else { }
  101. },
  102. })