index.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. "icon": "../../images/device/mode_wifi.png",
  22. "text": "WiFi模式",
  23. "type": 2,
  24. },
  25. {
  26. "icon": "../../images/device/mode_ble.png",
  27. "text": "蓝牙模式",
  28. "type": 1,
  29. },
  30. {
  31. "icon": "../../images/device/mode_g4.png",
  32. "text": "4G模式",
  33. "type": 4,
  34. },
  35. ],
  36. },
  37. getModeName(curItem) {
  38. // 设备类型:1-蓝牙,2-Wifi,3-传统蓝牙,4-4G
  39. var str = "";
  40. if (curItem.deviceMode == 4) {
  41. str = "移动数据模式";
  42. } else if (curItem.deviceMode == 2) {
  43. str = "WiFi模式";
  44. } else if (curItem.deviceMode == 1) {
  45. str = "蓝牙模式";
  46. }
  47. return str;
  48. },
  49. nextTap(e) {
  50. let device = this.data.typeList[0];
  51. let type = device.type ?? 0;
  52. console.log("选择模式", type)
  53. if (type == 1) {
  54. // let device = e.currentTarget.dataset.data
  55. let json = JSON.stringify(this.data.connectDevice)
  56. routeUtil.jumpParam(route_constant.connectBle, json)
  57. } else if (type == 2) {
  58. wx.navigateTo({
  59. url: './../deviceConnect0/deviceConnect0',
  60. });
  61. } else if (type == 3) {
  62. // btHelper.stopSearch()
  63. } else {
  64. }
  65. },
  66. async selectDeviceModelTap(e) {
  67. let device = e.currentTarget.dataset.device;
  68. // console.log(e)
  69. let type = device.type;
  70. if (type == 1) {
  71. // this.getConnectedDevices()
  72. } else if (type == 2) {
  73. } else if (type == 3) {
  74. // btHelper.stopSearch()
  75. } else {
  76. }
  77. var list = []
  78. list.push(device)
  79. this.data.typeList.forEach(element => {
  80. if (element.type != type) {
  81. list.push(element)
  82. }
  83. });
  84. this.setData({
  85. typeList: list,
  86. })
  87. },
  88. onLoad: function (options) {
  89. let json = JSON.parse(options.param)
  90. console.log(json)
  91. let device = json
  92. this.setData({
  93. connectDevice: device
  94. })
  95. if (getApp().globalData.isIOS) {
  96. } else {}
  97. },
  98. })