shareAir.vue 25 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094
  1. <template>
  2. <view class="container">
  3. <uni-swiper-dot :info="imgUrl" :current="current" field="content" :mode="dotMode">
  4. <swiper class="swiper-box" @change="swiper_change" autoplay :interval="3000" :duration="500">
  5. <swiper-item v-for="(item ,index) in imgUrl" :key="index">
  6. <image :src="item.url" mode="aspectFill"></image>
  7. </swiper-item>
  8. </swiper>
  9. </uni-swiper-dot>
  10. <view class="line"></view>
  11. <view class="nav">
  12. <navigator class="btn" url="/pagesAir/stdBookMgr/stdBookMgr" hover-class="navigator-hover">
  13. <view class="btn-icon-tzgl">
  14. <image src="../static/images/tzgl.png" mode=""></image>
  15. <text>台账管理</text>
  16. </view>
  17. <view class="txt-right">
  18. <text> </text>
  19. <uni-icons type="forward" color="#c7c9ce" size="26"></uni-icons>
  20. </view>
  21. </navigator>
  22. <navigator class="btn" url="/pagesAir/accountBalance/accountBalance" hover-class="navigator-hover">
  23. <view class="btn-icon">
  24. <image src="../static/images/yhye.png" mode=""></image>
  25. <text>账户余额</text>
  26. </view>
  27. <view class="txt-right">
  28. <text>{{balance}}</text>
  29. <uni-icons type="forward" color="#c7c9ce" size="26"></uni-icons>
  30. </view>
  31. </navigator>
  32. </view>
  33. <view class="line"></view>
  34. <view class="add-air" v-if="isList === false" :style="{height: screenHeight}">
  35. <view class="add-content">
  36. <view class="add-left">
  37. <navigator url="../addAir/addAir" class="add-btn">
  38. <uni-icons type="plus" color="white" size="30"></uni-icons>
  39. <view>添加</view>
  40. </navigator>
  41. <view class="add-tip">
  42. <view class="txt-add-air">添加空调</view>
  43. <view class="txt-tip">点击添加设备</view>
  44. <view class="txt-tip">可添加多个设备</view>
  45. </view>
  46. </view>
  47. <view class="add-right">
  48. <image src="../static/images/air-pic.png" mode="aspectFit"></image>
  49. </view>
  50. </view>
  51. <view class="add-bg">
  52. <image src="../static/images/qidong.png" mode="aspectFit"></image>
  53. </view>
  54. </view>
  55. <view class="list-air" v-else>
  56. <scroll-view scroll-y="true" :style="{height: screenHeight}" @scrolltoupper="scroll_to_upper"
  57. @scrolltolower="scroll_to_lower">
  58. <view class="list-items" v-for="(item, index) in airs" :key="index">
  59. <view v-if="item.on" class="item-air" @longpress="itemLongPress($event, 1, item.air_ip)">
  60. <view class="item-left">
  61. <view class="item-icon">
  62. <view class="circle1"></view>
  63. <view class="circle2"></view>
  64. <view class="circle3"></view>
  65. </view>
  66. <view class="item-title">{{item.name}}</view>
  67. <view class="item-info">
  68. <text class="item-info-left">{{item.info}}</text>
  69. <text>启动时间:</text><text>{{item.time}}</text>
  70. </view>
  71. </view>
  72. <view class="item-right" @tap="btn_click(index, item.air_ip, item.name, item.info, item.order_num)">
  73. <view class="item-btn">
  74. <image src="../static/images/power-off.png" mode="aspectFit"></image>
  75. <view class="item-txt-off">
  76. 关闭
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. <view v-else class="item-air" @longpress="itemLongPress($event, 0, item.air_ip)" :ref="index">
  82. <view class="item-left">
  83. <view class="item-icon">
  84. <view class="circle1"></view>
  85. <view class="circle2"></view>
  86. <view class="circle3"></view>
  87. </view>
  88. <view class="item-title">{{item.name}}</view>
  89. <view class="item-info">
  90. <text class="item-info-left">{{item.info}}</text>
  91. <image src="../static/images/power-off.png" mode="" class="item-info-icon"></image>
  92. <text>未启动</text>
  93. </view>
  94. </view>
  95. <view class="item-right" @tap="btn_click(index, item.air_ip, item.name, item.info, item.order_num)"
  96. :ref="index">
  97. <view class="item-btn">
  98. <image src="../static/images/power-on.png" mode="aspectFit"></image>
  99. <view class="item-txt-on">
  100. 启动
  101. </view>
  102. </view>
  103. </view>
  104. </view>
  105. </view>
  106. <navigator url="../addAir/addAir" class="add-air-bottom">
  107. <uni-icons type="plus" size="30" color="#4B8DFB"></uni-icons>
  108. <view class="add-btn-bottom">添加</view>
  109. </navigator>
  110. </scroll-view>
  111. </view>
  112. </view>
  113. </template>
  114. <script>
  115. export default {
  116. data() {
  117. return {
  118. ceshi: 'air',
  119. userinfo: {}, // 用户信息
  120. stu_number: '', // 学号
  121. id_card: '', // 身份证号
  122. // 滚动横幅的数据
  123. imgUrl: [{
  124. url: this.$code_base_url + '/image/1.png'
  125. },
  126. {
  127. url: this.$code_base_url + '/image/2.png'
  128. },
  129. {
  130. url: this.$code_base_url + '/image/3.png'
  131. }
  132. ],
  133. current: 0, // 开始显示第几个
  134. balance: 0.0.toFixed(2), // 余额
  135. airs: [], // 已经添加成功的空调列表数据
  136. selectAirs: [], // 已经选择的空调列表数据
  137. dotMode: 'round', // 显示控制点样式
  138. isList: false, // 是否显示添加的空调列表
  139. screenHeight: '', // 屏幕的高度
  140. options: 0
  141. };
  142. },
  143. onLoad(options) {
  144. this.options = options
  145. try{
  146. // 选择绑定了的空调
  147. let airs_selected = uni.getStorageSync('airs_selected')
  148. if (airs_selected.length > 0) {
  149. // 使用存储的列表
  150. this.selectAirs = airs_selected
  151. }
  152. }catch(e){
  153. console.log('读取空调相关信息:' + e.message);
  154. }
  155. },
  156. onShow() {
  157. // 从新计算高度
  158. this.calc_screen_height()
  159. // 监听全局的自定义事件,事件由 uni.$emit 触发,但仅触发一次,在第一次触发之后移除该监听器。
  160. // 绑定空调
  161. uni.$once('selectAirs', data => {
  162. // console.log(data.airs);
  163. let arrAirs = data.airs.trim().split(',')
  164. for (var i = 0; i < arrAirs.length; i++) {
  165. let tmpAirs = arrAirs[i].split('|')
  166. let t = tmpAirs[1].split('-')
  167. let tf = true
  168. for (var j = 0; j < this.selectAirs.length; j++) {
  169. if (this.selectAirs[j].air_ip == tmpAirs[2]) {
  170. tf = false
  171. }
  172. }
  173. // 存在则不添加到数组和缓存
  174. if (true === tf) {
  175. this.selectAirs.push({
  176. air_ip: tmpAirs[2],
  177. name: tmpAirs[0] + ' ' + t[0],
  178. info: t[1],
  179. time: '',
  180. on: false, // true开启了,false关闭了
  181. order_num: '' // 订单号
  182. })
  183. }
  184. }
  185. // 如果选的空调不为空,则显示添加的空调列表
  186. if (this.selectAirs.length > 0) {
  187. // 去重
  188. const newArr = [...new Set(this.selectAirs.map(e => JSON.stringify(e)))].map(e => JSON.parse(
  189. e));
  190. this.selectAirs = newArr
  191. }
  192. // 存储空调列表
  193. uni.setStorageSync('airs_selected', this.selectAirs)
  194. // 移除全局自定义事件监听器。
  195. uni.$off('selectAirs')
  196. });
  197. // 获取基本信息
  198. this.get_base_info(this.options, 'onLoad')
  199. },
  200. methods: {
  201. /**
  202. * 查询绑定的空调
  203. */
  204. async select_banding_airs() {
  205. const res = await this.$myRequest({
  206. host: this.ceshi,
  207. url: '/airManage/usersqueryAir.action',
  208. method: 'POST',
  209. header: {
  210. 'content-type': 'application/x-www-form-urlencoded'
  211. },
  212. data: {
  213. sfzh: this.id_card
  214. }
  215. })
  216. // console.log(res.data);
  217. if (res.data.code == 200) {
  218. let data = res.data.data
  219. if (data.length > 0) {
  220. this.airs = []
  221. let tmpAirs = []
  222. for (var i = 0; i < data.length; i++) {
  223. for (var j = 0; j < this.selectAirs.length; j++) {
  224. if (this.selectAirs[j].air_ip == data[i].air_ip) {
  225. tmpAirs.push(this.selectAirs[j])
  226. break
  227. }
  228. }
  229. }
  230. // 不为空
  231. if (tmpAirs.length > 0) {
  232. // 按名称排序
  233. tmpAirs.sort((a, b) => a.name.localeCompare(b.name));
  234. let _this = this;
  235. // 遍历状态
  236. for (var i = 0; i < tmpAirs.length; i++) {
  237. // 获取空调状态
  238. (function(t, tmpAirs) { // 注意这里是形参
  239. setTimeout(function() {
  240. _this.readAirsStatus(tmpAirs, t);
  241. }, 100 * t); // 还是每秒执行一次,不是累加的
  242. })(i, tmpAirs) // 注意这里是实参,这里把要用的参数传进去
  243. }
  244. setTimeout(() => {
  245. if (this.airs.length > 0) {
  246. // 显示添加的空调列表
  247. _this.isList = true
  248. }
  249. }, 300)
  250. }
  251. } else {
  252. // 隐藏添加的空调列表
  253. this.isList = false
  254. }
  255. } else if (res.data.code == 205) {
  256. // 隐藏添加的空调列表
  257. this.isList = false
  258. } else {
  259. // 隐藏添加的空调列表
  260. this.isList = false
  261. // 提示返回信息
  262. uni.showToast({
  263. title: res.data.message
  264. })
  265. }
  266. // 隐藏加载
  267. uni.hideLoading();
  268. },
  269. /**
  270. * 获取绑定的空调的状态
  271. * @param {Object} tmpAirs
  272. * @param {Object} index
  273. */
  274. async readAirsStatus(tmpAirs, index) {
  275. const res = await this.$myRequest({
  276. host: this.ceshi,
  277. url: '/airManage/consumeStatus.action',
  278. method: 'POST',
  279. header: {
  280. 'content-type': 'application/x-www-form-urlencoded'
  281. },
  282. data: {
  283. air_ip: tmpAirs[index].air_ip,
  284. sfzh: this.id_card
  285. }
  286. })
  287. // console.log(res.data);
  288. if (res.data.code == 200) {
  289. let data = res.data;
  290. if (data.is_on == 1) {
  291. for (var i = 0; i < tmpAirs.length; i++) {
  292. if (tmpAirs[i].air_ip == tmpAirs[index].air_ip) {
  293. tmpAirs[i].on = true
  294. tmpAirs[i].time = data.start_time
  295. }
  296. }
  297. }
  298. this.airs.push(tmpAirs[index])
  299. }
  300. },
  301. /**
  302. * 获取基本信息
  303. */
  304. get_base_info(options, param) {
  305. // console.log(options);
  306. uni.showLoading({
  307. title: '加载中',
  308. mask: true
  309. })
  310. // 获取学号
  311. this.stu_number = this.$store.state.userInfo.card_number
  312. try {
  313. if (this.stu_number == '' || typeof(this.stu_number) == 'undefined') { // 学号不存在,可以从存储中拿用户信息
  314. const userinfo = uni.getStorageSync('userinfo_storage_key')
  315. if (userinfo) { // 拿学号
  316. this.userinfo = userinfo
  317. this.stu_number = userinfo.card_number
  318. this.id_card = userinfo.id_card
  319. } else { // 还没有需要跳转到首页进行获取
  320. uni.navigateTo({
  321. url: '../index/index?from=' + options.from
  322. })
  323. uni.showToast({
  324. icon: 'none',
  325. title: '学号为空,请进行授权',
  326. duration: 3000
  327. });
  328. return
  329. }
  330. } else { // 学号已经存在,可以从存储中拿用户信息
  331. this.userinfo = JSON.stringify(uni.getStorageSync('userinfo_storage_key'))
  332. }
  333. } catch (e) {
  334. console.log('获取基本信息:' + e.message);
  335. }
  336. // 获取code
  337. this.getCode(options, param)
  338. if (this.id_card !== '') {
  339. // 查询绑定的空调
  340. this.select_banding_airs()
  341. }
  342. },
  343. /**
  344. * 获得code
  345. */
  346. getCode(options, param) {
  347. uni.login({
  348. success: (res) => {
  349. // console.log('getCode', res);
  350. if (res.code) {
  351. if (param == 'get_user_info') {
  352. this.getUserInfo(res.code)
  353. } else {
  354. // 请求服务器,获得openid
  355. this.getOpenId(options, res.code)
  356. }
  357. } else {
  358. uni.showToast({
  359. title: res.errMsg,
  360. icon: 'none'
  361. });
  362. }
  363. }
  364. })
  365. },
  366. /**
  367. * 请求服务器,获得openid
  368. */
  369. async getOpenId(options, param_code) {
  370. if (typeof this.userinfo === 'object') {
  371. this.userinfo = JSON.stringify(this.userinfo)
  372. }
  373. const res = await this.$myRequest({
  374. host: this.ceshi,
  375. url: '/airManage/usersopenid.action',
  376. method: 'POST',
  377. header: {
  378. 'content-type': 'application/x-www-form-urlencoded'
  379. },
  380. data: {
  381. code: param_code,
  382. userinfo: this.userinfo
  383. }
  384. })
  385. // console.log(res.data);
  386. if (res.data.code == 200) {
  387. // 查询用户基本信息
  388. this.getCode(options, 'get_user_info')
  389. // 绑定成功,提示返回信息,但没必要提示
  390. // uni.showToast({
  391. // title: res.data.message
  392. // })
  393. } else if (res.data.code == 205) {
  394. // 查询用户基本信息
  395. this.getCode(options, 'get_user_info')
  396. // 用户已经存在,但没必要提示
  397. // uni.showToast({
  398. // title: res.data.message
  399. // })
  400. } else {
  401. // 提示返回信息
  402. uni.showToast({
  403. title: res.data.message
  404. })
  405. if (options && typeof(options.from) != 'undefined' && typeof(options.from) != '') {
  406. uni.navigateTo({
  407. url: '../index/index?from=' + options.from
  408. })
  409. } else {
  410. uni.redirectTo({
  411. url: '../index/index?from=0'
  412. });
  413. }
  414. }
  415. },
  416. /**
  417. * 获取用户基本信息
  418. * @param {Object} code
  419. */
  420. async getUserInfo(code) {
  421. const res = await this.$myRequest({
  422. host: this.ceshi,
  423. url: '/airManage/usersget_user.action',
  424. method: 'POST',
  425. header: {
  426. 'content-type': 'application/x-www-form-urlencoded'
  427. },
  428. data: {
  429. code: code
  430. }
  431. })
  432. // console.log(res.data);
  433. if (res.data.code == 200) {
  434. // 余额
  435. this.balance = res.data.data.balance.toFixed(2)
  436. this.id_card = res.data.data.sfzh
  437. if (this.isList == false) {
  438. // 查询绑定的空调
  439. this.select_banding_airs()
  440. }
  441. } else {
  442. uni.showToast({
  443. title: res.data.message
  444. })
  445. }
  446. },
  447. /**
  448. * 长按可删除
  449. * @param {Object} e
  450. * @param {Object} val
  451. */
  452. itemLongPress(e, val, air_ip) {
  453. // console.log(e, val, air_ip);
  454. if (val == 0) {
  455. let index = e.currentTarget.dataset.ref
  456. uni.showModal({
  457. title: '提示',
  458. content: '是否删除该空调?',
  459. success: (res) => {
  460. if (res.confirm) {
  461. // 解绑空调
  462. this.unbangding_airs(air_ip, index)
  463. }
  464. }
  465. })
  466. } else {
  467. uni.showToast({
  468. title: '使用中不能删除',
  469. icon: 'error',
  470. duration: 1000
  471. })
  472. }
  473. },
  474. /**
  475. * 解绑空调
  476. * @param {Object} air_ip
  477. * @param {Object} index
  478. */
  479. async unbangding_airs(air_ip, index) {
  480. const res = await this.$myRequest({
  481. host: this.ceshi,
  482. url: '/airManage/usersdelAir.action',
  483. method: 'POST',
  484. header: {
  485. 'content-type': 'application/x-www-form-urlencoded'
  486. },
  487. data: {
  488. sfzh: this.id_card,
  489. air_ip: air_ip
  490. }
  491. })
  492. // console.log(res.data);
  493. if (res.data.code == 200) {
  494. // 删除指定下标的元素
  495. this.airs.splice(index, 1)
  496. if (this.airs.length == 0) {
  497. this.isList = false
  498. }
  499. uni.showToast({
  500. title: res.data.message
  501. })
  502. } else {
  503. uni.showToast({
  504. title: res.data.message
  505. })
  506. }
  507. },
  508. /**
  509. * 单击了启动或关闭按钮
  510. * @param {Object} e
  511. */
  512. btn_click(index, air_ip, name, info, order_num) {
  513. // console.log(index, air_ip, name, info, order_num);
  514. let tmp = name.split('-');
  515. let build = tmp[1],
  516. floors = tmp[2],
  517. dom = tmp[3] + '-' + tmp[4].split(' ')[0];
  518. let air_name = name.split(' ')[1]
  519. // 未获取到索引
  520. if (typeof index === 'undefined') {
  521. return
  522. }
  523. if (this.airs[index].on) {
  524. uni.showModal({
  525. title: '提示',
  526. content: '确认【关闭】空调吗?',
  527. success: (res) => {
  528. if (res.confirm) {
  529. // 【关闭】空调
  530. this.close_airs(index, air_ip, order_num)
  531. }
  532. }
  533. });
  534. } else {
  535. uni.showModal({
  536. title: '提示',
  537. content: '确认【启动】空调吗?',
  538. success: (res) => {
  539. if (res.confirm) {
  540. // 【启动】空调
  541. uni.login({
  542. success: (res) => {
  543. // console.log('getCode', res);
  544. if (res.code) {
  545. // 调用接口,开启空调
  546. this.open_airs(res.code, index, air_ip, build, floors,
  547. dom, info, air_name)
  548. } else {
  549. uni.showToast({
  550. title: res.errMsg,
  551. icon: 'none'
  552. });
  553. }
  554. }
  555. })
  556. }
  557. }
  558. });
  559. }
  560. },
  561. /**
  562. * 关闭空调
  563. * @param {Object} index
  564. * @param {Object} air_ip
  565. */
  566. async close_airs(index, air_ip, order_num) {
  567. if (order_num == '') {
  568. uni.showToast({
  569. title: '未获得单号'
  570. })
  571. return
  572. }
  573. if (this.id_card == '') {
  574. uni.showToast({
  575. title: '未获得身份证号'
  576. })
  577. return
  578. }
  579. const res = await this.$myRequest({
  580. host: this.ceshi,
  581. url: '/airManage/consumeend.action',
  582. method: 'POST',
  583. header: {
  584. 'content-type': 'application/x-www-form-urlencoded'
  585. },
  586. data: {
  587. sfzh: this.id_card,
  588. order_num: order_num,
  589. air_ip: air_ip
  590. }
  591. })
  592. console.log(res.data);
  593. if (res.data.code == 200) {
  594. // 等待1s
  595. uni.showLoading({
  596. title: '关闭中...',
  597. mask: true
  598. });
  599. // 延时1s看开启状态
  600. let _this = this;
  601. setTimeout(() => {
  602. // 查询是否开启成功
  603. _this.selectAirCloseState(index, air_ip, order_num)
  604. }, 1000);
  605. } else {
  606. uni.showToast({
  607. icon: 'none',
  608. title: res.data.message,
  609. duration: 3000
  610. })
  611. }
  612. },
  613. /**
  614. * 查询是否关闭成功
  615. * @param {Object} index
  616. * @param {Object} air_ip
  617. */
  618. async selectAirCloseState(index, air_ip, order_num) {
  619. // console.log(index, air_ip);
  620. const res = await this.$myRequest({
  621. host: this.ceshi,
  622. url: '/airManage/consumeairoffStatus.action',
  623. method: 'POST',
  624. header: {
  625. 'content-type': 'application/x-www-form-urlencoded'
  626. },
  627. data: {
  628. air_ip: air_ip,
  629. order_num: order_num
  630. }
  631. })
  632. console.log(res.data);
  633. if (res.data.code == 200) {
  634. if (res.data.is_on == 0) {
  635. // 显示已经关闭图标
  636. this.airs[index].on = false
  637. uni.showToast({
  638. title: '关闭成功!',
  639. duration: 2000
  640. });
  641. } else {
  642. uni.showToast({
  643. icon: 'none',
  644. title: '关闭失败!',
  645. duration: 2000
  646. });
  647. }
  648. uni.hideLoading();
  649. } else {
  650. uni.showToast({
  651. icon: 'none',
  652. title: res.data.message,
  653. duration: 2000
  654. });
  655. }
  656. },
  657. /**
  658. * 启动空调
  659. * @param {Object} code
  660. * @param {Object} index
  661. * @param {Object} air_ip
  662. * @param {Object} build
  663. * @param {Object} floors
  664. * @param {Object} dom
  665. * @param {Object} air_config
  666. */
  667. async open_airs(code, index, air_ip, build, floors, dom, air_config, air_name) {
  668. const res = await this.$myRequest({
  669. host: this.ceshi,
  670. url: '/airManage/consumestart.action',
  671. method: 'POST',
  672. header: {
  673. 'content-type': 'application/x-www-form-urlencoded'
  674. },
  675. data: {
  676. code: code,
  677. air_ip: air_ip,
  678. build: build,
  679. floors: floors,
  680. dom: dom,
  681. air_config: air_config,
  682. air_name: air_name
  683. }
  684. })
  685. console.log(res.data);
  686. if (res.data.code == 200) {
  687. // 等待12s
  688. uni.showLoading({
  689. title: '开启中...',
  690. mask: true
  691. });
  692. // 延时12s看开启状态
  693. let _this = this;
  694. setTimeout(() => {
  695. // 查询是否开启成功
  696. _this.selectAirOpenState(index, air_ip)
  697. }, 12000);
  698. } else {
  699. uni.showToast({
  700. icon: 'none',
  701. title: res.data.message,
  702. duration: 2000
  703. })
  704. }
  705. },
  706. /**
  707. * 查询是否开启成功
  708. * @param {Object} index
  709. * @param {Object} air_ip
  710. */
  711. async selectAirOpenState(index, air_ip) {
  712. // console.log(index, air_ip);
  713. const res = await this.$myRequest({
  714. host: this.ceshi,
  715. url: '/airManage/consumeairStatus.action',
  716. method: 'POST',
  717. header: {
  718. 'content-type': 'application/x-www-form-urlencoded'
  719. },
  720. data: {
  721. air_ip: air_ip,
  722. order_num: this.order_num
  723. }
  724. })
  725. console.log(res.data);
  726. if (res.data.code == 200) {
  727. if (res.data.is_on == 1) {
  728. let _this = this
  729. uni.showToast({
  730. title: '开启成功!',
  731. duration: 2000,
  732. success() {
  733. // 将开启按钮变成关闭按钮
  734. _this.airs[index].on = true;
  735. _this.airs[index].time = res.data.start_time;
  736. }
  737. });
  738. } else {
  739. uni.showToast({
  740. title: '开启失败!',
  741. duration: 2000
  742. });
  743. }
  744. uni.hideLoading();
  745. } else {
  746. uni.showToast({
  747. icon: 'none',
  748. title: res.data.message,
  749. duration: 2000
  750. });
  751. }
  752. },
  753. /**
  754. * 滚动到顶部提示
  755. */
  756. scroll_to_upper() {
  757. uni.showToast({
  758. title: '到顶了!',
  759. icon: 'none',
  760. duration: 500
  761. })
  762. },
  763. /**
  764. * 滚动到底部提示
  765. */
  766. scroll_to_lower() {
  767. uni.showToast({
  768. title: '到底了!',
  769. icon: 'none',
  770. duration: 500
  771. })
  772. },
  773. /**
  774. * 轮播图发生改变
  775. * @param {Object} e
  776. */
  777. swiper_change(e) {
  778. // console.log(e.detail.current);
  779. this.current = e.detail.current;
  780. },
  781. /**
  782. * 计算屏幕的高度, 适配屏幕的高度
  783. */
  784. calc_screen_height() {
  785. uni.getSystemInfo({
  786. success: res => {
  787. let h = 0;
  788. if (this.isList === true) {
  789. h = ((res.screenHeight * (750 / res.windowWidth)) - 640) //将px 转换rpx
  790. } else {
  791. h = ((res.screenHeight * (750 / res.windowWidth)) - 740) //将px 转换rpx
  792. }
  793. this.screenHeight = Math.floor(h) + 'rpx'
  794. }
  795. });
  796. }
  797. }
  798. }
  799. </script>
  800. <style lang="scss" scoped>
  801. .container {
  802. display: flex;
  803. flex-direction: column;
  804. font-size: 28rpx;
  805. font-family: "Microsoft YaHei-3970(82674968)";
  806. width: 730rpx;
  807. padding: 10rpx;
  808. .swiper-box {
  809. height: 150px;
  810. width: 100%;
  811. }
  812. swiper-item {
  813. /* #ifndef APP-NVUE */
  814. display: flex;
  815. /* #endif */
  816. flex-direction: column;
  817. justify-content: center;
  818. align-items: center;
  819. height: 100%;
  820. image {
  821. height: 100%;
  822. width: 100%;
  823. border-radius: 8rpx;
  824. }
  825. }
  826. .line {
  827. height: 20rpx;
  828. }
  829. .nav {
  830. display: flex;
  831. justify-content: space-between;
  832. .btn {
  833. display: flex;
  834. justify-content: space-between;
  835. align-items: center;
  836. width: 338rpx;
  837. height: 100rpx;
  838. padding: 5rpx 10rpx;
  839. border-radius: 8rpx;
  840. background-color: #eaefff;
  841. .btn-icon-tzgl {
  842. display: flex;
  843. align-items: center;
  844. image {
  845. width: 40rpx;
  846. height: 40rpx;
  847. padding: 10rpx;
  848. }
  849. }
  850. .btn-icon {
  851. display: flex;
  852. align-items: center;
  853. image {
  854. width: 60rpx;
  855. height: 60rpx;
  856. }
  857. }
  858. .txt-right {
  859. display: flex;
  860. align-items: center;
  861. }
  862. }
  863. }
  864. .add-air {
  865. border-radius: 8rpx;
  866. padding: 60rpx 10rpx;
  867. background-color: #F1F1F1;
  868. .add-content {
  869. display: flex;
  870. justify-content: space-around;
  871. align-items: center;
  872. margin-bottom: 20rpx;
  873. .add-left {
  874. display: flex;
  875. .add-btn {
  876. display: flex;
  877. flex-direction: column;
  878. justify-content: center;
  879. align-items: center;
  880. margin-right: 20rpx;
  881. width: 120rpx;
  882. height: 120rpx;
  883. border-radius: 20rpx;
  884. background-color: #2979ff;
  885. color: #ffffff;
  886. }
  887. .add-tip {
  888. display: flex;
  889. flex-direction: column;
  890. justify-content: space-around;
  891. .txt-add-air {
  892. font-size: 40rpx;
  893. font-weight: bold;
  894. }
  895. .txt-tip {
  896. font-size: 20rpx;
  897. color: #8f939c;
  898. }
  899. }
  900. }
  901. .add-right {
  902. width: 300rpx;
  903. height: 100rpx;
  904. border-radius: 10rpx;
  905. image {
  906. width: 300rpx;
  907. height: 100rpx;
  908. }
  909. }
  910. }
  911. .add-bg {
  912. display: flex;
  913. justify-content: center;
  914. align-items: center;
  915. padding-top: 90rpx;
  916. image {
  917. width: 400rpx;
  918. height: 400rpx;
  919. }
  920. }
  921. }
  922. .list-air {
  923. border-radius: 8rpx;
  924. padding: 10rpx 10rpx;
  925. background-color: #e9e9eb;
  926. .list-items {
  927. display: flex;
  928. flex-direction: column;
  929. .item-air {
  930. display: flex;
  931. justify-content: space-between;
  932. padding: 30rpx 20rpx;
  933. border-bottom: 1px solid #c3c8d4;
  934. .item-left {
  935. display: flex;
  936. flex-direction: column;
  937. justify-content: space-around;
  938. .item-icon {
  939. display: flex;
  940. align-items: center;
  941. .circle1 {
  942. width: 16rpx;
  943. height: 16rpx;
  944. border-radius: 8rpx;
  945. background-color: #18bc37;
  946. }
  947. .circle2 {
  948. width: 12rpx;
  949. height: 12rpx;
  950. border-radius: 6rpx;
  951. background-color: #18bc37;
  952. margin: 0 10rpx;
  953. }
  954. .circle3 {
  955. display: inline-block;
  956. width: 8rpx;
  957. height: 8rpx;
  958. border-radius: 4rpx;
  959. background-color: #18bc37;
  960. }
  961. }
  962. .item-title {
  963. font-size: 32rpx;
  964. font-weight: bold;
  965. padding-bottom: 12rpx;
  966. }
  967. .item-info {
  968. display: flex;
  969. color: #8f939c;
  970. .item-info-left {
  971. padding-right: 20rpx;
  972. }
  973. .item-info-icon {
  974. width: 40rpx;
  975. height: 40rpx;
  976. margin-right: 8rpx;
  977. }
  978. }
  979. }
  980. .item-right {
  981. .item-btn {
  982. display: flex;
  983. flex-direction: column;
  984. justify-content: center;
  985. align-items: center;
  986. margin-left: 20rpx;
  987. width: 100rpx;
  988. height: 100rpx;
  989. border: 1px solid #d9deeb;
  990. border-radius: 50rpx;
  991. box-shadow: 4rpx 4rpx 5rpx #c8cdd8;
  992. background-image: linear-gradient(-45deg, #F2F4F2, #DFDFDF);
  993. image {
  994. width: 50rpx;
  995. height: 50rpx;
  996. }
  997. .item-txt-on {
  998. font-size: 24rpx;
  999. font-weight: bold;
  1000. color: #4B8DFB;
  1001. }
  1002. .item-txt-off {
  1003. font-size: 24rpx;
  1004. font-weight: bold;
  1005. color: #8A8A8A;
  1006. }
  1007. }
  1008. }
  1009. }
  1010. }
  1011. .add-air-bottom {
  1012. display: flex;
  1013. justify-content: center;
  1014. margin: 20rpx 0;
  1015. padding: 20rpx 0;
  1016. width: 160rpx;
  1017. border-radius: 10rpx;
  1018. .add-btn-bottom {
  1019. font-size: 40rpx;
  1020. color: #4B8DFB;
  1021. padding-left: 8rpx;
  1022. }
  1023. }
  1024. }
  1025. }
  1026. </style>