index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. <template>
  2. <view class="page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title='智慧空调' bgColor='transparent'></cus-header>
  4. <image class="bg" :src="imgBase+'home/kongtiao_bg.png'" mode="widthFix"></image>
  5. <div class="nums">
  6. <div class="pre">空调:<span class="mr">{{ktNum}}</span></div>
  7. <div class="pre">正常:<span class="zc">{{zcNum}}</span></div>
  8. <div class="pre">离线:<span class="lx">{{lxNum}}</span></div>
  9. </div>
  10. <div class="boxs" v-if="list.length">
  11. <div class="box" v-for="(item,index) in list" :key="index" :style="{'background':modeCfg[item.attributeList[2].value].color}" @tap="showDetail(item,index)">
  12. <image :src="modeCfg[item.attributeList[2].value].icon.split(';')[0]" class="type" mode="widthFix"></image>
  13. <div class="place">{{item.installSite}}{{item.roomNumbers}}</div>
  14. <div class="position">{{item.airConditionerName}}</div>
  15. <div class="temperature" :class="{'off':item.opStatus==0}">{{item.attributeList[5].value}}℃</div>
  16. <div class="text">温度</div>
  17. <div class="btn" v-if="item.opStatus==1" @tap.stop="switchOpenClose(1,item.deviceId, index,item.attributeList[3].sensorAddress)">
  18. <div class="circle"></div>
  19. <text style="margin-left: 4rpx;">ON</text>
  20. </div>
  21. <div class="btn" v-else-if="item.opStatus==0" @tap.stop="switchOpenClose(0,item.deviceId, index,item.attributeList[3].sensorAddress)">
  22. <text style="margin-right: 4rpx;">OFF</text>
  23. <div class="circle off"></div>
  24. </div>
  25. </div>
  26. </div>
  27. <template v-else>
  28. <page-empty :height="'calc(100vh - 200px)'"></page-empty>
  29. </template>
  30. <u-popup :show="show" mode="bottom" :round="40" @close="ktClose">
  31. <div class="kt_info">
  32. <div class="top">
  33. <div class="left">
  34. <image :src="imgBase+'home/kongtiao_kt.png'"></image>
  35. <div class="addr">
  36. <text>{{ktInfo.installSite}}{{ktInfo.roomNumbers}}</text>
  37. <text class="ts">{{ktInfo.airConditionerName}}</text>
  38. </div>
  39. </div>
  40. <div class="right" @tap="ktClose">
  41. <u-icon name="close" color="#333333" size="48"></u-icon>
  42. </div>
  43. </div>
  44. <template v-if="!setShow">
  45. <!-- <image class="setting" :src="imgBase+'home/kongtiao_set.png'" @tap="setShow = true"></image> -->
  46. <div class="wendu">
  47. <TemperatureControl :temperature="temperature" @changeTemperature="changeTemperature" ref="tcRef"></TemperatureControl>
  48. </div>
  49. <div class="type" v-if="ktInfo.attributeList&&ktInfo.attributeList.length">
  50. <div class="pre" v-for="item in modeList" :key="item.id" :style="{'width':'calc(100% / '+modeList.length+' - 20rpx)'}"
  51. :class="{'active':temperature&&modeValue==item.dictValue}" @tap="changeType(item.dictValue)">
  52. <image :src="item.icon.split(';')[2]" v-if="temperature&&modeValue==item.dictValue"></image>
  53. <image :src="item.icon.split(';')[1]" v-else></image>
  54. <text>{{item.dictLabel}}</text>
  55. </div>
  56. </div>
  57. <div class="speend">
  58. <text>风速</text>
  59. <image class="jian" :src="imgBase+'home/kongtiao_jian.png'" @tap="changeWindSpeend(1)"></image>
  60. <div class="area" v-if="speendList.length">
  61. <div class="pre" :class="{'active':temperature&&speendValue==item.dictValue}"
  62. :style="{'width':'calc(100% / '+speendList.length+' - 3rpx)'}"
  63. v-for="item in speendList" :key="item.id">
  64. <div class="text" v-if="temperature&&speendValue==item.dictValue">{{item.dictLabel}}</div>
  65. </div>
  66. </div>
  67. <image class="jia" :src="imgBase+'home/kongtiao_jia.png'" @tap="changeWindSpeend(2)"></image>
  68. </div>
  69. <div class="btns">
  70. <!-- <div class="btn" :class="{'blue':wtype==1}" @tap="changeWindFx(1)">左右扫风</div> -->
  71. <div></div>
  72. <image :src="imgBase+'home/kongtiao_open1.png'" v-if="ktInfo.opStatus==1" @tap="control(1)"></image>
  73. <image :src="imgBase+'home/kongtiao_open2.png'" v-else-if="ktInfo.opStatus==0" @tap="control(0)"></image>
  74. <!-- <div class="btn" :class="{'blue':wtype==2}" @tap="changeWindFx(2)">上下扫风</div> -->
  75. <div></div>
  76. </div>
  77. </template>
  78. <template v-else>
  79. <div class="form">
  80. <div class="item">
  81. <div class="left">所属楼栋</div>
  82. <div class="right">
  83. <input type="text" placeholder="请输入楼栋">
  84. </div>
  85. </div>
  86. <div class="item">
  87. <div class="left">所属楼层</div>
  88. <div class="right">
  89. <input type="text" placeholder="请输入楼层">
  90. </div>
  91. </div>
  92. <div class="item">
  93. <div class="left">房间号</div>
  94. <div class="right">
  95. <input type="text" placeholder="请输入房间号">
  96. </div>
  97. </div>
  98. <div class="item">
  99. <div class="left">设备序列号</div>
  100. <div class="right">
  101. <input type="text" placeholder="请输入设备序列号">
  102. </div>
  103. </div>
  104. <div class="item">
  105. <div class="left">空调名称</div>
  106. <div class="right">
  107. <input type="text" placeholder="请输入空调名称">
  108. </div>
  109. </div>
  110. <div class="item">
  111. <div class="left">空调编号</div>
  112. <div class="right">
  113. <input type="text" placeholder="请输入空调编号">
  114. </div>
  115. </div>
  116. <div class="item">
  117. <div class="left">是否为公共区域</div>
  118. <div class="right">
  119. <u-switch></u-switch>
  120. </div>
  121. </div>
  122. </div>
  123. <div class="confirm" @tap="confirmSet">确定</div>
  124. </template>
  125. </div>
  126. </u-popup>
  127. </view>
  128. </template>
  129. <script>
  130. import TemperatureControl from '@/pagesHome/components/TemperatureControl/index.vue'
  131. import pageEmpty from '@/components/pageEmpty/index.vue'
  132. export default {
  133. components:{
  134. TemperatureControl,
  135. pageEmpty
  136. },
  137. data(){
  138. return {
  139. ktNum:0,
  140. zcNum:0,
  141. lxNum:0,
  142. params:{
  143. page:1,
  144. limit:9999,
  145. controlCategory:'CommonLighting'
  146. },
  147. modeList:[],
  148. modeCfg:{},
  149. modeValue:'',
  150. speendList:[],
  151. speendCfg:{},
  152. speendValue:'',
  153. ktStatus:'',
  154. temperature:0,
  155. list:[],
  156. lIndex:'',
  157. show:false,
  158. setShow:false,
  159. ktInfo:{},
  160. wtype:1,
  161. canClick:true
  162. }
  163. },
  164. async onLoad() {
  165. await this.getModeList();
  166. await this.getSpeendList();
  167. this.getList();
  168. },
  169. onPullDownRefresh() {
  170. this.getList();
  171. },
  172. methods:{
  173. async getModeList(){
  174. let res = await this.$api.get('/sys/dict/data/getListByType/air_mode');
  175. if(res.data.code===0){
  176. this.modeList = res.data.data;
  177. res.data.data.map(d=>this.modeCfg[d.dictValue]=d);
  178. }else this.$showToast(res.data.msg)
  179. },
  180. async getSpeendList(){
  181. let res = await this.$api.get('/sys/dict/data/getListByType/air_fan');
  182. if(res.data.code===0){
  183. this.speendList = res.data.data;
  184. res.data.data.map(d=>this.speendCfg[d.dictValue]=d);
  185. }else this.$showToast(res.data.msg)
  186. },
  187. getList(){
  188. this.$api.get('/airconditioner/page',this.params).then(res=>{
  189. if(res.data.code===0){
  190. this.list = res.data.data.list;
  191. this.ktNum = res.data.data.total;
  192. this.zcNum = this.list.filter(l=>l.opStatus==1).length;
  193. this.lxNum = this.list.filter(l=>l.opStatus==0).length;
  194. }else this.$showToast(res.data.msg)
  195. })
  196. },
  197. showDetail(item,index){
  198. this.ktInfo = JSON.parse(JSON.stringify(item));
  199. this.ktStatus = item.opStatus;
  200. this.modeValue = this.ktInfo.attributeList[2].value;
  201. this.temperature = this.ktInfo.attributeList[5].value;
  202. this.speendValue = this.ktInfo.attributeList[0].value;
  203. this.lIndex = index;
  204. this.show = true;
  205. this.$refs.tcRef.status = this.ktStatus;
  206. this.$refs.tcRef.sjTemperature = this.temperature;
  207. this.$refs.tcRef.init();
  208. },
  209. changeType(type){
  210. if(this.ktInfo.opStatus==0) return
  211. if(this.modeValue == type) return
  212. this.modeValue = type;
  213. this.updateAirConditioner(type,this.ktInfo.attributeList[2].sensorAddress)
  214. },
  215. changeWindSpeend(type){
  216. if(this.ktInfo.opStatus==0) return
  217. let idx = this.speendList.findIndex(s=>s.dictValue==this.speendValue)
  218. if(idx>-1){
  219. if(type==1){
  220. if(idx==0) return
  221. this.speendValue = this.speendList[idx-1].dictValue;
  222. }else if(type==2){
  223. if(idx==this.speendList.length-1) return
  224. this.speendValue = this.speendList[idx+1].dictValue;
  225. }
  226. }
  227. this.updateAirConditioner(this.speendValue,this.ktInfo.attributeList[0].sensorAddress)
  228. },
  229. // changeWindFx(type){
  230. // if(this.ktInfo.opStatus==0) return
  231. // },
  232. control(status){
  233. this.openCloseAirConditioner(status,this.ktInfo.deviceId,this.lIndex,this.ktInfo.attributeList[3].sensorAddress);
  234. },
  235. ktClose(){
  236. this.ktInfo = {};
  237. this.setShow = false;
  238. this.show = false;
  239. },
  240. confirmSet(){
  241. this.setShow = false;
  242. },
  243. changeTemperature(temperature){
  244. this.updateAirConditioner(temperature,this.ktInfo.attributeList[5].sensorAddress)
  245. },
  246. switchOpenClose(status,deviceId,index,identifier){
  247. this.openCloseAirConditioner(status,deviceId,index,identifier);
  248. },
  249. openCloseAirConditioner(status,deviceId,index,identifier){
  250. let msg = status?'关闭':'开启';
  251. uni.showModal({
  252. title:'温馨提示',
  253. content:`是否确认【${msg}】此设备`,
  254. success: (res) => {
  255. if(res.confirm){
  256. this.$api.post('/airconditioner/command',{
  257. identifier,
  258. action: 0,
  259. value: status? 0 : 1,
  260. deviceId,
  261. }).then(resu=>{
  262. if(resu.data.code===0){
  263. this.show = false;
  264. this.$showToast('操作成功');
  265. setTimeout(()=>{
  266. this.getList();
  267. },3000)
  268. }else this.$showToast(resu.data.msg)
  269. })
  270. }
  271. }
  272. })
  273. },
  274. updateAirConditioner(value, identifier){
  275. if(!this.canClick) return
  276. this.canClick = false;
  277. this.$api.post('/airconditioner/command',{
  278. action: 0,
  279. identifier,
  280. value,
  281. deviceId:this.ktInfo.deviceId,
  282. }).then(resu=>{
  283. if(resu.data.code===0){
  284. this.show = false;
  285. this.$showToast('操作成功');
  286. setTimeout(()=>{
  287. this.getList();
  288. },3000)
  289. }else this.$showToast(resu.data.msg)
  290. this.canClick = true;
  291. }).catch(err=>{
  292. this.canClick = true;
  293. })
  294. }
  295. }
  296. }
  297. </script>
  298. <style scoped lang="less">
  299. .page{
  300. width: 100%;
  301. padding: 0 24rpx 20rpx;
  302. box-sizing: border-box;
  303. background: #F4F8FB;
  304. .bg{
  305. width: 100%;
  306. position: fixed;
  307. top: 0;
  308. left: 0;
  309. z-index: 0;
  310. }
  311. .nums{
  312. width: 100%;
  313. background: #FFFFFF;
  314. border-radius: 16rpx;
  315. padding: 37rpx 24rpx;
  316. box-sizing: border-box;
  317. display: flex;
  318. margin-top: 20rpx;
  319. position: relative;
  320. .pre{
  321. width: calc(100% / 3);
  322. font-family: PingFangSC, PingFang SC;
  323. font-weight: 400;
  324. font-size: 30rpx;
  325. color: #4E5969;
  326. line-height: 36rpx;
  327. text-align: left;
  328. span{
  329. font-family: PingFang-SC, PingFang-SC;
  330. font-weight: bold;
  331. font-size: 32rpx;
  332. line-height: 36rpx;
  333. text-align: left;
  334. &.mr{
  335. color: #1D2129;
  336. }
  337. &.zc{
  338. color: #14CC8C;
  339. }
  340. &.lx{
  341. color: #F95050;
  342. }
  343. }
  344. }
  345. }
  346. .boxs{
  347. position: relative;
  348. display: flex;
  349. flex-wrap: wrap;
  350. justify-content: space-between;
  351. margin-top: 4rpx;
  352. .box{
  353. width: calc(50% - 11rpx);
  354. box-shadow: 0rpx 4rpx 12rpx 0rpx rgba(35,130,255,0.1), inset 0rpx 3rpx 3rpx 0rpx #FFFFFF;
  355. border-radius: 16rpx;
  356. margin-top: 20rpx;
  357. padding: 32rpx 21rpx 42rpx 29rpx;
  358. box-sizing: border-box;
  359. position: relative;
  360. .type{
  361. width: 164rpx;
  362. height: 164rpx;
  363. position: absolute;
  364. top: 0;
  365. right: 0;
  366. z-index: 9;
  367. }
  368. .place{
  369. font-family: PingFang-SC, PingFang-SC;
  370. font-weight: bold;
  371. font-size: 30rpx;
  372. color: #1D2129;
  373. line-height: 42rpx;
  374. white-space: nowrap;
  375. overflow: hidden;
  376. text-overflow: ellipsis;
  377. }
  378. .position{
  379. font-family: PingFangSC, PingFang SC;
  380. font-weight: 400;
  381. font-size: 24rpx;
  382. color: #86909C;
  383. line-height: 33rpx;
  384. white-space: nowrap;
  385. overflow: hidden;
  386. text-overflow: ellipsis;
  387. margin-top: 16rpx;
  388. }
  389. .temperature{
  390. font-family: PingFang-SC, PingFang-SC;
  391. font-weight: bold;
  392. font-size: 54rpx;
  393. color: #198CFF;
  394. line-height: 64rpx;
  395. margin-top: 33rpx;
  396. &.off{
  397. color: #4E5969;
  398. }
  399. }
  400. .text{
  401. font-family: PingFangSC, PingFang SC;
  402. font-weight: 400;
  403. font-size: 24rpx;
  404. color: #86909C;
  405. line-height: 33rpx;
  406. margin-top: 9rpx;
  407. }
  408. .btn{
  409. width: 98rpx;
  410. height: 54rpx;
  411. background: #FFFFFF;
  412. box-shadow: 0rpx 2rpx 8rpx 0rpx rgba(0,0,0,0.06), inset 0rpx 2rpx 4rpx 0rpx #FFFFFF, inset 0rpx -1rpx 1rpx 0rpx #FFFFFF;
  413. border-radius: 27rpx;
  414. display: flex;
  415. align-items: center;
  416. justify-content: center;
  417. position: absolute;
  418. right: 21rpx;
  419. bottom: 40rpx;
  420. .circle{
  421. width: 24rpx;
  422. height: 24rpx;
  423. background: #6FDD93;
  424. border-radius: 50%;
  425. &.off{
  426. background: #CCCCCC;
  427. }
  428. }
  429. text{
  430. font-family: PingFang-SC, PingFang-SC;
  431. font-weight: bold;
  432. font-size: 24rpx;
  433. color: #1D2129;
  434. line-height: 33rpx;
  435. }
  436. }
  437. }
  438. }
  439. .kt_info{
  440. width: 100%;
  441. padding: 40rpx 30rpx 65rpx;
  442. box-sizing: border-box;
  443. background: #FFFFFF;
  444. position: relative;
  445. border-radius: 40rpx 40rpx 0 0;
  446. .top{
  447. display: flex;
  448. justify-content: space-between;
  449. .left{
  450. display: flex;
  451. image{
  452. width: 72rpx;
  453. height: 72rpx;
  454. }
  455. .addr{
  456. display: flex;
  457. flex-direction: column;
  458. margin-left: 20rpx;
  459. text{
  460. font-family: PingFang-SC, PingFang-SC;
  461. font-weight: bold;
  462. font-size: 30rpx;
  463. color: #1D2129;
  464. line-height: 42rpx;
  465. text-align: left;
  466. &.ts{
  467. font-weight: 400;
  468. font-size: 24rpx;
  469. color: #86909C;
  470. margin-top: 16rpx;
  471. }
  472. }
  473. }
  474. }
  475. }
  476. .setting{
  477. width: 48rpx;
  478. height: 48rpx;
  479. position: absolute;
  480. right: 30rpx;
  481. top: 165rpx;
  482. z-index: 9;
  483. }
  484. .wendu{
  485. width: 484rpx;
  486. height: 484rpx;
  487. margin: 69rpx auto 0;
  488. }
  489. .type{
  490. display: flex;
  491. justify-content: space-around;
  492. margin-top: 20rpx;
  493. .pre{
  494. margin: 0 10rpx;
  495. padding: 36rpx 0;
  496. display: flex;
  497. flex-direction: column;
  498. align-items: center;
  499. background: linear-gradient( 180deg, #ECF2F7 0%, #FFFFFF 100%);
  500. box-shadow: 0rpx 4rpx 16rpx 0rpx #EDF4FF, inset 0rpx 3rpx 3rpx 0rpx #FFFFFF;
  501. border-radius: 16rpx;
  502. border: 2rpx solid #FFFFFF;
  503. image{
  504. width: 48rpx;
  505. height: 48rpx;
  506. }
  507. text{
  508. font-family: PingFangSC, PingFang SC;
  509. font-weight: 400;
  510. font-size: 28rpx;
  511. color: #1D2129;
  512. line-height: 40rpx;
  513. text-align: center;
  514. margin-top: 16rpx;
  515. }
  516. &.active{
  517. background: #198CFF;
  518. box-shadow: 0rpx 4rpx 16rpx 4rpx #EDF4FF;
  519. text{
  520. font-weight: bold;
  521. color: #FFFFFF;
  522. }
  523. }
  524. }
  525. }
  526. .speend{
  527. width: 100%;
  528. padding-left: 20rpx;
  529. box-sizing: border-box;
  530. display: flex;
  531. align-items: center;
  532. margin-top: 80rpx;
  533. text{
  534. font-family: PingFangSC, PingFang SC;
  535. font-weight: 400;
  536. font-size: 28rpx;
  537. color: #1D2129;
  538. line-height: 40rpx;
  539. }
  540. image{
  541. width: 32rpx;
  542. height: 32rpx;
  543. margin: 0 20rpx;
  544. }
  545. .area{
  546. width: calc(100% - 200rpx);
  547. height: 20rpx;
  548. border-radius: 16rpx;
  549. display: flex;
  550. justify-content: space-between;
  551. .pre{
  552. height: 20rpx;
  553. background: #EDF4FF;
  554. position: relative;
  555. &.active{
  556. background: linear-gradient( 90deg, #3A8DFF 0%, #0BC6FF 100%);
  557. box-shadow: 0rpx 4rpx 16rpx 4rpx #EFEFEF;
  558. }
  559. .text{
  560. width: 100%;
  561. font-family: PingFangSC, PingFang SC;
  562. font-weight: 400;
  563. font-size: 24rpx;
  564. color: #86909C;
  565. line-height: 33rpx;
  566. text-align: center;
  567. position: absolute;
  568. top: -33rpx;
  569. }
  570. }
  571. }
  572. }
  573. .btns{
  574. display: flex;
  575. align-items: center;
  576. justify-content: space-between;
  577. margin-top: 28rpx;
  578. .btn{
  579. width: 210rpx;
  580. height: 88rpx;
  581. background: #FFFFFF;
  582. box-shadow: 0rpx 4rpx 12rpx 4rpx #EDF4FF;
  583. border-radius: 16rpx;
  584. font-family: PingFangSC, PingFang SC;
  585. font-weight: 400;
  586. font-size: 28rpx;
  587. color: #1D2129;
  588. line-height: 88rpx;
  589. text-align: center;
  590. &.blue{
  591. background: #198CFF;
  592. color: #FFFFFF;
  593. }
  594. }
  595. image{
  596. width: 170rpx;
  597. height: 170rpx;
  598. }
  599. }
  600. .form{
  601. margin-top: 72rpx;
  602. .item{
  603. width: 100%;
  604. padding: 28rpx 30rpx;
  605. box-sizing: border-box;
  606. box-shadow: inset 0rpx -1rpx 0rpx 0rpx #EDF4FF;
  607. display: flex;
  608. align-items: center;
  609. justify-content: space-between;
  610. .left{
  611. font-family: PingFangSC, PingFang SC;
  612. font-weight: 400;
  613. font-size: 30rpx;
  614. color: #1D2129;
  615. line-height: 42rpx;
  616. letter-spacing: 2rpx;
  617. }
  618. .right{
  619. input{
  620. outline: none;
  621. border: none;
  622. font-family: PingFangSC, PingFang SC;
  623. font-weight: 400;
  624. font-size: 30rpx;
  625. color: #4E5969;
  626. line-height: 42rpx;
  627. text-align: right;
  628. }
  629. }
  630. }
  631. }
  632. .confirm{
  633. width: calc(100% - 48rpx);
  634. height: 88rpx;
  635. background: #198CFF;
  636. border-radius: 16rpx;
  637. margin: 234rpx 24rpx 0;
  638. font-family: PingFang-SC, PingFang-SC;
  639. font-weight: bold;
  640. font-size: 32rpx;
  641. color: #FFFFFF;
  642. line-height: 88rpx;
  643. text-align: center;
  644. letter-spacing: 2rpx;
  645. }
  646. }
  647. }
  648. </style>