| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452 |
- <template>
- <div class="volumn-box" :class="isOpen ? 'active' : ''">
- <div class="top">
- <img
- :src="
- parseImgUrl('taiguv1/envmonitor', isOpen ? 'active/air-con.svg' : 'air-con.svg')
- "
- alt=""
- />
- <div class="top-right">
- <Switch
- @change="getAirStatus"
- class="switch-btn"
- inactive-color="rgba(0, 0, 0, 0.3)"
- v-model="isOpen"
- />
- </div>
- </div>
- <div class="bottom">
- <div class="air-info">
- <div class="left">
- <div class="text">空调</div>
- <div class="status">{{ isOpen ? "已开启" : "已关闭" }}</div>
- </div>
- <div class="temp" v-if="isOpen">
- {{ realTemp }}
- <sup>℃</sup>
- </div>
- </div>
- <!--温度⏭️-->
- <div class="temp-box" id="sliderAirId" v-if="isOpen">
- <div class="bar">
- <div class="text text-left active-text">{{ airData.minTempSet }}</div>
- <div class="active-bar" :style="{ width: barWidth + 'px' }" id="barAirId">
- <div class="hand-box" id="handAirId">
- <div class="line"></div>
- </div>
- </div>
- <div class="text text-right" :class="isWhite ? 'active-text' : ''">
- {{ airData.maxTempSet }}
- </div>
- </div>
- </div>
- <!--风量调整-->
- <div class="air-volume" v-if="isOpen">
- <div class="volume-left">
- <div class="volume-top">
- <span>1</span>
- <span>2</span>
- <span>3</span>
- <span class="span-active">4</span>
- </div>
- <div class="text">风量调节</div>
- </div>
- <div class="volume-right">
- <div class="control-item">
- <img class="icon" :src="parseImgUrl('taiguv1/envmonitor', 'minus.svg')" />
- </div>
- <div class="control-item">
- <img class="icon" :src="parseImgUrl('taiguv1/envmonitor', 'plus.svg')" />
- </div>
- <div class="control-item">A</div>
- </div>
- </div>
- </div>
- </div>
- </template>
- <script>
- import {
- defineComponent,
- onMounted,
- reactive,
- toRefs,
- computed,
- nextTick,
- watch,
- onUnmounted,
- onBeforeMount,
- onBeforeUnmount,
- } from "vue";
- import { Switch, Dialog, Loading, Toast } from "vant";
- import { parseImgUrl, fix } from "@/utils";
- import { swiper } from "@/utils/swiper";
- export default defineComponent({
- components: {
- Switch,
- [Dialog.Component.name]: Dialog.Component,
- Loading,
- },
- setup(props, contx) {
- const proxyData = reactive({
- parseImgUrl: parseImgUrl,
- isOpen: false,
- airData: {
- minTempSet: 16,
- maxTempSet: 32,
- airTemp: 0,
- },
- part: 1,
- realTemp: 24,
- isWhite: false,
- barWidth: 73,
- getAirStatus() {
- if (proxyData.isOpen) {
- nextTick(() => {
- proxyData.endBoxSwiper();
- });
- }
- contx.emit("getStatus", proxyData.isOpen);
- },
- getEleWidth(ele) {
- // debugger;
- if (ele) {
- return ele.getBoundingClientRect().width;
- } else {
- return 1;
- }
- },
- endBoxSwiper() {
- let sliderBox = document.querySelector("#sliderAirId");
- let handBox = document.querySelector("#handAirId");
- let barBox = document.querySelector("#barAirId");
- let isMove = false;
- let sliderWidth = proxyData.getEleWidth(sliderBox);
- let startBarWidth = proxyData.getEleWidth(barBox);
- if (sliderWidth > 1) {
- sliderWidth = sliderWidth;
- }
- let tempPart =
- (proxyData.airData.maxTempSet - proxyData.airData.minTempSet) /
- (sliderWidth - 30);
- let part = tempPart;
- proxyData.part = tempPart;
- if (!handBox) {
- return;
- }
- handBox.addEventListener("touchstart", function (e) {
- let oldBarWidth = (barBox && barBox.style && barBox.style.width) || 0;
- startBarWidth = isNaN(parseInt(oldBarWidth)) ? 0 : parseInt(oldBarWidth);
- isMove = true;
- });
- handBox.addEventListener("touchend", function (e) {
- isMove = false;
- });
- swiper(handBox, {
- swipeLeft: function (e) {
- if (isMove) {
- let moveRealX = Math.abs(e.mation.moveX - e.mation.startX);
- let barWidth = startBarWidth - moveRealX;
- barWidth = barWidth < 30 ? 30 : barWidth;
- if (barWidth >= sliderWidth) {
- proxyData.isWhite = true;
- } else {
- proxyData.isWhite = false;
- }
- barBox.style.width = barWidth + "px";
- let realTemp = proxyData.airData.minTempSet + barWidth * part;
- if (realTemp > proxyData.airData.maxTempSet) {
- realTemp = proxyData.airData.maxTempSet;
- }
- if (realTemp) {
- proxyData.realTemp = fix(realTemp.toFixed(1));
- }
- }
- },
- swipeRight: function (e) {
- if (isMove) {
- let moveRealX = Math.abs(e.mation.moveX - e.mation.startX);
- let barWidth = startBarWidth + moveRealX;
- barWidth = barWidth > sliderWidth ? sliderWidth : barWidth;
- if (barWidth >= sliderWidth) {
- proxyData.isWhite = true;
- } else {
- proxyData.isWhite = false;
- }
- barBox.style.width = barWidth + "px";
- let realTemp = barWidth * part + proxyData.airData.minTempSet;
- if (realTemp > proxyData.airData.maxTempSet) {
- realTemp = proxyData.airData.maxTempSet;
- }
- if (realTemp) {
- proxyData.realTemp = fix(realTemp.toFixed(1));
- }
- }
- },
- });
- },
- });
- onBeforeUnmount(() => {});
- onMounted(() => {});
- return {
- ...toRefs(proxyData),
- };
- },
- });
- </script>
- <style lang="scss" scoped>
- .volumn-box {
- box-sizing: border-box;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- padding: 16px;
- width: 100%;
- height: 100%;
- border-radius: 24px 24px 44px 24px;
- background-color: rgba(255, 255, 255, 0.2);
- backdrop-filter: blur(40px);
- box-shadow: 0px 10px 20px 0px rgba(0, 20, 40, 0.1);
- .top {
- display: flex;
- justify-content: space-between;
- img {
- width: 30px;
- }
- }
- .bottom {
- width: 100%;
- // margin-top: 18vh;
- // margin-top: 109px;
- .air-info {
- display: flex;
- justify-content: space-between;
- align-items: end;
- .temp {
- //styleName: En/H2;
- width: 80px;
- text-align: right;
- font-family: Jost;
- font-size: 20px;
- font-weight: 300;
- line-height: 28px;
- color: rgba(0, 20, 40, 1);
- sup {
- //styleName: En/Body XS;
- font-family: Jost;
- font-size: 11px;
- font-weight: 400;
- line-height: 15px;
- color: rgba(0, 20, 40, 1);
- }
- }
- }
- .text {
- //styleName: Chi/Body Large;
- font-family: PingFang SC;
- font-size: 16px;
- font-weight: 300;
- line-height: 22px;
- letter-spacing: 0.02em;
- text-align: left;
- text-underline-position: from-font;
- text-decoration-skip-ink: none;
- color: rgba(255, 255, 255, 1);
- padding-bottom: 2px;
- }
- .status {
- //styleName: Chi/Body XS;
- font-family: PingFang SC;
- font-size: 11px;
- font-weight: 400;
- line-height: 15px;
- letter-spacing: 0.02em;
- color: rgba(255, 255, 255, 0.4);
- }
- .temp-box {
- position: relative;
- box-sizing: border-box;
- width: 100%;
- padding: 2px;
- margin-top: 8px;
- height: 34px;
- border-radius: 12px;
- background: rgba(255, 255, 255, 0.6);
- .text {
- position: absolute;
- top: 50%;
- transform: translateY(-50%);
- font-family: Jost;
- font-size: 11px;
- font-weight: 400;
- line-height: 15px;
- color: rgba(116, 128, 141, 1);
- z-index: 2;
- }
- .text-left {
- left: 8px;
- }
- .text-right {
- right: 8px;
- }
- .active-text {
- color: rgba(255, 255, 255, 0.6);
- }
- .active-bar {
- position: absolute;
- background: linear-gradient(95.5deg, #99282b 21.44%, #a95459 84.95%);
- left: 2px;
- top: 50%;
- transform: translateY(-50%);
- z-index: 1;
- // width: 73px;
- // min-width: 18px;
- height: 30px;
- border-radius: 10px;
- .hand-box {
- padding-left: 6px;
- padding-right: 6px;
- position: absolute;
- top: 50%;
- transform: translateY(-50%);
- right: 0px;
- height: 100%;
- }
- .line {
- margin-top: 9px;
- height: 12px;
- width: 2px;
- background: rgba(255, 255, 255, 0.8);
- }
- }
- }
- }
- .switch-btn {
- margin-top: 0;
- width: 50px !important;
- height: 28px !important;
- border: none;
- }
- }
- .active {
- background: rgba(255, 255, 255, 0.8);
- backdrop-filter: blur(40px);
- box-shadow: 0px 10px 20px 0px rgba(0, 20, 40, 0.1);
- .bottom {
- .text {
- color: rgba(0, 20, 40, 1);
- }
- .status {
- color: rgba(116, 128, 141, 1);
- }
- }
- }
- .air-volume {
- display: flex;
- margin-top: 12px;
- .volume-left {
- width: 69px;
- .volume-top {
- padding-bottom: 2px;
- height: 3.33vh;
- line-height: 1;
- span {
- //styleName: En/Body Small;
- display: inline-block;
- margin-right: 5px;
- font-family: Jost;
- font-size: 12px;
- font-weight: 400;
- line-height: 17px;
- color: rgba(116, 128, 141, 1);
- }
- .span-active {
- color: rgba(0, 20, 40, 1);
- font-size: 16px;
- line-height: 22px;
- }
- }
- .text {
- //styleName: Chi/Body XS;
- font-family: PingFang SC;
- font-size: 11px;
- font-weight: 400;
- line-height: 15px;
- letter-spacing: 0.02em;
- color: rgba(0, 20, 40, 1);
- }
- }
- .volume-right {
- width: 120px;
- display: flex;
- justify-content: space-between;
- .control-item {
- width: 36px;
- height: 36px;
- background: rgba(255, 255, 255, 0.4);
- backdrop-filter: blur(60px);
- border-radius: 50%;
- text-align: center;
- .icon {
- width: 20px;
- height: 20px;
- margin-top: 8px;
- }
- &:nth-child(3) {
- font-family: Jost;
- font-size: 16px;
- font-weight: 300;
- line-height: 36px;
- text-align: center;
- color: rgba(0, 20, 40, 1);
- }
- }
- }
- }
- </style>
- <style lang="scss">
- .volumn-box {
- .van-switch__node {
- background: rgba(255, 255, 255, 0.6);
- width: 24px;
- height: 24px;
- top: 0.33vh;
- // top: 50%;
- // transform: translateY(-50%);
- }
- .van-switch--on.switch-btn {
- .van-switch__node {
- transform: translate(calc(50px - 28px)) !important;
- }
- }
- .van-switch--on {
- background: linear-gradient(95.5deg, #99282b 21.44%, #a95459 84.95%) !important;
- .van-switch__node {
- background: #fff !important;
- }
- }
- .van-loading__spinner {
- color: $elActiveColor !important;
- }
- .van-switch__loading {
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- line-height: 1;
- }
- .van-switch--disabled {
- opacity: 0.5;
- }
- }
- </style>
|