index.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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: "",
  19. connectDevice: {},
  20. typeList: [
  21. ],
  22. },
  23. getModeName(curItem) {
  24. // 设备类型:1-蓝牙,2-Wifi,3-传统蓝牙,4-4G
  25. var str = "";
  26. if (curItem.type == 4) {
  27. str = "移动数据模式";
  28. } else if (curItem.type == 2) {
  29. str = "WiFi模式";
  30. } else if (curItem.type == 1) {
  31. str = "蓝牙模式";
  32. }
  33. return str;
  34. },
  35. nextTap(e) {
  36. let device = this.data.typeList[0];
  37. let type = device.connectType ?? 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. } else if (type == 2) {
  44. wx.navigateTo({
  45. url: './../deviceConnect0/deviceConnect0',
  46. });
  47. } else if (type == 3) {
  48. // btHelper.stopSearch()
  49. } else {
  50. }
  51. },
  52. async selectDeviceModelTap(e) {
  53. let device = e.currentTarget.dataset.device;
  54. // console.log(e)
  55. let type = device.connectType;
  56. if (type == 1) {
  57. // this.getConnectedDevices()
  58. } else if (type == 2) {
  59. } else if (type == 3) {
  60. // btHelper.stopSearch()
  61. } else {
  62. }
  63. var list = []
  64. list.push(device)
  65. this.data.typeList.forEach(element => {
  66. if (element.connectType != type) {
  67. list.push(element)
  68. }
  69. });
  70. this.setData({
  71. typeList: list,
  72. model: this.getModeName(device.typeList)
  73. })
  74. },
  75. onLoad: function (options) {
  76. let json = JSON.parse(options.param)
  77. console.log(json)
  78. let device = json
  79. let typeList = json.typeList.map(e => {
  80. return {
  81. icon: "../../images/device/mode_" + e.connectType + ".png",
  82. text: this.getModeName(e),
  83. connectType: e.connectType
  84. }
  85. })
  86. this.setData({
  87. connectDevice: device,
  88. typeList: typeList
  89. })
  90. if (getApp().globalData.isIOS) {
  91. } else {
  92. }
  93. },
  94. /**
  95. * 生命周期函数--监听页面初次渲染完成
  96. */
  97. onReady() {
  98. },
  99. /**
  100. * 生命周期函数--监听页面显示
  101. */
  102. onShow() {
  103. },
  104. /**
  105. * 生命周期函数--监听页面隐藏
  106. */
  107. onHide() {
  108. },
  109. /**
  110. * 生命周期函数--监听页面卸载
  111. */
  112. onUnload() {
  113. },
  114. /**
  115. * 页面相关事件处理函数--监听用户下拉动作
  116. */
  117. onPullDownRefresh() {
  118. },
  119. /**
  120. * 页面上拉触底事件的处理函数
  121. */
  122. onReachBottom() {
  123. },
  124. /**
  125. * 用户点击右上角分享
  126. */
  127. onShareAppMessage() {
  128. }
  129. })