addMattresses.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773
  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.sn);
  70. console.log(this.data.ssid);
  71. console.log(this.data.password);
  72. this.checkSn(this.data.sn);
  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.sn,
  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. var name = this.data.deviceList[this.data.bluetoothSelectIndex].name;
  270. var nameList = this.data.deviceList[this.data.bluetoothSelectIndex].name.split(' ');
  271. this.setData({
  272. deviceId: deviceId,
  273. sn: nameList[1]
  274. })
  275. wx.offBluetoothDeviceFound()
  276. },
  277. // 开始配网
  278. bindViewConnect() {
  279. const that = this;
  280. if (bluetoothSelectIndex < 0) {
  281. util.showToast("没有指定要配网的设备");
  282. return false;
  283. }
  284. var deviceIds = this.data.deviceList[this.data.bluetoothSelectIndex];
  285. if (this.data.deviceList.length == 0 || deviceIds.length === 0) {
  286. util.showToast("没有指定要配网的设备");
  287. return false;
  288. }
  289. that.gotoProvision()
  290. },
  291. // 获取Wifi
  292. getWifiInfo: function () {
  293. wx.startWifi({
  294. success(res) {
  295. //console.log(' ================== startWifi ================== ');
  296. //console.log(res);
  297. wx.getConnectedWifi({
  298. success(res) {
  299. },
  300. fail: function (err) {
  301. console.log(' ================== startWifi fail ================== ');
  302. console.log(err);
  303. if (app.data.sytem == 'ios') {
  304. util.showToast("获取Wi-Fi信息失败,请更新微信到最新版");
  305. } else {
  306. util.showToast("获取Wi-Fi信息失败");
  307. }
  308. }
  309. });
  310. }
  311. });
  312. const self = this;
  313. wx.startWifi({
  314. success(res) {
  315. //console.log(res)
  316. // 先取一次,防止IOS获取不到
  317. wx.getConnectedWifi({
  318. success(res) {
  319. self.setData({
  320. wifiInfo: res.wifi,
  321. ssid: res.wifi.SSID
  322. });
  323. //console.log('== getConnectedWifi ==');
  324. //console.log(res);
  325. if (res.frequency >= 2412 && res.frequency <= 2472) { } else {
  326. self.setData({
  327. notice: "温馨提示:当前您连接的Wi-Fi网络是5G频段,建议连接2.4G频段配网"
  328. })
  329. }
  330. },
  331. fail: function (err) {
  332. util.showToast("获取Wi-Fi信息失败");
  333. }
  334. })
  335. wx.onWifiConnected(function (res) {
  336. // console.log('== onWifiConnected ==');
  337. // console.log(res);
  338. self.setData({
  339. wifiInfo: res.wifi
  340. })
  341. })
  342. },
  343. fail(res) {
  344. console.log('WIFI初始化失败', res)
  345. util.showToast("WIFI初始化失败");
  346. }
  347. })
  348. },
  349. gotoProvision: function () {
  350. const wifiInfo = this.data.wifiInfo;
  351. const ssid = wifiInfo != null ? wifiInfo.SSID : null;
  352. const bssid = wifiInfo != null ? wifiInfo.BSSID : null;
  353. const password = this.data.password;
  354. if (wifiInfo == null) {
  355. util.showToast("没有Wi-Fi连接");
  356. return;
  357. } else {
  358. if (ssid == null || ssid == '' || password == '') {
  359. util.showToast("WiFi登录名和密码不能为空");
  360. return;
  361. } else {
  362. const info = {
  363. ssid: ssid,
  364. bssid: bssid,
  365. password: password,
  366. deviceIds: this.data.deviceId
  367. }
  368. this.blueConnect();
  369. }
  370. }
  371. },
  372. // 蓝牙链接
  373. blueConnect: function (event) {
  374. //console.log(' =============== blueConnect start ===============')
  375. var self = this;
  376. sequenceControl = 0;
  377. self.setData({
  378. flagEnd: false,
  379. serviceId: "",
  380. uuid: "",
  381. showBluetoothConnected:true
  382. });
  383. self.setProcess(0, util.descSucList[0],1);
  384. //第一步检查蓝牙适配器是否可用
  385. wx.onBluetoothAdapterStateChange(function (res) {
  386. if (!res.available) {
  387. util.showToast('蓝牙不可用');
  388. return false;
  389. }
  390. });
  391. //console.log(app.data);
  392. if (app.data.sytem == 'ios') {
  393. }
  394. //console.log('deviceId = ' + self.data.deviceId)
  395. wx.createBLEConnection({
  396. // 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
  397. deviceId: self.data.deviceId,
  398. timeout: 10000,
  399. success: function (res) {
  400. wx.setBLEMTU({
  401. deviceId: self.data.deviceId,
  402. mtu: 128
  403. })
  404. //console.log("============ createBLEConnection success =============")
  405. //console.log(self.data.deviceId)
  406. self.getDeviceServices(self.data.deviceId);
  407. },
  408. fail: function (res) {
  409. console.log("============ createBLEConnection fail =============")
  410. console.log(res)
  411. console.log(self.data.blueConnectNum)
  412. var num = self.data.blueConnectNum;
  413. if (num < 3) {
  414. self.blueConnect();
  415. num++;
  416. self.setData({
  417. blueConnectNum: num
  418. })
  419. } else {
  420. self.setFailProcess(true, res.errCode + "::" + util.descFailList[0]);
  421. }
  422. }
  423. })
  424. },
  425. getDeviceServices: function (deviceId) {
  426. var self = this;
  427. wx.getBLEDeviceServices({
  428. // 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
  429. deviceId: deviceId,
  430. success: function (res) {
  431. self.setProcess(10, util.descSucList[1],2);
  432. var services = res.services;
  433. if (services.length > 0) {
  434. for (var i = 0; i < services.length; i++) {
  435. var uuid = services[i].uuid;
  436. if (uuid == app.data.service_uuid) {
  437. self.getDeviceCharacteristics(deviceId, uuid);
  438. return false;
  439. }
  440. }
  441. }
  442. },
  443. fail: function (res) {
  444. self.setFailProcess(true, res.errCode + "::" + util.descFailList[1]);
  445. }
  446. })
  447. },
  448. getDeviceCharacteristics: function (deviceId, serviceId) {
  449. //console.log(" ============== getDeviceCharacteristics =============== ");
  450. var self = this;
  451. wx.getBLEDeviceCharacteristics({
  452. // 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
  453. deviceId: deviceId,
  454. serviceId: serviceId,
  455. success: function (res) {
  456. self.setProcess(40, util.descSucList[2],3);
  457. var list = res.characteristics;
  458. if (list.length > 0) {
  459. for (var i = 0; i < list.length; i++) {
  460. var uuid = list[i].uuid;
  461. if (uuid == app.data.characteristic_write_uuid) {
  462. self.openNotify(deviceId, serviceId, uuid);
  463. self.setData({
  464. serviceId: serviceId,
  465. uuid: uuid,
  466. })
  467. return false;
  468. }
  469. }
  470. }
  471. },
  472. fail: function (res) {
  473. console.log(res);
  474. self.setFailProcess(true, res.errCode + "::" + util.descFailList[2]);
  475. }
  476. })
  477. },
  478. //连接超时
  479. onTimeout: function (num) {
  480. const self = this;
  481. timeId = setInterval(function () {
  482. if (num < timeOut) {
  483. num++;
  484. } else {
  485. clearInterval(timeId);
  486. self.setFailProcess(true, res.errCode + "::" + util.descFailList[4]);
  487. }
  488. }, 1000)
  489. },
  490. //启用通知
  491. openNotify: function (deviceId, serviceId, characteristicId) {
  492. //console.log("=========== openNotify ============");
  493. var self = this;
  494. wx.notifyBLECharacteristicValueChange({
  495. state: true, // 启用 notify 功能
  496. deviceId: deviceId,
  497. serviceId: serviceId,
  498. characteristicId: app.data.characteristic_read_uuid,
  499. success: function (res) {
  500. //console.log(res);
  501. self.writeDevice(deviceId, serviceId, characteristicId, null);
  502. self.onNotify();
  503. },
  504. fail: function (res) {
  505. console.log(res);
  506. }
  507. })
  508. },
  509. //监听通知
  510. onNotify: function () {
  511. //console.log("=========== onNotify ============");
  512. var self = this;
  513. wx.onBLECharacteristicValueChange(function (res) {
  514. //console.log(res);
  515. self.getResultType(util.ab2hex(res.value));
  516. })
  517. },
  518. // 设备数据开始写入
  519. writeDevice: function (deviceId, serviceId, characteristicId, data) {
  520. //console.log("===== writeDevice =====");
  521. var self = this,
  522. obj = {};
  523. self.setProcess(60, util.descSucList[4],3);
  524. sequenceControl = parseInt(sequenceControl) + 1;
  525. if (!util._isEmpty(data)) {
  526. obj = util.isSubcontractor(data, true, sequenceControl);
  527. } else {
  528. data = util.writeData(self.getCharCodeat('"' + self.data.ssid + '","' + self.data.password + '"'));
  529. obj = util.isSubcontractor(data, self.data.isChecksum, sequenceControl);
  530. }
  531. var typedArray = new Uint8Array(obj.lenData)
  532. wx.writeBLECharacteristicValue({
  533. deviceId: deviceId,
  534. serviceId: serviceId,
  535. characteristicId: characteristicId,
  536. value: typedArray.buffer,
  537. success: function (res) {
  538. //console.log(res);
  539. if (obj.flag) {
  540. self.writeDevice(deviceId, serviceId, characteristicId, obj.laveData);
  541. } else {
  542. self.setProcess(80, util.descSucList[5],4);
  543. }
  544. },
  545. fail: function (res) {
  546. console.log(res);
  547. self.setFailProcess(true, res.errCode + "::" + util.descFailList[3]);
  548. }
  549. })
  550. },
  551. getResultType: function (list) {
  552. console.log(' ========= getResultType ========= ');
  553. var self = this;
  554. console.log(list);
  555. var deviceList = wx.getStorageSync('deviceList');
  556. console.log(deviceList);
  557. if (list.length < 4) {
  558. self.setFailProcess(true, res.errCode + "::" + util.descFailList[4]);
  559. return false;
  560. }
  561. var val = list[4];
  562. if (val == "00") {
  563. var idx = self.data.deviceNo + 1;
  564. var doDevices = wx.getStorageSync('doDevices');
  565. if (doDevices) {
  566. if (doDevices.indexOf(self.data.deviceId) < 0) {
  567. doDevices.push(self.data.deviceId);
  568. }
  569. } else {
  570. doDevices = [self.data.deviceId];
  571. }
  572. wx.setStorageSync('doDevices', doDevices);
  573. var deviceSn = self.data.deviceId;
  574. for (var i = 0; i < deviceList.length; i++) {
  575. var itemSub = deviceList[i];
  576. if (itemSub.deviceId === self.data.deviceId) {
  577. deviceSn = itemSub.sn;
  578. break;
  579. }
  580. }
  581. if (idx < self.data.deviceIds.length) {
  582. self.setProcess(90, 'SN:' + deviceSn + ' 连接成功', 5);
  583. wx.closeBLEConnection({
  584. deviceId: self.data.deviceId,
  585. success: function (res) { }
  586. })
  587. self.setData({
  588. deviceNo: idx,
  589. deviceId: self.data.deviceIds[idx],
  590. blueConnectNum: 0
  591. });
  592. self.blueConnect();
  593. } else {
  594. self.setProcess(90, 'SN:' + deviceSn + ' 连接成功', 5);
  595. self.setProcess(100, util.descSucList[6],6);
  596. self.setData({
  597. result: [],
  598. })
  599. }
  600. } else {
  601. self.setFailProcess(true, res.errCode + "::" + util.descFailList[4])
  602. }
  603. },
  604. setProcess: function (value, desc,step = 0) {
  605. var self = this,
  606. list = [];
  607. list = self.data.processList;
  608. if (list.indexOf(desc) == -1) {
  609. list.push(desc);
  610. }
  611. if (self.data.value <= value) {
  612. self.setData({
  613. value: value,
  614. bluetoothConnectedStep:step
  615. });
  616. }
  617. self.setData({
  618. processList: list
  619. });
  620. //console.log(value);
  621. //console.log(desc);
  622. if (value == 100) {
  623. self.closeConnect();
  624. wx.closeBluetoothAdapter();
  625. self.setData({
  626. isBluetoothConnected:true,
  627. desc: util.descSucList[6]
  628. });
  629. clearInterval(timeId);
  630. sequenceControl = 0;
  631. self.commitUserData();
  632. }
  633. },
  634. setFailProcess: function (flag, desc) {
  635. var self = this,
  636. list = [];
  637. list = self.data.processList;
  638. list.push(desc);
  639. self.setData({
  640. failure: flag,
  641. processList: list
  642. });
  643. },
  644. closeConnect: function () {
  645. var self = this;
  646. wx.closeBLEConnection({
  647. deviceId: self.data.deviceId,
  648. success: function (res) { }
  649. })
  650. },
  651. /**
  652. * 生命周期函数--监听页面加载
  653. */
  654. onLoad(options) {
  655. this.getWifiInfo();
  656. if (options.type && options.type == "edit") {
  657. wx.setNavigationBarTitle({
  658. title:"编辑床垫"
  659. })
  660. const item = wx.getStorageSync("item");
  661. if (item) {
  662. this.setData({
  663. isEdit: true,
  664. pid: item.pid,
  665. placeOfUse: item.location,
  666. usingHuman: item.person,
  667. deviceId: item.sn,
  668. sn: item.sn,
  669. ssid: "",
  670. password: "",
  671. })
  672. wx.removeStorageSync("item")
  673. }
  674. }
  675. },
  676. checkSn(sntram) {
  677. const that = this;
  678. wx.request({
  679. url: 'https://aipush.aidsleep.cn/customerlist',
  680. method: 'POST',
  681. data: {
  682. token: "89835e65993fee4a6a6cbbe4c271da51e5521822934e13769e61cadabaed72c3" || wx.getStorageSync('token'),
  683. sntram: sntram,
  684. },
  685. success: (res) => {
  686. var incustom = res.data.incustom;
  687. if (incustom == "true") {
  688. that.bindViewConnect();
  689. } else {
  690. wx.showToast({
  691. icon: 'none',
  692. title: "sn 不合法"
  693. });
  694. }
  695. },
  696. fail: () => {
  697. wx.showToast({
  698. icon: 'none',
  699. title: "sn 不合法"
  700. });
  701. }
  702. });
  703. },
  704. /**
  705. * 生命周期函数--监听页面初次渲染完成
  706. */
  707. onReady() {
  708. },
  709. /**
  710. * 生命周期函数--监听页面显示
  711. */
  712. onShow() {
  713. },
  714. /**
  715. * 生命周期函数--监听页面隐藏
  716. */
  717. onHide() {
  718. },
  719. /**
  720. * 生命周期函数--监听页面卸载
  721. */
  722. onUnload() {
  723. wx.offWifiConnected({});
  724. wx.stopWifi({})
  725. this.closeConnect()
  726. },
  727. /**
  728. * 页面相关事件处理函数--监听用户下拉动作
  729. */
  730. onPullDownRefresh() {
  731. },
  732. /**
  733. * 页面上拉触底事件的处理函数
  734. */
  735. onReachBottom() {
  736. },
  737. /**
  738. * 用户点击右上角分享
  739. */
  740. onShareAppMessage() {
  741. }
  742. })