airConditioning.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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. this.$parent.buttonClick('conditioningClose','');
  116. },
  117. switchFun(){
  118. if(!this.infraredControllerForm.switchType){
  119. if (this.infraredControllerForm.functionType == 1){
  120. if(this.infraredControllerForm.orderType<18 || this.infraredControllerForm.orderType>28){
  121. this.$set(this.infraredControllerForm,'orderType',18);
  122. }
  123. } else if(this.infraredControllerForm.functionType == 2){
  124. if(this.infraredControllerForm.orderType<22 || this.infraredControllerForm.orderType>30){
  125. this.$set(this.infraredControllerForm,'orderType',22);
  126. }
  127. }else if(this.infraredControllerForm.functionType == 3){
  128. this.$set(this.infraredControllerForm,'orderType',18);
  129. }else{
  130. this.$set(this.infraredControllerForm,'functionType',1);
  131. this.$set(this.infraredControllerForm,'orderType',18);
  132. }
  133. }
  134. this.$set(this.infraredControllerForm,'switchType',!this.infraredControllerForm.switchType);
  135. },
  136. temperatureFun(value){
  137. if(this.infraredControllerForm.functionType != value){
  138. if (value == 1){
  139. if(this.infraredControllerForm.orderType<18 || this.infraredControllerForm.orderType>28){
  140. this.$set(this.infraredControllerForm,'orderType',18);
  141. }
  142. } else if(value == 2){
  143. if(this.infraredControllerForm.orderType<22 || this.infraredControllerForm.orderType>30){
  144. this.$set(this.infraredControllerForm,'orderType',22);
  145. }
  146. }
  147. this.$set(this.infraredControllerForm,'functionType',value);
  148. }
  149. },
  150. add() {
  151. if (this.infraredControllerForm.functionType == 1){
  152. if(this.infraredControllerForm.orderType<28){
  153. this.infraredControllerForm.orderType++
  154. }
  155. } else if(this.infraredControllerForm.functionType == 2){
  156. if(this.infraredControllerForm.orderType<30){
  157. this.infraredControllerForm.orderType++
  158. }
  159. }
  160. },
  161. subtract() {
  162. if (this.infraredControllerForm.functionType == 1){
  163. if(this.infraredControllerForm.orderType>18){
  164. this.infraredControllerForm.orderType--
  165. }
  166. } else if(this.infraredControllerForm.functionType == 2){
  167. if(this.infraredControllerForm.orderType>22){
  168. this.infraredControllerForm.orderType--
  169. }
  170. }
  171. },
  172. //设备开关
  173. async mangerControl() {
  174. let text = '';
  175. if(this.infraredControllerForm.switchType == 1){
  176. if(this.infraredControllerForm.functionType == 1){
  177. text = '3-' + this.infraredControllerForm.orderType;
  178. }else if(this.infraredControllerForm.functionType == 2){
  179. text = '4-' + this.infraredControllerForm.orderType;
  180. }else if(this.infraredControllerForm.functionType == 3){
  181. text = '2';
  182. }
  183. }else if(this.infraredControllerForm.switchType == 0){
  184. text = '0';
  185. }
  186. let switchData = {
  187. hardwareNo:this.infraredControllerForm.hardwareNo,
  188. command:text
  189. };
  190. const {
  191. data
  192. } = await iotAppHardwareOperatingHardware(switchData);
  193. if (data.code == 200) {
  194. uni.showToast({
  195. title: '操作成功',
  196. icon: "none",
  197. mask: true,
  198. duration: 2000
  199. });
  200. this.$parent.getIotControlData();
  201. this.backPage();
  202. }
  203. },
  204. },
  205. }
  206. </script>
  207. <style lang="stylus" scoped>
  208. .airConditioning{
  209. height: 100%;
  210. width: 100%;
  211. position: fixed;
  212. top: 0;
  213. display: flex;
  214. flex-direction: column;
  215. z-index: 10;
  216. background: rgba(0, 0, 0, 0.2);
  217. .null-box {
  218. flex: 1;
  219. }
  220. /* 空调面板 */
  221. .panel{
  222. width: 710rpx;
  223. background: #FFFFFF;
  224. border-radius: 20rpx;
  225. padding:34rpx 30rpx 34rpx;
  226. box-sizing: border-box;
  227. position: absolute;
  228. top: 320rpx;
  229. left:20rpx;
  230. .panel-t{
  231. display: flex;
  232. justify-content: flex-start;
  233. align-items: center;
  234. >view:nth-of-type(1){
  235. font-family: PingFang SC;
  236. font-weight: 500;
  237. font-size: 32rpx;
  238. color: #333333;
  239. line-height: 30rpx;
  240. margin-right: 16rpx;
  241. }
  242. .color-A{
  243. width: 100rpx;
  244. height: 50rpx;
  245. font-family: PingFang SC;
  246. font-weight: 500;
  247. font-size: 30rpx;
  248. color: #FFFFFF;
  249. line-height: 50rpx;
  250. text-align: center;
  251. background: #0183FA;
  252. border-radius: 25rpx;
  253. }
  254. .color-B{
  255. width: 100rpx;
  256. height: 50rpx;
  257. font-family: PingFang SC;
  258. font-weight: 500;
  259. font-size: 30rpx;
  260. color: #666666;
  261. line-height: 50rpx;
  262. text-align: center;
  263. background: #E0E0E0;
  264. border-radius: 25rpx;
  265. }
  266. }
  267. .panel-m{
  268. display: flex;
  269. justify-content: space-between;
  270. align-items: center;
  271. margin-top: 48rpx;
  272. >view{
  273. width: 200rpx;
  274. height: 80rpx;
  275. border-radius: 10rpx;
  276. border: 1px solid #E0E0E0;
  277. font-family: PingFang SC;
  278. font-weight: 500;
  279. font-size: 32rpx;
  280. color: #333333;
  281. line-height: 80rpx;
  282. text-align: center;
  283. }
  284. .color-C{
  285. width: 200rpx;
  286. height: 80rpx;
  287. border-radius: 10rpx;
  288. border: 1px solid #E0E0E0;
  289. font-family: PingFang SC;
  290. font-weight: 500;
  291. font-size: 32rpx;
  292. color: #FFFFFF;
  293. line-height: 80rpx;
  294. text-align: center;
  295. background: #0183FA;
  296. }
  297. }
  298. .panel-b{
  299. display: flex;
  300. justify-content: space-between;
  301. align-items: center;
  302. width: 650rpx;
  303. height: 100rpx;
  304. border-radius: 10rpx;
  305. border: 1px solid #E0E0E0;
  306. margin-top: 40rpx;
  307. >view:nth-of-type(1){
  308. font-weight: 500;
  309. font-size: 32rpx;
  310. color: #333333;
  311. line-height: 100rpx;
  312. width: 120rpx;
  313. text-align: center;
  314. }
  315. >view:nth-of-type(2){
  316. font-weight: 500;
  317. font-size: 32rpx;
  318. color: #333333;
  319. line-height: 30rpx;
  320. }
  321. >view:nth-of-type(3){
  322. font-family: PingFang SC;
  323. font-weight: 500;
  324. font-size: 32rpx;
  325. color: #333333;
  326. line-height: 100rpx;
  327. width: 120rpx;
  328. text-align: center;
  329. }
  330. }
  331. .panel-button{
  332. text-align: center;
  333. line-height: 80rpx;
  334. font-size: 32rpx;
  335. background: #0183fa;
  336. border-radius: 10rpx;
  337. color: #fff;
  338. margin-top: 40rpx;
  339. }
  340. }
  341. }
  342. </style>