index.js 2.2 KB

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