Browse Source

新增设备控制卡片页面

dev_230517
zhangzhiyi 2 years ago
parent
commit
e39adcb1fc
  1. BIN
      src/assets/imgs/device-control/air_quality_cha@2x.png
  2. BIN
      src/assets/imgs/device-control/air_quality_liang@2x.png
  3. BIN
      src/assets/imgs/device-control/air_quality_you@2x.png
  4. BIN
      src/assets/imgs/device-control/power_on@2x.png
  5. BIN
      src/assets/imgs/device-control/shutdown@2x.png
  6. 287
      src/view/tabs/device-control.vue
  7. 14
      src/view/tabs/tabs.vue

BIN
src/assets/imgs/device-control/air_quality_cha@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 102 KiB

BIN
src/assets/imgs/device-control/air_quality_liang@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

BIN
src/assets/imgs/device-control/air_quality_you@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

BIN
src/assets/imgs/device-control/power_on@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

BIN
src/assets/imgs/device-control/shutdown@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

287
src/view/tabs/device-control.vue

@ -1,13 +1,294 @@ @@ -1,13 +1,294 @@
<template>
<div id="device-control-wrapper"></div>
<div id="device-control-wrapper">
<div class="title">
<div class="title-name">设备</div>
<div class="all-close-btn" @click="allShutDown()">一键全关</div>
</div>
<div class="container">
<div class="content">
<div
v-for="(item, index) in deviceList"
:key="index"
class="device-card"
:class="{
'air-quality-you': item.airQuality === '优',
'air-quality-liang': item.airQuality === '良',
'air-quality-cha': item.airQuality === '差',
}"
>
<div class="content-top">
<div class="device-name">{{ item.name }}</div>
<div v-if="item.self_clean !== 0" class="status-border" :class="{'need-clean-bg': item.self_clean === 1, 'cleaning-bg': item.self_clean === 2}">
<!-- 需清洁 -->
<span v-if="item.self_clean === 1" class="need-clean">需清洁</span>
<!-- 自清洁中 -->
<span v-if="item.self_clean === 2" class="cleaning">自清洁中</span>
</div>
</div>
<div class="content-btm">
<!-- 非空气盒子 -->
<div v-if="item.deviceType !== '02'" class="device-btm">
<div :class="!item.openFlg? 'shutdown': 'powerOn'">
<span
v-for="i in item.statusArr"
class="status"
:class="!item.openFlg? '': i === '偏热'? 'hot': i === '偏冷'? 'cold': ''">
{{ i }}
</span>
<span v-for="i in item.unitArr" class="unit">{{ i }}</span>
</div>
<div class="close-btn" @click="switchDevice(item)">
<img src="@/assets/imgs/device-control/power_on@2x.png" v-show="item.openFlg">
<img src="@/assets/imgs/device-control/shutdown@2x.png" v-show="!item.openFlg">
</div>
</div>
<!-- 空气盒子 -->
<div v-if="item.deviceType === '02'">
<div :class="!item.openFlg? 'shutdown': 'powerOn'" class="box-btm">
<div v-for="(j, i) in item.statusArr">
<span class="status">{{ j }}</span><span class="unit" style="margin-right: 8px;">{{ item.unitArr[i] }}</span>
</div>
<div class="air-quality">{{ item.airQuality }}</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script lang="ts" setup></script>
<script lang="ts" setup>
import { ref, onMounted } from 'vue';
const deviceList: any = ref<any[]>([]);
onMounted(() => {
deviceList.value = [
{
name: 'Q5全热',
openFlg: true,
deviceType: '4D',
self_clean: 0,
statusArr: ['34'],
unitArr: ['ug/m³']
}, {
name: '书房空调',
openFlg: false,
deviceType: '01',
self_clean: 1,
statusArr: ['24'],
unitArr: ['℃']
}, {
name: '厨房空调',
openFlg: true,
deviceType: '01',
self_clean: 2,
statusArr: ['偏热'],
unitArr: []
}, {
name: '主卧空调',
openFlg: true,
deviceType: '01',
self_clean: 0,
statusArr: ['偏冷'],
unitArr: []
}, {
name: '餐厅空调',
openFlg: true,
deviceType: '01',
self_clean: 0,
statusArr: ['24'],
unitArr: ['℃ 设定']
}, {
name: '客厅空气盒子',
openFlg: true,
deviceType: '02',
self_clean: 0,
statusArr: ['25', '68'],
unitArr: ['℃', '%'],
airQuality: '良'
}
]
})
/** 设备开关 */
const switchDevice = (item: any) => {
item.openFlg = !item.openFlg;
}
/** 一键全关 */
const allShutDown = () => {
deviceList.value.forEach((item: any) => {
if (item.deviceType !== '02') {
item.openFlg = false;
}
})
}
</script>
<style lang="scss" scoped>
#device-control-wrapper {
width: 100vw;
height: 100vh;
background: rgb(5, 154, 200);
background: #000;
display: flex;
flex-direction: column;
font-family: SourceHanSansCN-Regular, SourceHanSansCN;
.title {
width: 100%;
padding: 35px 0;
position: relative;
flex-shrink: 0;
.title-name {
text-align: center;
color: #FFF;
font-weight: 400;
font-size: 40px;
}
.all-close-btn {
color: #FFF;
font-size: 32px;
padding: 14px 18px;
background: #394457;
border-radius: 16px;
position: absolute;
top: 25px;
right: 24px;
}
}
.container {
flex: 1;
overflow: auto;
}
.content {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
padding: 0 24px;
.device-card {
width: 326px;
height: 146px;
box-sizing: border-box;
background: #20252E;
border-radius: 16px;
padding: 22px 24px 10px 24px;
margin-bottom: 20px;
.content-top {
display: flex;
align-items: center;
.device-name {
color: #FFF;
font-size: 24px;
margin-right: 10px;
padding: 6px 0;
}
.status-border {
font-size: 20px;
padding: 6px 10px;
border-radius: 16px;
span {
display: inline-block;
}
}
.need-clean-bg {
background: rgba($color: #FF8F4D, $alpha: 0.3);
color: #FF853D;
}
.cleaning-bg {
background: rgba($color: #4382FF, $alpha: 0.3);
color: #5991FF;
}
}
.content-btm {
margin-top: 18px;
font-family: Roboto-Light, Roboto;
//
.shutdown {
color: #999;
}
//
.powerOn {
color: #FFF;
}
.status {
font-size: 40px;
font-weight: 300;
margin-right: 4px;
}
.hot {
color: #FF8F4D;
}
.cold {
color: #507FDD;
}
.unit {
font-size: 18px;
font-weight: 400;
}
.air-quality {
font-size: 40px;
}
}
//
.device-btm {
display: flex;
justify-content: space-between;
.close-btn {
width: 60px;
height: 60px;
img {
width: 100%;
}
}
}
//
.box-btm {
display: flex;
justify-content: space-between;
align-items: flex-end;
}
}
.air-quality-you {
background: url('@/assets/imgs/device-control/air_quality_you@2x.png') no-repeat;
background-size: cover;
}
.air-quality-liang {
background: url('@/assets/imgs/device-control/air_quality_liang@2x.png') no-repeat;
background-size: cover;
}
.air-quality-cha {
background: url('@/assets/imgs/device-control/air_quality_cha@2x.png') no-repeat;
background-size: cover;
}
}
}
</style>

14
src/view/tabs/tabs.vue

@ -9,28 +9,29 @@ @@ -9,28 +9,29 @@
</div>
<DropDownMenu id="menu" v-show="showMenu" ref="menu" @pull-up="pullUp()"></DropDownMenu>
<div class="swiper">
<div class="swiper-wrapper">
<div class="swiper-wrapper" @touchstart.self>
<div class="swiper-slide">
<div class="swiper-item">
<FixedTime class="swiper-slide"></FixedTime>
<div><FixedTime></FixedTime></div>
</div>
</div>
<div class="swiper-slide">
<div class="swiper-item">
<HomeScreen class="swiper-slide"></HomeScreen>
<div><HomeScreen></HomeScreen></div>
</div>
</div>
<div class="swiper-slide">
<div class="swiper-item">
<DeviceControl class="swiper-slide"></DeviceControl>
<div><DeviceControl></DeviceControl></div>
</div>
</div>
<div class="swiper-slide">
<div class="swiper-item">
<Scene class="swiper-slide"></Scene>
<div><Scene></Scene></div>
</div>
</div>
</div>
<div class="swiper-pagination"></div>
</div>
</div>
</template>
@ -71,7 +72,9 @@ const initSwiper = () => { @@ -71,7 +72,9 @@ const initSwiper = () => {
pagination: {
el: ".swiper-pagination",
}, //
touchStartPreventDefault : false,
effect: "fade", //
resistanceRatio: 0,
});
}
@ -127,6 +130,7 @@ const pullUp = () => { @@ -127,6 +130,7 @@ const pullUp = () => {
width: 100vw;
height: 100vh;
position: relative;
-webkit-overflow-scrolling: touch;
.drop-down-menu {
width: 100vw;

Loading…
Cancel
Save