airConditioning.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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" >
  12. <view @click="temperatureFun(index)" :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">
  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. this.$set(this,'infraredControllerForm',{
  71. name:this.airConditioningData.hardwareName,
  72. switchType:parseInt(this.airConditioningData.switchType),
  73. functionType:this.airConditioningData.switchType == 0 ? 1 : parseInt(this.airConditioningData.functionType),
  74. orderType:this.airConditioningData.switchType == 1 && this.airConditioningData.functionType !=3 ? parseInt(this.airConditioningData.orderType):18,
  75. hardwareNo:this.airConditioningData.hardwareNo,
  76. });
  77. },
  78. methods: {
  79. // 返回按钮
  80. backPage(){
  81. this.$parent.buttonClick('conditioningClose','');
  82. },
  83. switchFun(){
  84. if(this.switchStatus==0){
  85. this.$set(this, 'switchStatus',1);
  86. }else{
  87. this.$set(this, 'switchStatus',0);
  88. }
  89. },
  90. temperatureFun(index){
  91. this.$set(this, 'keystrokeIndex',index);
  92. },
  93. add() {
  94. if(this.infraredControllerForm.orderType<27){
  95. this.infraredControllerForm.orderType++
  96. }
  97. },
  98. subtract() {
  99. if(this.infraredControllerForm.orderType>18){
  100. this.infraredControllerForm.orderType--
  101. }
  102. },
  103. //设备开关
  104. async mangerControl() {
  105. let text = '';
  106. if(this.infraredControllerForm.switchType == 1){
  107. if(this.infraredControllerForm.functionType != 3){
  108. text = '1-' + this.infraredControllerForm.functionType + '-' + this.infraredControllerForm.orderType;
  109. }else {
  110. text = '1-3';
  111. }
  112. }else if(this.infraredControllerForm.switchType == 0){
  113. text = '0';
  114. }
  115. let switchData = {
  116. hardwareNo:this.infraredControllerForm.hardwareNo,
  117. command:text
  118. };
  119. const {
  120. data
  121. } = await iotAppHardwareOperatingHardware(switchData);
  122. if (data.code == 200) {
  123. uni.showToast({
  124. title: '操作成功',
  125. icon: "none",
  126. mask: true,
  127. duration: 2000
  128. });
  129. this.backPage();
  130. }
  131. },
  132. },
  133. }
  134. </script>
  135. <style lang="stylus" scoped>
  136. .airConditioning{
  137. height: 100%;
  138. width: 100%;
  139. position: fixed;
  140. top: 0;
  141. display: flex;
  142. flex-direction: column;
  143. z-index: 10;
  144. background: rgba(0, 0, 0, 0.2);
  145. .null-box {
  146. flex: 1;
  147. }
  148. /* 空调面板 */
  149. .panel{
  150. width: 710rpx;
  151. height: 530rpx;
  152. background: #FFFFFF;
  153. border-radius: 20rpx;
  154. padding:34rpx 30rpx 0rpx;
  155. box-sizing: border-box;
  156. position: absolute;
  157. top: 320rpx;
  158. left:20rpx;
  159. .panel-t{
  160. display: flex;
  161. justify-content: flex-start;
  162. align-items: center;
  163. >view:nth-of-type(1){
  164. font-family: PingFang SC;
  165. font-weight: 500;
  166. font-size: 32rpx;
  167. color: #333333;
  168. line-height: 30rpx;
  169. margin-right: 16rpx;
  170. }
  171. .color-A{
  172. width: 100rpx;
  173. height: 50rpx;
  174. font-family: PingFang SC;
  175. font-weight: 500;
  176. font-size: 30rpx;
  177. color: #FFFFFF;
  178. line-height: 50rpx;
  179. text-align: center;
  180. background: #0183FA;
  181. border-radius: 25rpx;
  182. }
  183. .color-B{
  184. width: 100rpx;
  185. height: 50rpx;
  186. font-family: PingFang SC;
  187. font-weight: 500;
  188. font-size: 30rpx;
  189. color: #666666;
  190. line-height: 50rpx;
  191. text-align: center;
  192. background: #E0E0E0;
  193. border-radius: 25rpx;
  194. }
  195. }
  196. .panel-m{
  197. display: flex;
  198. justify-content: space-between;
  199. align-items: center;
  200. margin-top: 48rpx;
  201. >view{
  202. width: 200rpx;
  203. height: 80rpx;
  204. border-radius: 10rpx;
  205. border: 1px solid #E0E0E0;
  206. font-family: PingFang SC;
  207. font-weight: 500;
  208. font-size: 32rpx;
  209. color: #333333;
  210. line-height: 80rpx;
  211. text-align: center;
  212. }
  213. .color-C{
  214. width: 200rpx;
  215. height: 80rpx;
  216. border-radius: 10rpx;
  217. border: 1px solid #E0E0E0;
  218. font-family: PingFang SC;
  219. font-weight: 500;
  220. font-size: 32rpx;
  221. color: #FFFFFF;
  222. line-height: 80rpx;
  223. text-align: center;
  224. background: #0183FA;
  225. }
  226. }
  227. .panel-b{
  228. display: flex;
  229. justify-content: space-between;
  230. align-items: center;
  231. width: 650rpx;
  232. height: 100rpx;
  233. border-radius: 10rpx;
  234. border: 1px solid #E0E0E0;
  235. margin-top: 40rpx;
  236. >view:nth-of-type(1){
  237. font-weight: 500;
  238. font-size: 32rpx;
  239. color: #333333;
  240. line-height: 100rpx;
  241. width: 120rpx;
  242. text-align: center;
  243. }
  244. >view:nth-of-type(2){
  245. font-weight: 500;
  246. font-size: 32rpx;
  247. color: #333333;
  248. line-height: 30rpx;
  249. }
  250. >view:nth-of-type(3){
  251. font-family: PingFang SC;
  252. font-weight: 500;
  253. font-size: 32rpx;
  254. color: #333333;
  255. line-height: 100rpx;
  256. width: 120rpx;
  257. text-align: center;
  258. }
  259. }
  260. .panel-button{
  261. text-align: center;
  262. line-height: 80rpx;
  263. font-size: 32rpx;
  264. background: #0183fa;
  265. border-radius: 10rpx;
  266. color: #fff;
  267. margin-top: 40rpx;
  268. }
  269. }
  270. }
  271. </style>