addMattresses.js 22 KB

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