index.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. } else if (type == 2) {
  59. wx.navigateTo({
  60. url: './../deviceConnect0/deviceConnect0',
  61. });
  62. } else if (type == 3) {
  63. // btHelper.stopSearch()
  64. } else {
  65. }
  66. },
  67. async selectDeviceModelTap(e) {
  68. let device = e.currentTarget.dataset.device;
  69. // console.log(e)
  70. let type = device.type;
  71. if (type == 1) {
  72. // this.getConnectedDevices()
  73. } else if (type == 2) {
  74. } else if (type == 3) {
  75. // btHelper.stopSearch()
  76. } else {
  77. }
  78. var list = []
  79. list.push(device)
  80. this.data.typeList.forEach(element => {
  81. if (element.type != type) {
  82. list.push(element)
  83. }
  84. });
  85. this.setData({
  86. typeList: list,
  87. })
  88. },
  89. onLoad: function (options) {
  90. let json = JSON.parse(options.param)
  91. console.log(json)
  92. let device = json
  93. this.setData({
  94. connectDevice: device
  95. })
  96. if (getApp().globalData.isIOS) {
  97. } else {
  98. }
  99. },
  100. /**
  101. * 生命周期函数--监听页面初次渲染完成
  102. */
  103. onReady() {
  104. },
  105. /**
  106. * 生命周期函数--监听页面显示
  107. */
  108. onShow() {
  109. },
  110. /**
  111. * 生命周期函数--监听页面隐藏
  112. */
  113. onHide() {
  114. },
  115. /**
  116. * 生命周期函数--监听页面卸载
  117. */
  118. onUnload() {
  119. },
  120. /**
  121. * 页面相关事件处理函数--监听用户下拉动作
  122. */
  123. onPullDownRefresh() {
  124. },
  125. /**
  126. * 页面上拉触底事件的处理函数
  127. */
  128. onReachBottom() {
  129. },
  130. /**
  131. * 用户点击右上角分享
  132. */
  133. onShareAppMessage() {
  134. }
  135. })