index.js 3.0 KB

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