index.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  1. // 获取应用实例
  2. const app = getApp();
  3. const {
  4. getBanner,
  5. login,
  6. listByDevice
  7. } = require('../../utils/api.js');
  8. const {
  9. isCN
  10. } = require('../../utils/util.js');
  11. let _this = null;
  12. const interval = null;
  13. // import routeUtil from '../../utils/route_util.js'
  14. import routeUtil from '../../utils/route_util'
  15. import route_constant from '../../utils/route_constant.js'
  16. Page({
  17. data: {
  18. ///下午好
  19. greeting: "",
  20. phone: "",
  21. nvabarData: {
  22. showCapsule: 0, //是否显示左上角图标 1表示显示 0表示不显示
  23. title: 'OhPlay', //导航栏 中间的标题
  24. },
  25. bannerList: [],
  26. autoplay: true,
  27. interval: 3000, // 切换时间间隔
  28. duration: 500, // 滑动动画时长
  29. circular: true, // 衔接滑动
  30. indexPage: 0,
  31. ///是否展示频道
  32. showChannel: false,
  33. ////首页
  34. navBarHeight: app.globalData.navBarHeight,
  35. MenuButtonheight: app.globalData.MenuButtonheight,
  36. MenuButtonTop: app.globalData.MenuButtonTop,
  37. actionIndex: null,
  38. luoma: ["Ⅰ", "Ⅱ", "Ⅲ", "Ⅳ", "Ⅴ", "Ⅵ", " Ⅶ", "Ⅷ", "Ⅸ", "Ⅹ", "Ⅺ", "Ⅻ"],
  39. channelData: [],
  40. deviceList: [],
  41. deviceListIndex: null,
  42. showLogin: false,
  43. isOneLoading: true,
  44. uid: null,
  45. isSetWake: false,
  46. thisDeviceMac: null,
  47. battery: 4, // 0≤电量<20,0格
  48. newVersion: false,
  49. ////我的界面
  50. loginStatus: true,
  51. nickname: "未登录",
  52. userPic: './../../img/head_pic.png',
  53. islogin: false,
  54. },
  55. onLoad(options) {
  56. var that = this;
  57. var bannerList = wx.getStorageSync("homeBanner") || [];
  58. if (that.data.bannerList.length == 0) {
  59. that.setData({
  60. bannerList: bannerList
  61. });
  62. }
  63. that.onHomeLoad();
  64. that.onMeLoad();
  65. },
  66. onShow() {
  67. var that = this;
  68. that.onHomeShow();
  69. that.onMeShow();
  70. var nickname = that.data.nickname;
  71. var greeting = that.updateGreeting();
  72. if (nickname != "" && nickname != "未登录") {
  73. greeting = greeting + ',' + nickname;;
  74. }
  75. that.setData({
  76. greeting: greeting
  77. });
  78. getBanner({}).then((res) => {
  79. that.setData({
  80. bannerList: res
  81. });
  82. wx.setStorageSync("homeBanner", res);
  83. })
  84. },
  85. updateGreeting() {
  86. const now = new Date();
  87. const hour = now.getHours();
  88. let greeting;
  89. if (hour >= 5 && hour < 12) {
  90. greeting = '上午好';
  91. } else if (hour >= 12 && hour < 18) {
  92. greeting = '下午好';
  93. } else {
  94. greeting = '晚上好';
  95. }
  96. return greeting;
  97. },
  98. onHomeLoad() {
  99. _this = this;
  100. // 版本自动更新代码
  101. const updateManager = wx.getUpdateManager();
  102. updateManager.onUpdateReady(function () {
  103. _this.setData({
  104. newVersion: true
  105. });
  106. })
  107. updateManager.onUpdateFailed(function () {
  108. // 新的版本下载失败
  109. wx.showModal({
  110. title: '已有新版本咯',
  111. content: '请您删除当前小程序,重新打开呦~',
  112. showCancel: false
  113. })
  114. })
  115. wx.showLoading({
  116. title: '加载中',
  117. });
  118. const str = setTimeout(() => {
  119. clearTimeout(str);
  120. if (_this.data.isOneLoading) {
  121. _this.setData({
  122. isOneLoading: false,
  123. });
  124. }
  125. }, 500);
  126. // 获取缓存的频道数据
  127. wx.getStorage({
  128. key: "channelData",
  129. success(res) {
  130. _this.setData({
  131. channelData: res.data
  132. })
  133. }
  134. });
  135. // 登录
  136. this.login();
  137. },
  138. onMeLoad() {
  139. // wx.getStorage("userInfo")
  140. var that = this;
  141. wx.getStorage({
  142. key: "userInfo",
  143. success(res) {
  144. var phone = res.data.phone;
  145. if (!phone) {
  146. return;
  147. };
  148. var nickname = res.data.nickname || "";
  149. var greeting = that.updateGreeting();
  150. if (nickname != "" && nickname != "未登录") {
  151. greeting = greeting + ',' + nickname;;
  152. }
  153. that.setData({
  154. phone: phone,
  155. greeting: greeting,
  156. nickname: nickname,
  157. userPic: res.data.headUrl || "",
  158. islogin: true,
  159. });
  160. }
  161. })
  162. },
  163. onHomeShow() {
  164. if ((!this.data.isOneLoading)) {
  165. wx.getStorage({
  166. key: 'userInfo',
  167. fail(res) {
  168. // 取消订阅
  169. if (_this.data.thisDeviceMac !== null) {
  170. app.unsubscribe(`/${_this.data.thisDeviceMac}/user/pub_response`);
  171. };
  172. _this.setData({
  173. showLogin: true,
  174. });
  175. },
  176. success() {
  177. if (app.globalData.newDeviceId) {
  178. // 获取设备本地数据
  179. _this.getDeviceData();
  180. } else if (_this.data.deviceListIndex !== null) {
  181. // 更新
  182. _this.actionDevice(_this.data.deviceListIndex);
  183. }
  184. }
  185. });
  186. };
  187. },
  188. onMeShow() {
  189. this.onLoad();
  190. },
  191. ////开始是home的
  192. login() {
  193. wx.login({
  194. success: res => {
  195. let phone = undefined;
  196. try {
  197. var value = wx.getStorageSync('userInfo')
  198. if (value) {
  199. phone = value.phone || undefined;
  200. };
  201. } catch (e) {
  202. // Do something when catch error
  203. };
  204. // 请求登录
  205. login({
  206. code: res.code,
  207. phone
  208. }).then((res) => {
  209. app.globalData.userInfo = res;
  210. wx.setStorage({
  211. key: "userInfo",
  212. data: res
  213. });
  214. // 需要用授权登录
  215. if ((res.isNewUser && res.isNewUser === true) || !phone) {
  216. _this.setData({
  217. showLogin: true,
  218. });
  219. return;
  220. };
  221. // 获取设备本地数据
  222. this.getDeviceData();
  223. _this.setData({
  224. showLogin: false,
  225. });
  226. wx.setStorage({
  227. key: "token",
  228. data: JSON.stringify({
  229. id: res.userId,
  230. token: res.accessToken,
  231. }),
  232. });
  233. });
  234. },
  235. })
  236. },
  237. ///开始时home的
  238. getDeviceData() {
  239. // 获取设备数据
  240. wx.getStorage({
  241. key: 'devicelist',
  242. success(res) {
  243. wx.hideLoading();
  244. if (res.data) {
  245. const resData = JSON.parse(res.data);
  246. console.log("本地设备列表", resData)
  247. _this.setData({
  248. deviceList: resData
  249. });
  250. // 连接mqtt
  251. if (app.globalData.client === null) {
  252. app.connect();
  253. } else if (app.globalData.newDeviceId) {
  254. _this.setData({
  255. actionIndex: null,
  256. deviceListIndex: null,
  257. });
  258. // 监听
  259. let topic = `/AIrSMArT_${resData[0].name.split("BLUFI_")[1]}/status/onoffline`;
  260. app.subscribe(topic);
  261. const Timeout = setTimeout(() => {
  262. clearTimeout(Timeout);
  263. _this.actionDevice(0);
  264. }, 1000);
  265. }
  266. // // 有新设备
  267. // if(app.globalData.newDeviceId) {
  268. // _this.setData({
  269. // actionIndex: null,
  270. // deviceListIndex: null,
  271. // });
  272. // let topic = `/AIrSMArT_${resData[0].name.split("BLUFI_")[1]}/status/onoffline`;
  273. // app.subscribe(topic);
  274. // }
  275. }
  276. },
  277. fail(e) {
  278. wx.hideLoading();
  279. }
  280. });
  281. },
  282. // 回调
  283. mqttCallback(type, option) {
  284. // console.log("gadsfadsfqwerq===" + type + "===" + option);
  285. let payloads = null;
  286. if (option) {
  287. payloads = JSON.parse(option.payload);
  288. };
  289. switch (type) {
  290. case "connect":
  291. _this.connectSuccess();
  292. break;
  293. case "message_onoffline":
  294. _this.online(payloads);
  295. break;
  296. case "message":
  297. // 接收设备播放信息
  298. if (payloads.type === "get_position" && payloads.other) {
  299. let actionIndex = null;
  300. _this.data.channelData.map((v, index) => {
  301. if (v.channelNum === payloads.other.channel) {
  302. actionIndex = index;
  303. }
  304. });
  305. _this.setData({
  306. actionIndex,
  307. });
  308. } else if (payloads.type === "play" || payloads.type === "play_state") {
  309. if (_this.data.deviceListIndex === null) {
  310. return;
  311. }
  312. // 接收设备当前播放状态
  313. const obj = {
  314. DstDeviceName: _this.getThisDeviceID()
  315. }
  316. app.PubMsg({
  317. type: "get_position",
  318. ...obj
  319. });
  320. } else if (payloads.type === "get_dev_info") {
  321. // 接收设备当前信息
  322. this.getchannelData(payloads.other.ProdModel);
  323. // 电量
  324. _this.setData({
  325. battery: _this._battery(payloads.other.Power),
  326. })
  327. // 当前设备木有设置定时
  328. _this.setData({
  329. isSetWake: false,
  330. });
  331. payloads.other.alarm.map((v) => {
  332. if (v.enable === "1") {
  333. _this.setData({
  334. isSetWake: true
  335. });
  336. }
  337. });
  338. // 更新信息
  339. _this.data.deviceList.map((v, index) => {
  340. if (payloads.SrcDeviceName && payloads.SrcDeviceName.indexOf(v.name.split("BLUFI_")[1]) !== -1) {
  341. _this.data.deviceList[index].ProdModel = payloads.other.ProdModel;
  342. _this.data.deviceList[index].devName = payloads.other.devName;
  343. }
  344. });
  345. // 更新缓存
  346. wx.setStorage({
  347. key: "devicelist",
  348. data: JSON.stringify(_this.data.deviceList),
  349. success() {
  350. _this.setData({
  351. deviceList: _this.data.deviceList
  352. })
  353. }
  354. });
  355. } else if (payloads.type === "battery" && payloads.other) {
  356. _this.setData({
  357. battery: _this._battery(payloads.other.battery),
  358. })
  359. }
  360. break;
  361. default:
  362. }
  363. },
  364. // 格式化电量
  365. _battery(battery) {
  366. let _battery = 0;
  367. if (battery < 20) {
  368. _battery = 0
  369. } else if (20 <= battery && battery < 40) {
  370. _battery = 1
  371. } else if (40 <= battery && battery < 60) {
  372. _battery = 2
  373. } else if (60 <= battery && battery < 80) {
  374. _battery = 3
  375. } else if (80 <= battery && battery <= 100) {
  376. _battery = 4
  377. } else if (battery > 100) {
  378. _battery = 5
  379. };
  380. return _battery
  381. },
  382. connectSuccess() {
  383. // 订阅设备在线信息
  384. _this.subscribeDevicesStatus();
  385. },
  386. // [{"deviceId":"BLUFI_7cdfa1fcbb24","name":"BLUFI_7cdfa1fcbb24","state":"online","ProdModel":"MW-2AX(WIFI-N)","devName":"猫王小王子OTR-X"}]
  387. online(payloads) {
  388. // 设置在线状态
  389. _this.data.deviceList.map((v, index) => {
  390. if (payloads.uuid && payloads.uuid.indexOf(v.name.split("BLUFI_")[1]) !== -1) {
  391. _this.data.deviceList[index].state = payloads.state;
  392. }
  393. });
  394. _this.setData({
  395. deviceList: _this.data.deviceList,
  396. });
  397. // 更新缓存
  398. wx.setStorage({
  399. key: "devicelist",
  400. data: JSON.stringify(_this.data.deviceList)
  401. });
  402. // 如没有选中,选中最新的
  403. (() => {
  404. if (_this.data.deviceListIndex === null) {
  405. let itue = false;
  406. _this.data.deviceList.map((v, index) => {
  407. if (v.state === "online" && !itue) {
  408. itue = true;
  409. _this.actionDevice(index);
  410. }
  411. });
  412. }
  413. // else {
  414. // _this.actionDevice(_this.data.deviceListIndex);
  415. // };
  416. })();
  417. // 当前播放设备离线
  418. if (_this.data.deviceListIndex !== null && _this.data.deviceList[_this.data.deviceListIndex].state !== "online") {
  419. _this.setData({
  420. actionIndex: null,
  421. deviceListIndex: null,
  422. });
  423. };
  424. },
  425. // 订阅设备在线状态
  426. subscribeDevicesStatus() {
  427. this.data.deviceList.forEach((value) => {
  428. let topic = `/AIrSMArT_${value.name.split("BLUFI_")[1]}/status/onoffline`;
  429. app.subscribe(topic);
  430. })
  431. },
  432. subscribeCurrDevice() {
  433. if (!(app.globalData.client && app.globalData.client.connected)) {
  434. console.log("未连接MQTT服务器");
  435. const str = setInterval(() => {
  436. clearInterval(str);
  437. _this.subscribeCurrDevice();
  438. }, 500);
  439. return;
  440. };
  441. if (this.data.deviceList.length === 0 || this.data.deviceListIndex === null) {
  442. return
  443. };
  444. let topic = `/AIrSMArT_${this.data.deviceList[this.data.deviceListIndex].name.split("BLUFI_")[1]}/user/pub_response`;
  445. app.subscribe(topic);
  446. const obj = {
  447. DstDeviceName: _this.getThisDeviceID()
  448. };
  449. app.PubMsg({
  450. type: "get_dev_info",
  451. ...obj
  452. });
  453. },
  454. actionMusic(e) {
  455. if (e.currentTarget.dataset.index === this.data.actionIndex) {
  456. return;
  457. };
  458. if (this.data.deviceListIndex === null) {
  459. wx.showToast({
  460. title: '请选择设备',
  461. icon: "none"
  462. })
  463. return;
  464. };
  465. this.setData({
  466. actionIndex: e.currentTarget.dataset.index
  467. });
  468. const other = {
  469. "url": "",
  470. "media_data": "",
  471. "user_id": `${app.globalData.userInfo.deviceUid}`,
  472. "timestamp": `${Math.round(new Date() / 1000)}`,
  473. "channel_id": `${this.data.channelData[e.currentTarget.dataset.index].channelNum}`,
  474. "order": "",
  475. "resource_from": "",
  476. "songAlbumID": "",
  477. "version": 3,
  478. "is_debug": app.globalData.is_debug
  479. };
  480. app.PubMsg({
  481. type: "play",
  482. DstDeviceName: _this.getThisDeviceID(),
  483. other
  484. });
  485. },
  486. actionDeviceIndex(e) {
  487. if (e.currentTarget.dataset.index === this.data.deviceListIndex) {
  488. return
  489. };
  490. this.actionDevice(e.currentTarget.dataset.index)
  491. },
  492. actionDevice(index) {
  493. const device = this.data.deviceList[index];
  494. if (device.state !== "online") {
  495. return;
  496. };
  497. // 取消订阅
  498. if (this.data.thisDeviceMac !== null) {
  499. app.unsubscribe(`/${this.data.thisDeviceMac}/user/pub_response`);
  500. };
  501. this.setData({
  502. deviceListIndex: index,
  503. thisDeviceMac: `AIrSMArT_${this.data.deviceList[index].name.split("BLUFI_")[1]}`
  504. });
  505. // app.PubMsg({
  506. // type: "get_dev_info",
  507. // DstDeviceName: _this.getThisDeviceID()
  508. // });
  509. this.subscribeCurrDevice();
  510. },
  511. getThisDeviceID() {
  512. return `AIrSMArT_${this.data.deviceList[this.data.deviceListIndex].name.split("BLUFI_")[1]}`
  513. },
  514. getchannelData(clientType) {
  515. let _this = this;
  516. if (this.data.deviceListIndex === null) {
  517. return;
  518. };
  519. listByDevice({
  520. clientType
  521. }).then((res) => {
  522. _this.setData({
  523. channelData: res
  524. });
  525. // 接收设备当前播放状态
  526. const obj = {
  527. DstDeviceName: _this.getThisDeviceID()
  528. }
  529. app.PubMsg({
  530. type: "get_position",
  531. ...obj
  532. });
  533. wx.setStorage({
  534. key: "channelData",
  535. data: res
  536. });
  537. // 有新设备
  538. if (app.globalData.newDeviceId) {
  539. app.globalData.newDeviceId = null;
  540. return;
  541. // 去掉此功能,先留着吧
  542. // const other= {
  543. // "url": "",
  544. // "media_data": "",
  545. // "user_id": `${app.globalData.userInfo.deviceUid}`,
  546. // "timestamp": `${Math.round(new Date() / 1000)}`,
  547. // "channel_id": `${res[1].channelNum}`,
  548. // "order": "",
  549. // "resource_from": "",
  550. // "songAlbumID":"",
  551. // "version":3,
  552. // "is_debug": app.globalData.is_debug
  553. // };
  554. // app.PubMsg({
  555. // type: "play",
  556. // DstDeviceName: _this.getThisDeviceID(),
  557. // other
  558. // });
  559. }
  560. })
  561. },
  562. goChnnel() {
  563. wx.setStorage({
  564. key: "channelDeta",
  565. data: this.data.channelData[this.data.actionIndex],
  566. success() {
  567. wx.navigateTo({
  568. url: './../channelDetails/channelDetails'
  569. })
  570. }
  571. })
  572. },
  573. updata() {
  574. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  575. wx.getUpdateManager().applyUpdate()
  576. },
  577. updataClone() {
  578. this.setData({
  579. newVersion: false
  580. })
  581. },
  582. onUnload() {
  583. if (app.globalData.client === null) {
  584. return;
  585. };
  586. app.globalData.client.end(true);
  587. app.globalData.client.end(true);
  588. app.globalData.client = null;
  589. },
  590. onTapIndex(e) {
  591. var that = this;
  592. var index = e.currentTarget.dataset.index;
  593. var indexPage = that.data.indexPage;
  594. if (indexPage != index) {
  595. that.setData({
  596. indexPage: index,
  597. });
  598. }
  599. },
  600. goMeAbout() {
  601. wx.navigateTo({
  602. url: './../about/about',
  603. })
  604. },
  605. goMeLogin() {
  606. const that = this;
  607. if (that.data.islogin) {
  608. // 退出登录
  609. wx.removeStorage({
  610. key: 'userInfo',
  611. success(res) {
  612. var nickname = "未登录";
  613. var greeting = that.updateGreeting();
  614. if (nickname != "" && nickname != "未登录") {
  615. greeting = greeting + ',' + nickname;;
  616. }
  617. that.setData({
  618. phone: "",
  619. greeting: greeting,
  620. islogin: false,
  621. nickname: nickname,
  622. userPic: "./../../img/head_pic.png",
  623. });
  624. // wx.switchTab({
  625. // url: `./../index/index`
  626. // });
  627. }
  628. });
  629. wx.removeStorage({
  630. key: 'token',
  631. })
  632. } else {
  633. // 登录
  634. wx.navigateTo({
  635. url: './../login/login',
  636. });
  637. }
  638. },
  639. addDevice() {
  640. var that = this;
  641. var phone = that.data.phone;
  642. var showLogin = that.data.showLogin;
  643. if (phone == "" || showLogin) {
  644. wx.navigateTo({
  645. url: './../login/login'
  646. });
  647. return;
  648. }
  649. that.goDeviceConnect();
  650. },
  651. goDeviceConnect() {
  652. wx.navigateTo({
  653. url: './../deviceList/deviceList',
  654. });
  655. },
  656. ///点击item
  657. // [{"deviceId":"BLUFI_7cdfa1fcbb24","name":"BLUFI_7cdfa1fcbb24","state":"online","ProdModel":"MW-2AX(WIFI-N)","devName":"猫王小王子OTR-X"}]
  658. onTapIem(e) {
  659. var that = this;
  660. var item = e.currentTarget.dataset.item;
  661. var devName = item.devName;
  662. if (devName == "猫王小王子OTR-X") {
  663. that.goWake();
  664. return;
  665. }
  666. },
  667. goWake() {
  668. if (this.data.deviceListIndex === null) {
  669. return;
  670. };
  671. wx.navigateTo({
  672. url: './../deviceWake/deviceWake?deviceId=' + this.data.deviceList[this.data.deviceListIndex].deviceId + "&clientType=" + this.data.deviceList[this.data.deviceListIndex].ProdModel,
  673. });
  674. },
  675. ///点击banner事件
  676. onTapBanner() {
  677. var that = this;
  678. var item = e.currentTarget.dataset.item;
  679. },
  680. deleteDevice(e) {
  681. wx.showModal({
  682. title: '确定删除?',
  683. success: function (res) {
  684. if (res.confirm) {
  685. const id = this.data.deviceList[e.currentTarget.dataset.index].deviceId;
  686. let name = _this.data.deviceListIndex !== null ? this.data.deviceList[_this.data.deviceListIndex].name : null;
  687. const deviceList = this.data.deviceList.filter((v, i) => {
  688. return id !== v.deviceId
  689. });
  690. // 取消订阅
  691. app.unsubscribe(`/AIrSMArT_${_this.data.deviceList[e.currentTarget.dataset.index].name.split("BLUFI_")[1]}/user/pub_response`);
  692. wx.setStorage({
  693. key: "devicelist",
  694. data: JSON.stringify(deviceList),
  695. success() {
  696. _this.setData({
  697. deviceList,
  698. thisDeviceMac: null
  699. });
  700. // 当前没有设备
  701. if (deviceList.length === 0) {
  702. _this.setData({
  703. actionIndex: null,
  704. deviceListIndex: null,
  705. });
  706. }
  707. if (_this.data.deviceListIndex === null) {
  708. return
  709. };
  710. if (e.currentTarget.dataset.index === _this.data.deviceListIndex) {
  711. let index_ = null;
  712. deviceList.map((v, index) => {
  713. if (v.state === "online" && index_ === null) {
  714. index_ = index;
  715. }
  716. });
  717. if (index_ !== null) {
  718. _this.actionDevice(index_);
  719. } else {
  720. _this.setData({
  721. actionIndex: null,
  722. deviceListIndex: null,
  723. });
  724. };
  725. } else {
  726. deviceList.map((v, index) => {
  727. if (v.name === name) {
  728. _this.setData({
  729. deviceListIndex: index,
  730. });
  731. }
  732. });
  733. }
  734. }
  735. });
  736. }
  737. }
  738. });
  739. },
  740. })