123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 |
- <!-- 空调 -->
- <template>
- <view class="airConditioning">
- <view class="null-box" @click="backPage()"></view>
- <!-- 空调按钮 -->
- <view class="panel">
- <view class="panel-t">
- <view>{{infraredControllerForm.name}}</view>
- <view @click="switchFun()" :class="infraredControllerForm.switchType==1?'color-A':'color-B'">{{infraredControllerForm.switchType==1?'开启':'关闭'}}</view>
- </view>
- <view class="panel-m" v-if="infraredControllerForm.switchType == 1">
- <view @click="temperatureFun(item.value)" :class="infraredControllerForm.functionType==item.value?'color-C':''" v-for="(item,index) in infraredControllerData.functionList" :key="index">{{item.label}}</view>
- </view>
- <view class="panel-b" v-if="infraredControllerForm.switchType == 1 && infraredControllerForm.functionType != 3">
- <view @click="subtract">-</view>
- <view v-for="(item,index) in infraredControllerData.orderList" :key="index" v-if="item.value == infraredControllerForm.orderType">{{item.value}}</view>
- <view @click="add">+</view>
- </view>
- <view class="panel-button" @click="mangerControl">确定</view>
- </view>
- </view>
- </template>
- <script>
- import {
- iotAppHardwareOperatingHardware,
- } from '@/pages_manage/api/index.js'
- import { config } from '@/api/request/config.js'
- export default {
- name: "airConditioning",
- props: {
- airConditioningData: {},
- },
- data() {
- return {
- baseUrl:config.base_url,
- /****************** 红外控制器相关 ******************/
- infraredControllerType:false,
- infraredControllerTitle:"",
- infraredControllerForm:{
- name:null,//设备名称
- switchType:null,//0.关 1.开
- functionType:null, //1.制冷 2.制热 3.通风
- orderType:null, //温度指令
- hardwareNo:null, //设备编号
- },
- infraredControllerData:{
- functionList:[
- {label:'制冷',value:'1'},
- {label:'制热',value:'2'},
- {label:'通风',value:'3'},
- ],
- orderList:[
- {label:"18°C",value:18},
- {label:"19°C",value:19},
- {label:"20°C",value:20},
- {label:"21°C",value:21},
- {label:"22°C",value:22},
- {label:"23°C",value:23},
- {label:"24°C",value:24},
- {label:"25°C",value:25},
- {label:"26°C",value:26},
- {label:"27°C",value:27},
- ],
- }
- }
- },
- created() {
- },
- mounted() {
- if(this.airConditioningData.reservedThree == 0){
- this.$set(this,'infraredControllerForm',{
- name:this.airConditioningData.hardwareName,
- switchType:0,
- functionType:1,
- orderType:18,
- hardwareNo:this.airConditioningData.hardwareNo,
- });
- }else if(this.airConditioningData.reservedThree == 2){
- this.$set(this,'infraredControllerForm',{
- name:this.airConditioningData.hardwareName,
- switchType:1,
- functionType:3,
- orderType:18,
- hardwareNo:this.airConditioningData.hardwareNo,
- });
- }else if(this.airConditioningData.reservedThree.indexOf('-') != -1){
- let list = this.airConditioningData.reservedThree.split('-');
- this.$set(this,'infraredControllerForm',{
- name:this.airConditioningData.hardwareName,
- switchType:1,
- functionType:list[0]==3?1:(list[0]==4?2:''),
- orderType:list[1]?list[1]:'',
- hardwareNo:this.airConditioningData.hardwareNo,
- });
- }
- },
- methods: {
- // 返回按钮
- backPage(){
- this.$parent.buttonClick('conditioningClose','');
- },
- switchFun(){
- if(this.infraredControllerForm.switchType==0){
- this.$set(this.infraredControllerForm, 'switchType',1);
- }else{
- this.$set(this.infraredControllerForm, 'switchType',0);
- }
- },
- temperatureFun(value){
- this.$set(this.infraredControllerForm, 'functionType',value);
- },
- add() {
- if(this.infraredControllerForm.orderType<27){
- this.infraredControllerForm.orderType++
- }
- },
- subtract() {
- if(this.infraredControllerForm.orderType>18){
- this.infraredControllerForm.orderType--
- }
- },
-
- //设备开关
- async mangerControl() {
- let text = '';
- if(this.infraredControllerForm.switchType == 1){
- if(this.infraredControllerForm.functionType == 1){
- text = '3-' + this.infraredControllerForm.orderType;
- }else if(this.infraredControllerForm.functionType == 2){
- text = '4-' + this.infraredControllerForm.orderType;
- }else if(this.infraredControllerForm.functionType == 3){
- text = '2';
- }
- }else if(this.infraredControllerForm.switchType == 0){
- text = '0';
- }
- let switchData = {
- hardwareNo:this.infraredControllerForm.hardwareNo,
- command:text
- };
- const {
- data
- } = await iotAppHardwareOperatingHardware(switchData);
- if (data.code == 200) {
- uni.showToast({
- title: '操作成功',
- icon: "none",
- mask: true,
- duration: 2000
- });
- this.$parent.getIotControlData();
- this.backPage();
- }
- },
-
- },
- }
- </script>
- <style lang="stylus" scoped>
- .airConditioning{
- height: 100%;
- width: 100%;
- position: fixed;
- top: 0;
- display: flex;
- flex-direction: column;
- z-index: 10;
- background: rgba(0, 0, 0, 0.2);
- .null-box {
- flex: 1;
- }
- /* 空调面板 */
- .panel{
- width: 710rpx;
- background: #FFFFFF;
- border-radius: 20rpx;
- padding:34rpx 30rpx 34rpx;
- box-sizing: border-box;
- position: absolute;
- top: 320rpx;
- left:20rpx;
- .panel-t{
- display: flex;
- justify-content: flex-start;
- align-items: center;
- >view:nth-of-type(1){
- font-family: PingFang SC;
- font-weight: 500;
- font-size: 32rpx;
- color: #333333;
- line-height: 30rpx;
- margin-right: 16rpx;
- }
- .color-A{
- width: 100rpx;
- height: 50rpx;
- font-family: PingFang SC;
- font-weight: 500;
- font-size: 30rpx;
- color: #FFFFFF;
- line-height: 50rpx;
- text-align: center;
- background: #0183FA;
- border-radius: 25rpx;
- }
- .color-B{
- width: 100rpx;
- height: 50rpx;
- font-family: PingFang SC;
- font-weight: 500;
- font-size: 30rpx;
- color: #666666;
- line-height: 50rpx;
- text-align: center;
- background: #E0E0E0;
- border-radius: 25rpx;
- }
- }
- .panel-m{
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-top: 48rpx;
- >view{
- width: 200rpx;
- height: 80rpx;
- border-radius: 10rpx;
- border: 1px solid #E0E0E0;
- font-family: PingFang SC;
- font-weight: 500;
- font-size: 32rpx;
- color: #333333;
- line-height: 80rpx;
- text-align: center;
- }
- .color-C{
- width: 200rpx;
- height: 80rpx;
- border-radius: 10rpx;
- border: 1px solid #E0E0E0;
- font-family: PingFang SC;
- font-weight: 500;
- font-size: 32rpx;
- color: #FFFFFF;
- line-height: 80rpx;
- text-align: center;
- background: #0183FA;
- }
- }
- .panel-b{
- display: flex;
- justify-content: space-between;
- align-items: center;
- width: 650rpx;
- height: 100rpx;
- border-radius: 10rpx;
- border: 1px solid #E0E0E0;
- margin-top: 40rpx;
- >view:nth-of-type(1){
- font-weight: 500;
- font-size: 32rpx;
- color: #333333;
- line-height: 100rpx;
- width: 120rpx;
- text-align: center;
- }
- >view:nth-of-type(2){
- font-weight: 500;
- font-size: 32rpx;
- color: #333333;
- line-height: 30rpx;
- }
- >view:nth-of-type(3){
- font-family: PingFang SC;
- font-weight: 500;
- font-size: 32rpx;
- color: #333333;
- line-height: 100rpx;
- width: 120rpx;
- text-align: center;
- }
- }
- .panel-button{
- text-align: center;
- line-height: 80rpx;
- font-size: 32rpx;
- background: #0183fa;
- border-radius: 10rpx;
- color: #fff;
- margin-top: 40rpx;
- }
- }
-
-
- }
- </style>
|