index.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. routeUtil.jumpParam(route_constant.connectBle, this.data.connectDevice)
  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. },
  99. /**
  100. * 生命周期函数--监听页面初次渲染完成
  101. */
  102. onReady() {
  103. },
  104. /**
  105. * 生命周期函数--监听页面显示
  106. */
  107. onShow() {
  108. },
  109. /**
  110. * 生命周期函数--监听页面隐藏
  111. */
  112. onHide() {
  113. },
  114. /**
  115. * 生命周期函数--监听页面卸载
  116. */
  117. onUnload() {
  118. },
  119. /**
  120. * 页面相关事件处理函数--监听用户下拉动作
  121. */
  122. onPullDownRefresh() {
  123. },
  124. /**
  125. * 页面上拉触底事件的处理函数
  126. */
  127. onReachBottom() {
  128. },
  129. /**
  130. * 用户点击右上角分享
  131. */
  132. onShareAppMessage() {
  133. }
  134. })