airConditioning.vue 7.8 KB

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