airConditioning.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. <!-- 空调 -->
  2. <template>
  3. <view class="airConditioning">
  4. <view class="null-box" @click="backPage()"></view>
  5. <!-- 空调按钮 -->
  6. <view class="panel">
  7. <view class="panel-t">
  8. <view>{{infraredControllerForm.name}}</view>
  9. <view @click="switchFun()" :class="infraredControllerForm.switchType==1?'color-A':'color-B'">{{infraredControllerForm.switchType==1?'开启':'关闭'}}</view>
  10. </view>
  11. <view class="panel-m" v-if="infraredControllerForm.switchType == 1">
  12. <view @click="temperatureFun(item.value)" :class="infraredControllerForm.functionType==item.value?'color-C':''" v-for="(item,index) in infraredControllerData.functionList" :key="index">{{item.label}}</view>
  13. </view>
  14. <view class="panel-b" v-if="infraredControllerForm.switchType == 1 && infraredControllerForm.functionType != 3">
  15. <view @click="subtract">-</view>
  16. <view v-for="(item,index) in infraredControllerData.refrigerationList" :key="index" v-if="infraredControllerForm.functionType==1&&item.value == infraredControllerForm.orderType">{{item.value}}</view>
  17. <view v-for="(item,index) in infraredControllerData.heatingList" :key="index" v-if="infraredControllerForm.functionType==2&&item.value == infraredControllerForm.orderType">{{item.value}}</view>
  18. <view @click="add">+</view>
  19. </view>
  20. <view class="panel-button" @click="mangerControl">确定</view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import {
  26. iotAppHardwareOperatingHardware,
  27. } from '@/pages_manage/api/index.js'
  28. import { config } from '@/api/request/config.js'
  29. export default {
  30. name: "airConditioning",
  31. props: {
  32. airConditioningData: {},
  33. },
  34. data() {
  35. return {
  36. baseUrl:config.base_url,
  37. /****************** 红外控制器相关 ******************/
  38. infraredControllerType:false,
  39. infraredControllerTitle:"",
  40. infraredControllerForm:{
  41. name:null,//设备名称
  42. switchType:null,//0.关 1.开
  43. functionType:null, //1.制冷 2.制热 3.通风
  44. orderType:null, //温度指令
  45. hardwareNo:null, //设备编号
  46. },
  47. infraredControllerData:{
  48. functionList:[
  49. {label:'制冷',value:'1'},
  50. {label:'制热',value:'2'},
  51. {label:'通风',value:'3'},
  52. ],
  53. //制冷
  54. refrigerationList:[
  55. {label:"18°C",value:18},
  56. {label:"19°C",value:19},
  57. {label:"20°C",value:20},
  58. {label:"21°C",value:21},
  59. {label:"22°C",value:22},
  60. {label:"23°C",value:23},
  61. {label:"24°C",value:24},
  62. {label:"25°C",value:25},
  63. {label:"26°C",value:26},
  64. {label:"27°C",value:27},
  65. {label:"28°C",value:28},
  66. ],
  67. //制热
  68. heatingList:[
  69. {label:"22°C",value:22},
  70. {label:"23°C",value:23},
  71. {label:"24°C",value:24},
  72. {label:"25°C",value:25},
  73. {label:"26°C",value:26},
  74. {label:"27°C",value:27},
  75. {label:"28°C",value:28},
  76. {label:"29°C",value:29},
  77. {label:"30°C",value:30},
  78. ],
  79. }
  80. }
  81. },
  82. created() {
  83. },
  84. mounted() {
  85. if(this.airConditioningData.reservedThree == 0){
  86. this.$set(this,'infraredControllerForm',{
  87. name:this.airConditioningData.hardwareName,
  88. switchType:0,
  89. functionType:1,
  90. orderType:18,
  91. hardwareNo:this.airConditioningData.hardwareNo,
  92. });
  93. }else if(this.airConditioningData.reservedThree == 2){
  94. this.$set(this,'infraredControllerForm',{
  95. name:this.airConditioningData.hardwareName,
  96. switchType:1,
  97. functionType:3,
  98. orderType:18,
  99. hardwareNo:this.airConditioningData.hardwareNo,
  100. });
  101. }else if(this.airConditioningData.reservedThree.indexOf('-') != -1){
  102. let list = this.airConditioningData.reservedThree.split('-');
  103. this.$set(this,'infraredControllerForm',{
  104. name:this.airConditioningData.hardwareName,
  105. switchType:1,
  106. functionType:list[0]==3?1:(list[0]==4?2:''),
  107. orderType:list[1]?list[1]:'',
  108. hardwareNo:this.airConditioningData.hardwareNo,
  109. });
  110. }
  111. },
  112. methods: {
  113. // 返回按钮
  114. backPage(){
  115. // #ifdef WEB
  116. this.$parent.$parent.buttonClick('conditioningClose','');
  117. // #endif
  118. // #ifdef MP-WEIXIN
  119. this.$parent.buttonClick('conditioningClose','');
  120. // #endif
  121. },
  122. switchFun(){
  123. if(!this.infraredControllerForm.switchType){
  124. if (this.infraredControllerForm.functionType == 1){
  125. if(this.infraredControllerForm.orderType<18 || this.infraredControllerForm.orderType>28){
  126. this.$set(this.infraredControllerForm,'orderType',18);
  127. }
  128. } else if(this.infraredControllerForm.functionType == 2){
  129. if(this.infraredControllerForm.orderType<22 || this.infraredControllerForm.orderType>30){
  130. this.$set(this.infraredControllerForm,'orderType',22);
  131. }
  132. }else if(this.infraredControllerForm.functionType == 3){
  133. this.$set(this.infraredControllerForm,'orderType',18);
  134. }else{
  135. this.$set(this.infraredControllerForm,'functionType',1);
  136. this.$set(this.infraredControllerForm,'orderType',18);
  137. }
  138. }
  139. this.$set(this.infraredControllerForm,'switchType',!this.infraredControllerForm.switchType);
  140. },
  141. temperatureFun(value){
  142. if(this.infraredControllerForm.functionType != value){
  143. if (value == 1){
  144. if(this.infraredControllerForm.orderType<18 || this.infraredControllerForm.orderType>28){
  145. this.$set(this.infraredControllerForm,'orderType',18);
  146. }
  147. } else if(value == 2){
  148. if(this.infraredControllerForm.orderType<22 || this.infraredControllerForm.orderType>30){
  149. this.$set(this.infraredControllerForm,'orderType',22);
  150. }
  151. }
  152. this.$set(this.infraredControllerForm,'functionType',value);
  153. }
  154. },
  155. add() {
  156. if (this.infraredControllerForm.functionType == 1){
  157. if(this.infraredControllerForm.orderType<28){
  158. this.infraredControllerForm.orderType++
  159. }
  160. } else if(this.infraredControllerForm.functionType == 2){
  161. if(this.infraredControllerForm.orderType<30){
  162. this.infraredControllerForm.orderType++
  163. }
  164. }
  165. },
  166. subtract() {
  167. if (this.infraredControllerForm.functionType == 1){
  168. if(this.infraredControllerForm.orderType>18){
  169. this.infraredControllerForm.orderType--
  170. }
  171. } else if(this.infraredControllerForm.functionType == 2){
  172. if(this.infraredControllerForm.orderType>22){
  173. this.infraredControllerForm.orderType--
  174. }
  175. }
  176. },
  177. //设备开关
  178. async mangerControl() {
  179. let text = '';
  180. if(this.infraredControllerForm.switchType == 1){
  181. if(this.infraredControllerForm.functionType == 1){
  182. text = '3-' + this.infraredControllerForm.orderType;
  183. }else if(this.infraredControllerForm.functionType == 2){
  184. text = '4-' + this.infraredControllerForm.orderType;
  185. }else if(this.infraredControllerForm.functionType == 3){
  186. text = '2';
  187. }
  188. }else if(this.infraredControllerForm.switchType == 0){
  189. text = '0';
  190. }
  191. let switchData = {
  192. hardwareNo:this.infraredControllerForm.hardwareNo,
  193. command:text
  194. };
  195. const {
  196. data
  197. } = await iotAppHardwareOperatingHardware(switchData);
  198. if (data.code == 200) {
  199. uni.showToast({
  200. title: '操作成功',
  201. icon: "none",
  202. mask: true,
  203. duration: 2000
  204. });
  205. // #ifdef WEB
  206. this.$parent.$parent.getIotControlData();
  207. // #endif
  208. // #ifdef MP-WEIXIN
  209. this.$parent.getIotControlData();
  210. // #endif
  211. this.backPage();
  212. }
  213. },
  214. },
  215. }
  216. </script>
  217. <style lang="stylus" scoped>
  218. .airConditioning{
  219. height: 100%;
  220. width: 100%;
  221. position: fixed;
  222. top: 0;
  223. display: flex;
  224. flex-direction: column;
  225. z-index: 10;
  226. background: rgba(0, 0, 0, 0.2);
  227. .null-box {
  228. flex: 1;
  229. }
  230. /* 空调面板 */
  231. .panel{
  232. width: 710rpx;
  233. background: #FFFFFF;
  234. border-radius: 20rpx;
  235. padding:34rpx 30rpx 34rpx;
  236. box-sizing: border-box;
  237. position: absolute;
  238. top: 320rpx;
  239. left:20rpx;
  240. .panel-t{
  241. display: flex;
  242. justify-content: flex-start;
  243. align-items: center;
  244. >view:nth-of-type(1){
  245. font-family: PingFang SC;
  246. font-weight: 500;
  247. font-size: 32rpx;
  248. color: #333333;
  249. line-height: 30rpx;
  250. margin-right: 16rpx;
  251. }
  252. .color-A{
  253. width: 100rpx;
  254. height: 50rpx;
  255. font-family: PingFang SC;
  256. font-weight: 500;
  257. font-size: 30rpx;
  258. color: #FFFFFF;
  259. line-height: 50rpx;
  260. text-align: center;
  261. background: #0183FA;
  262. border-radius: 25rpx;
  263. }
  264. .color-B{
  265. width: 100rpx;
  266. height: 50rpx;
  267. font-family: PingFang SC;
  268. font-weight: 500;
  269. font-size: 30rpx;
  270. color: #666666;
  271. line-height: 50rpx;
  272. text-align: center;
  273. background: #E0E0E0;
  274. border-radius: 25rpx;
  275. }
  276. }
  277. .panel-m{
  278. display: flex;
  279. justify-content: space-between;
  280. align-items: center;
  281. margin-top: 48rpx;
  282. >view{
  283. width: 200rpx;
  284. height: 80rpx;
  285. border-radius: 10rpx;
  286. border: 1px solid #E0E0E0;
  287. font-family: PingFang SC;
  288. font-weight: 500;
  289. font-size: 32rpx;
  290. color: #333333;
  291. line-height: 80rpx;
  292. text-align: center;
  293. }
  294. .color-C{
  295. width: 200rpx;
  296. height: 80rpx;
  297. border-radius: 10rpx;
  298. border: 1px solid #E0E0E0;
  299. font-family: PingFang SC;
  300. font-weight: 500;
  301. font-size: 32rpx;
  302. color: #FFFFFF;
  303. line-height: 80rpx;
  304. text-align: center;
  305. background: #0183FA;
  306. }
  307. }
  308. .panel-b{
  309. display: flex;
  310. justify-content: space-between;
  311. align-items: center;
  312. width: 650rpx;
  313. height: 100rpx;
  314. border-radius: 10rpx;
  315. border: 1px solid #E0E0E0;
  316. margin-top: 40rpx;
  317. >view:nth-of-type(1){
  318. font-weight: 500;
  319. font-size: 32rpx;
  320. color: #333333;
  321. line-height: 100rpx;
  322. width: 120rpx;
  323. text-align: center;
  324. }
  325. >view:nth-of-type(2){
  326. font-weight: 500;
  327. font-size: 32rpx;
  328. color: #333333;
  329. line-height: 30rpx;
  330. }
  331. >view:nth-of-type(3){
  332. font-family: PingFang SC;
  333. font-weight: 500;
  334. font-size: 32rpx;
  335. color: #333333;
  336. line-height: 100rpx;
  337. width: 120rpx;
  338. text-align: center;
  339. }
  340. }
  341. .panel-button{
  342. text-align: center;
  343. line-height: 80rpx;
  344. font-size: 32rpx;
  345. background: #0183fa;
  346. border-radius: 10rpx;
  347. color: #fff;
  348. margin-top: 40rpx;
  349. }
  350. }
  351. }
  352. </style>