addMattresses.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770
  1. // subpages/addMattresses/addMattresses.js
  2. const app = getApp();
  3. const util = require('../../utils/util.js');
  4. const timeOut = 20; //超时时间
  5. var timeId = "";
  6. var sequenceControl = 0;
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. isEdit:false,
  13. showBluetoothList: false,
  14. showBluetoothConnected: false,//连接中
  15. isBluetoothConnected: false,//连接成功
  16. bluetoothConnectedStep: 0,
  17. placeOfUse: "",
  18. usingHuman: "",
  19. pid:"",
  20. sn: "",
  21. ssid: "",
  22. password: "",
  23. bluetoothSelectIndex: -1,
  24. activeIcon: "/subpages/images/ic_blue_radio_check.png",
  25. normalIcon: "/subpages/images/ic_blue_radio_uncheck.png",
  26. deviceList: [],
  27. deviceId: "",
  28. deviceIds: [],
  29. wifiInfo: null,
  30. deviceId: "",
  31. password: "",
  32. notice: "",
  33. value: 90,
  34. gradientColor: {
  35. '0%': '#00CEB2',
  36. '50%': '#00C7FF',
  37. '100%': '#53DAFF',
  38. },
  39. statusDefault: ['蓝牙连接...', '蓝牙连接成功', '成功获取设备信息', '获取属性信息成功', '发送配置信息...', '配置信息发送成功', '连接成功'],
  40. descFailList: ["蓝牙连接失败", "获取设备信息失败", "获取属性信息失败", "发送配置信息失败", "分配网络失败"],
  41. failure: false,
  42. value: 0,
  43. desc: "设备连接...",
  44. blueConnectNum: 0,
  45. isChecksum: true,
  46. isEncrypt: false,
  47. flagEnd: false,
  48. defaultData: 1,
  49. ssidType: 2,
  50. passwordType: 3,
  51. meshIdType: 3,
  52. deviceNo: 0,
  53. uuid: "",
  54. serviceId: "",
  55. meshId: "",
  56. processList: [],
  57. result: [],
  58. },
  59. onClose() {
  60. this.setData({ showBluetoothList: false, showBluetoothConnected: false });
  61. },
  62. checkBluetoothSelectIndex(e) {
  63. const index = e.currentTarget.dataset.index;
  64. this.setData({ bluetoothSelectIndex: index });
  65. },
  66. commitData() {
  67. console.log(this.data.placeOfUse);
  68. console.log(this.data.usingHuman);
  69. console.log(this.data.deviceId);
  70. console.log(this.data.ssid);
  71. console.log(this.data.password);
  72. this.checkSn(this.data.deviceId);
  73. },
  74. commitUserData() {
  75. const that = this;
  76. if (that.data.isEdit) {
  77. wx.request({
  78. url: 'https://aipush.aidsleep.cn/customeredit',
  79. method: 'POST',
  80. data: {
  81. token: "89835e65993fee4a6a6cbbe4c271da51e5521822934e13769e61cadabaed72c3" || wx.getStorageSync('token'),
  82. pid: this.data.pid,
  83. sntram: this.data.deviceId,
  84. per: this.data.usingHuman,
  85. loc: this.data.placeOfUse,
  86. },
  87. success: (res) => {
  88. var codes = res.data.codes;
  89. if (codes && codes == 'success') {
  90. wx.showToast({
  91. icon: 'none',
  92. title: "添加成功"
  93. });
  94. setTimeout(() => {
  95. wx.navigateBack()
  96. }, 800);
  97. } else {
  98. wx.showToast({
  99. icon: 'none',
  100. title: "添加失败"
  101. });
  102. }
  103. },
  104. fail: () => {
  105. wx.showToast({
  106. icon: 'none',
  107. title: "添加失败"
  108. });
  109. }
  110. });
  111. return
  112. }
  113. wx.request({
  114. url: 'https://aipush.aidsleep.cn/wxsaveunionsn',
  115. method: 'POST',
  116. data: {
  117. token: "89835e65993fee4a6a6cbbe4c271da51e5521822934e13769e61cadabaed72c3" || wx.getStorageSync('token'),
  118. unionid: wx.getStorageSync("unionid"),
  119. sntram: this.data.deviceId,
  120. per: this.data.usingHuman,
  121. loc: this.data.placeOfUse,
  122. },
  123. success: (res) => {
  124. var codes = res.data.codes;
  125. if (codes && codes == 'success') {
  126. wx.showToast({
  127. icon: 'none',
  128. title: "添加成功"
  129. });
  130. setTimeout(() => {
  131. wx.navigateBack()
  132. }, 800);
  133. } else {
  134. wx.showToast({
  135. icon: 'none',
  136. title: "添加失败"
  137. });
  138. }
  139. },
  140. fail: () => {
  141. wx.showToast({
  142. icon: 'none',
  143. title: "添加失败"
  144. });
  145. }
  146. });
  147. },
  148. // 开启蓝牙
  149. bindViewBlue: function () {
  150. const that = this;
  151. wx.closeBluetoothAdapter();
  152. wx.openBluetoothAdapter({
  153. success(res) {
  154. //console.log(res);
  155. that.getBluDevice()
  156. },
  157. fail(res) {
  158. console.log(res);
  159. wx.showToast({
  160. icon:'none',
  161. title: "请打开系统蓝牙"
  162. });
  163. }
  164. })
  165. },
  166. // 获取蓝牙设备列表
  167. getBluDevice () {
  168. var self = this;
  169. //第一步检查蓝牙适配器是否可用
  170. wx.onBluetoothAdapterStateChange(function (res) {
  171. if (!res.available) {
  172. util.showToast('蓝牙不可用');
  173. return false;
  174. }
  175. });
  176. //第二步关闭适配器,重新来搜索
  177. wx.openBluetoothAdapter({
  178. success: function (res) {
  179. wx.getBluetoothAdapterState({
  180. success: function (res) {
  181. wx.stopBluetoothDevicesDiscovery({
  182. success: function (res) {
  183. wx.startBluetoothDevicesDiscovery({
  184. success: function (res) {
  185. wx.onBluetoothDeviceFound(function (res) {
  186. console.log(res);
  187. var list = util.filterDevice(res.devices, "name");
  188. if (list.length > 0) {
  189. console.log('==========onBluetoothDeviceFound===========');
  190. console.log(list);
  191. var deviceList = self.data.deviceList;
  192. var doDevices = wx.getStorageSync('doDevices');
  193. if (doDevices) {
  194. } else {
  195. doDevices = [];
  196. }
  197. console.log(deviceList);
  198. console.log(doDevices);
  199. wx.setStorageSync('doDevices', doDevices);
  200. wx.hideLoading();
  201. list.forEach(function (item) {
  202. var flag = true;
  203. for (var i = 0; i < deviceList.length; i++) {
  204. var itemSub = deviceList[i];
  205. if (itemSub.deviceId === item.deviceId) {
  206. flag = false;
  207. break;
  208. }
  209. }
  210. if (flag) {
  211. var arrD = item['name'].split(' ');
  212. item['sn'] = arrD[1];
  213. wx.request({
  214. url: 'https://aipush.aidsleep.cn/checkbeds',
  215. method: 'POST',
  216. header: {
  217. 'content-type': 'application/json' // 设置请求的 header
  218. },
  219. data: {
  220. "snlists": arrD[1], // 需要发送的数据
  221. "token": "89835e65993fee4a6a6cbbe4c271da51e5521822934e13769e61cadabaed72c3"
  222. },
  223. success: function (res) {
  224. //console.log(res);
  225. if (res.data.data[arrD[1]].trim() == 'yes') {
  226. item['beOnline'] = 'icon-deng-ok';
  227. } else {
  228. item['beOnline'] = '';
  229. if (doDevices.indexOf(item['deviceId']) >= 0) {
  230. item['beOnline'] = 'icon-deng-ok';
  231. }
  232. }
  233. deviceList.push(item);
  234. self.setData({
  235. deviceList: deviceList,
  236. showBluetoothList:true
  237. });
  238. wx.setStorageSync('deviceList', deviceList);
  239. },
  240. fail: function (error) {
  241. console.error(error);
  242. }
  243. });
  244. }
  245. })
  246. }
  247. })
  248. }
  249. })
  250. },
  251. fail: function (res) {
  252. console.log(res);
  253. }
  254. });
  255. },
  256. fail: function (res) {
  257. console.log(res);
  258. }
  259. });
  260. },
  261. fail: function (res) {
  262. console.log(res);
  263. }
  264. });
  265. },
  266. commitBluetooth() {
  267. this.onClose();
  268. var deviceId = this.data.deviceList[this.data.bluetoothSelectIndex].deviceId;
  269. this.setData({
  270. deviceId: deviceId,
  271. sn:deviceId
  272. })
  273. },
  274. // 开始配网
  275. bindViewConnect() {
  276. const that = this;
  277. if (bluetoothSelectIndex < 0) {
  278. util.showToast("没有指定要配网的设备");
  279. return false;
  280. }
  281. var deviceIds = this.data.deviceList[this.data.bluetoothSelectIndex];
  282. if (this.data.deviceList.length == 0 || deviceIds.length === 0) {
  283. util.showToast("没有指定要配网的设备");
  284. return false;
  285. }
  286. that.gotoProvision()
  287. },
  288. // 获取Wifi
  289. getWifiInfo: function () {
  290. wx.startWifi({
  291. success(res) {
  292. //console.log(' ================== startWifi ================== ');
  293. //console.log(res);
  294. wx.getConnectedWifi({
  295. success(res) {
  296. },
  297. fail: function (err) {
  298. console.log(' ================== startWifi fail ================== ');
  299. console.log(err);
  300. if (app.data.sytem == 'ios') {
  301. util.showToast("获取Wi-Fi信息失败,请更新微信到最新版");
  302. } else {
  303. util.showToast("获取Wi-Fi信息失败");
  304. }
  305. }
  306. });
  307. }
  308. });
  309. const self = this;
  310. wx.startWifi({
  311. success(res) {
  312. //console.log(res)
  313. // 先取一次,防止IOS获取不到
  314. wx.getConnectedWifi({
  315. success(res) {
  316. self.setData({
  317. wifiInfo: res.wifi,
  318. ssid: res.wifi.SSID
  319. });
  320. //console.log('== getConnectedWifi ==');
  321. //console.log(res);
  322. if (res.frequency >= 2412 && res.frequency <= 2472) { } else {
  323. self.setData({
  324. notice: "温馨提示:当前您连接的Wi-Fi网络是5G频段,建议连接2.4G频段配网"
  325. })
  326. }
  327. },
  328. fail: function (err) {
  329. util.showToast("获取Wi-Fi信息失败");
  330. }
  331. })
  332. wx.onWifiConnected(function (res) {
  333. // console.log('== onWifiConnected ==');
  334. // console.log(res);
  335. self.setData({
  336. wifiInfo: res.wifi
  337. })
  338. })
  339. },
  340. fail(res) {
  341. console.log('WIFI初始化失败', res)
  342. util.showToast("WIFI初始化失败");
  343. }
  344. })
  345. },
  346. gotoProvision: function () {
  347. const wifiInfo = this.data.wifiInfo;
  348. const ssid = wifiInfo != null ? wifiInfo.SSID : null;
  349. const bssid = wifiInfo != null ? wifiInfo.BSSID : null;
  350. const password = this.data.password;
  351. if (wifiInfo == null) {
  352. util.showToast("没有Wi-Fi连接");
  353. return;
  354. } else {
  355. if (ssid == null || ssid == '' || password == '') {
  356. util.showToast("WiFi登录名和密码不能为空");
  357. return;
  358. } else {
  359. const info = {
  360. ssid: ssid,
  361. bssid: bssid,
  362. password: password,
  363. deviceIds: this.data.deviceId
  364. }
  365. this.blueConnect();
  366. }
  367. }
  368. },
  369. // 蓝牙链接
  370. blueConnect: function (event) {
  371. //console.log(' =============== blueConnect start ===============')
  372. var self = this;
  373. sequenceControl = 0;
  374. self.setData({
  375. flagEnd: false,
  376. serviceId: "",
  377. uuid: "",
  378. showBluetoothConnected:true
  379. });
  380. self.setProcess(0, util.descSucList[0],1);
  381. //第一步检查蓝牙适配器是否可用
  382. wx.onBluetoothAdapterStateChange(function (res) {
  383. if (!res.available) {
  384. util.showToast('蓝牙不可用');
  385. return false;
  386. }
  387. });
  388. //console.log(app.data);
  389. if (app.data.sytem == 'ios') {
  390. }
  391. //console.log('deviceId = ' + self.data.deviceId)
  392. wx.createBLEConnection({
  393. // 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
  394. deviceId: self.data.deviceId,
  395. timeout: 10000,
  396. success: function (res) {
  397. wx.setBLEMTU({
  398. deviceId: self.data.deviceId,
  399. mtu: 128
  400. })
  401. //console.log("============ createBLEConnection success =============")
  402. //console.log(self.data.deviceId)
  403. self.getDeviceServices(self.data.deviceId);
  404. },
  405. fail: function (res) {
  406. console.log("============ createBLEConnection fail =============")
  407. console.log(res)
  408. console.log(self.data.blueConnectNum)
  409. var num = self.data.blueConnectNum;
  410. if (num < 3) {
  411. self.blueConnect();
  412. num++;
  413. self.setData({
  414. blueConnectNum: num
  415. })
  416. } else {
  417. self.setFailProcess(true, res.errCode + "::" + util.descFailList[0]);
  418. }
  419. }
  420. })
  421. },
  422. getDeviceServices: function (deviceId) {
  423. var self = this;
  424. wx.getBLEDeviceServices({
  425. // 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
  426. deviceId: deviceId,
  427. success: function (res) {
  428. self.setProcess(10, util.descSucList[1],2);
  429. var services = res.services;
  430. if (services.length > 0) {
  431. for (var i = 0; i < services.length; i++) {
  432. var uuid = services[i].uuid;
  433. if (uuid == app.data.service_uuid) {
  434. self.getDeviceCharacteristics(deviceId, uuid);
  435. return false;
  436. }
  437. }
  438. }
  439. },
  440. fail: function (res) {
  441. self.setFailProcess(true, res.errCode + "::" + util.descFailList[1]);
  442. }
  443. })
  444. },
  445. getDeviceCharacteristics: function (deviceId, serviceId) {
  446. //console.log(" ============== getDeviceCharacteristics =============== ");
  447. var self = this;
  448. wx.getBLEDeviceCharacteristics({
  449. // 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
  450. deviceId: deviceId,
  451. serviceId: serviceId,
  452. success: function (res) {
  453. self.setProcess(40, util.descSucList[2],3);
  454. var list = res.characteristics;
  455. if (list.length > 0) {
  456. for (var i = 0; i < list.length; i++) {
  457. var uuid = list[i].uuid;
  458. if (uuid == app.data.characteristic_write_uuid) {
  459. self.openNotify(deviceId, serviceId, uuid);
  460. self.setData({
  461. serviceId: serviceId,
  462. uuid: uuid,
  463. })
  464. return false;
  465. }
  466. }
  467. }
  468. },
  469. fail: function (res) {
  470. console.log(res);
  471. self.setFailProcess(true, res.errCode + "::" + util.descFailList[2]);
  472. }
  473. })
  474. },
  475. //连接超时
  476. onTimeout: function (num) {
  477. const self = this;
  478. timeId = setInterval(function () {
  479. if (num < timeOut) {
  480. num++;
  481. } else {
  482. clearInterval(timeId);
  483. self.setFailProcess(true, res.errCode + "::" + util.descFailList[4]);
  484. }
  485. }, 1000)
  486. },
  487. //启用通知
  488. openNotify: function (deviceId, serviceId, characteristicId) {
  489. //console.log("=========== openNotify ============");
  490. var self = this;
  491. wx.notifyBLECharacteristicValueChange({
  492. state: true, // 启用 notify 功能
  493. deviceId: deviceId,
  494. serviceId: serviceId,
  495. characteristicId: app.data.characteristic_read_uuid,
  496. success: function (res) {
  497. //console.log(res);
  498. self.writeDevice(deviceId, serviceId, characteristicId, null);
  499. self.onNotify();
  500. },
  501. fail: function (res) {
  502. console.log(res);
  503. }
  504. })
  505. },
  506. //监听通知
  507. onNotify: function () {
  508. //console.log("=========== onNotify ============");
  509. var self = this;
  510. wx.onBLECharacteristicValueChange(function (res) {
  511. //console.log(res);
  512. self.getResultType(util.ab2hex(res.value));
  513. })
  514. },
  515. // 设备数据开始写入
  516. writeDevice: function (deviceId, serviceId, characteristicId, data) {
  517. //console.log("===== writeDevice =====");
  518. var self = this,
  519. obj = {};
  520. self.setProcess(60, util.descSucList[4],3);
  521. sequenceControl = parseInt(sequenceControl) + 1;
  522. if (!util._isEmpty(data)) {
  523. obj = util.isSubcontractor(data, true, sequenceControl);
  524. } else {
  525. data = util.writeData(self.getCharCodeat('"' + self.data.ssid + '","' + self.data.password + '"'));
  526. obj = util.isSubcontractor(data, self.data.isChecksum, sequenceControl);
  527. }
  528. var typedArray = new Uint8Array(obj.lenData)
  529. wx.writeBLECharacteristicValue({
  530. deviceId: deviceId,
  531. serviceId: serviceId,
  532. characteristicId: characteristicId,
  533. value: typedArray.buffer,
  534. success: function (res) {
  535. //console.log(res);
  536. if (obj.flag) {
  537. self.writeDevice(deviceId, serviceId, characteristicId, obj.laveData);
  538. } else {
  539. self.setProcess(80, util.descSucList[5],4);
  540. }
  541. },
  542. fail: function (res) {
  543. console.log(res);
  544. self.setFailProcess(true, res.errCode + "::" + util.descFailList[3]);
  545. }
  546. })
  547. },
  548. getResultType: function (list) {
  549. console.log(' ========= getResultType ========= ');
  550. var self = this;
  551. console.log(list);
  552. var deviceList = wx.getStorageSync('deviceList');
  553. console.log(deviceList);
  554. if (list.length < 4) {
  555. self.setFailProcess(true, res.errCode + "::" + util.descFailList[4]);
  556. return false;
  557. }
  558. var val = list[4];
  559. if (val == "00") {
  560. var idx = self.data.deviceNo + 1;
  561. var doDevices = wx.getStorageSync('doDevices');
  562. if (doDevices) {
  563. if (doDevices.indexOf(self.data.deviceId) < 0) {
  564. doDevices.push(self.data.deviceId);
  565. }
  566. } else {
  567. doDevices = [self.data.deviceId];
  568. }
  569. wx.setStorageSync('doDevices', doDevices);
  570. var deviceSn = self.data.deviceId;
  571. for (var i = 0; i < deviceList.length; i++) {
  572. var itemSub = deviceList[i];
  573. if (itemSub.deviceId === self.data.deviceId) {
  574. deviceSn = itemSub.sn;
  575. break;
  576. }
  577. }
  578. if (idx < self.data.deviceIds.length) {
  579. self.setProcess(90, 'SN:' + deviceSn + ' 连接成功', 5);
  580. wx.closeBLEConnection({
  581. deviceId: self.data.deviceId,
  582. success: function (res) { }
  583. })
  584. self.setData({
  585. deviceNo: idx,
  586. deviceId: self.data.deviceIds[idx],
  587. blueConnectNum: 0
  588. });
  589. self.blueConnect();
  590. } else {
  591. self.setProcess(90, 'SN:' + deviceSn + ' 连接成功', 5);
  592. self.setProcess(100, util.descSucList[6],6);
  593. self.setData({
  594. result: [],
  595. })
  596. }
  597. } else {
  598. self.setFailProcess(true, res.errCode + "::" + util.descFailList[4])
  599. }
  600. },
  601. setProcess: function (value, desc,step = 0) {
  602. var self = this,
  603. list = [];
  604. list = self.data.processList;
  605. if (list.indexOf(desc) == -1) {
  606. list.push(desc);
  607. }
  608. if (self.data.value <= value) {
  609. self.setData({
  610. value: value,
  611. bluetoothConnectedStep:step
  612. });
  613. }
  614. self.setData({
  615. processList: list
  616. });
  617. //console.log(value);
  618. //console.log(desc);
  619. if (value == 100) {
  620. self.closeConnect();
  621. wx.closeBluetoothAdapter();
  622. self.setData({
  623. isBluetoothConnected:true,
  624. desc: util.descSucList[6]
  625. });
  626. clearInterval(timeId);
  627. sequenceControl = 0;
  628. self.commitUserData();
  629. }
  630. },
  631. setFailProcess: function (flag, desc) {
  632. var self = this,
  633. list = [];
  634. list = self.data.processList;
  635. list.push(desc);
  636. self.setData({
  637. failure: flag,
  638. processList: list
  639. });
  640. },
  641. closeConnect: function () {
  642. var self = this;
  643. wx.closeBLEConnection({
  644. deviceId: self.data.deviceId,
  645. success: function (res) { }
  646. })
  647. },
  648. /**
  649. * 生命周期函数--监听页面加载
  650. */
  651. onLoad(options) {
  652. this.getWifiInfo();
  653. if (options.type && options.type == "edit") {
  654. wx.setNavigationBarTitle({
  655. title:"编辑床垫"
  656. })
  657. const item = wx.getStorageSync("item");
  658. if (item) {
  659. this.setData({
  660. isEdit: true,
  661. pid: item.pid,
  662. placeOfUse: item.location,
  663. usingHuman: item.person,
  664. deviceId: item.sn,
  665. sn: item.sn,
  666. ssid: "",
  667. password: "",
  668. })
  669. wx.removeStorageSync("item")
  670. }
  671. }
  672. },
  673. checkSn(sntram) {
  674. const that = this;
  675. wx.request({
  676. url: 'https://aipush.aidsleep.cn/customerlist',
  677. method: 'POST',
  678. data: {
  679. token: "89835e65993fee4a6a6cbbe4c271da51e5521822934e13769e61cadabaed72c3" || wx.getStorageSync('token'),
  680. sntram: sntram,
  681. },
  682. success: (res) => {
  683. var incustom = res.data.incustom;
  684. if (incustom == "true") {
  685. that.bindViewConnect();
  686. } else {
  687. wx.showToast({
  688. icon: 'none',
  689. title: "sn 不合法"
  690. });
  691. }
  692. },
  693. fail: () => {
  694. wx.showToast({
  695. icon: 'none',
  696. title: "sn 不合法"
  697. });
  698. }
  699. });
  700. },
  701. /**
  702. * 生命周期函数--监听页面初次渲染完成
  703. */
  704. onReady() {
  705. },
  706. /**
  707. * 生命周期函数--监听页面显示
  708. */
  709. onShow() {
  710. },
  711. /**
  712. * 生命周期函数--监听页面隐藏
  713. */
  714. onHide() {
  715. },
  716. /**
  717. * 生命周期函数--监听页面卸载
  718. */
  719. onUnload() {
  720. wx.offWifiConnected({});
  721. wx.stopWifi({})
  722. this.closeConnect()
  723. },
  724. /**
  725. * 页面相关事件处理函数--监听用户下拉动作
  726. */
  727. onPullDownRefresh() {
  728. },
  729. /**
  730. * 页面上拉触底事件的处理函数
  731. */
  732. onReachBottom() {
  733. },
  734. /**
  735. * 用户点击右上角分享
  736. */
  737. onShareAppMessage() {
  738. }
  739. })