addMattresses.js 22 KB

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