|
@@ -78,23 +78,28 @@ export default defineComponent({
|
|
|
timeTempNum: 1,
|
|
|
timeColor: timeColor,
|
|
|
timeColorNum: 1,
|
|
|
- getTimeNum(newTime:any=''){
|
|
|
- let time:any=((new Date()).getTime()-newTime)/1000
|
|
|
- let num:any=parseInt(time)
|
|
|
- if(num==1){
|
|
|
- return true
|
|
|
- }else {
|
|
|
- return false
|
|
|
- }
|
|
|
+ getTimeNum(newTime: any = "") {
|
|
|
+ let time: any = (new Date().getTime() - newTime) / 1000;
|
|
|
+ let num: any = parseInt(time);
|
|
|
+ if (num == 1) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
},
|
|
|
// 改变当前空间设置的值
|
|
|
- changContrlVal(type: any,tmerType:any=2) {
|
|
|
+ changContrlVal(type: any, tmerType: any = 2) {
|
|
|
let data: any = [];
|
|
|
if (type == 1) {
|
|
|
- if(proxyData.lightData.brightValue<proxyData.lightData.brightMinValue){
|
|
|
- proxyData.lightData.brightValue=proxyData.lightData.brightMinValue
|
|
|
+ if (
|
|
|
+ proxyData.lightData.brightValue < proxyData.lightData.brightMinValue
|
|
|
+ ) {
|
|
|
+ proxyData.lightData.brightValue =
|
|
|
+ proxyData.lightData.brightMinValue;
|
|
|
}
|
|
|
- proxyData.lightData.brightValue=Math.floor(proxyData.lightData.brightValue)
|
|
|
+ proxyData.lightData.brightValue = Math.floor(
|
|
|
+ proxyData.lightData.brightValue
|
|
|
+ );
|
|
|
data = [
|
|
|
{
|
|
|
id: proxyData.lightData.id,
|
|
@@ -102,20 +107,25 @@ export default defineComponent({
|
|
|
value: proxyData.lightData.brightValue,
|
|
|
},
|
|
|
];
|
|
|
- if(tmerType==2){
|
|
|
-
|
|
|
- if(proxyData.getTimeNum(proxyData.timeTemp)){
|
|
|
- proxyData.setSpaceContrl(data);
|
|
|
- proxyData.timeTemp=(new Date()).getTime()
|
|
|
- }
|
|
|
- }else {
|
|
|
+ if (tmerType == 2) {
|
|
|
+ if (proxyData.getTimeNum(proxyData.timeTemp)) {
|
|
|
+ proxyData.setSpaceContrl(data);
|
|
|
+ proxyData.timeTemp = new Date().getTime();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
proxyData.setSpaceContrl(data);
|
|
|
}
|
|
|
} else if (type == 2) {
|
|
|
- if(proxyData.lightData.colorTempValue<proxyData.lightData.colorTempMinValue){
|
|
|
- proxyData.lightData.colorTempValue=proxyData.lightData.colorTempMinValue
|
|
|
+ if (
|
|
|
+ proxyData.lightData.colorTempValue <
|
|
|
+ proxyData.lightData.colorTempMinValue
|
|
|
+ ) {
|
|
|
+ proxyData.lightData.colorTempValue =
|
|
|
+ proxyData.lightData.colorTempMinValue;
|
|
|
}
|
|
|
- proxyData.lightData.colorTempValue=Math.floor(proxyData.lightData.colorTempValue)
|
|
|
+ proxyData.lightData.colorTempValue = Math.floor(
|
|
|
+ proxyData.lightData.colorTempValue
|
|
|
+ );
|
|
|
data = [
|
|
|
{
|
|
|
id: proxyData.lightData.id,
|
|
@@ -123,31 +133,30 @@ export default defineComponent({
|
|
|
value: proxyData.lightData.colorTempValue,
|
|
|
},
|
|
|
];
|
|
|
- if(tmerType==2){
|
|
|
- if(proxyData.getTimeNum(proxyData.timeColor)){
|
|
|
- proxyData.setSpaceContrl(data);
|
|
|
- proxyData.timeColor=(new Date()).getTime()
|
|
|
- }
|
|
|
- }else {
|
|
|
+ if (tmerType == 2) {
|
|
|
+ if (proxyData.getTimeNum(proxyData.timeColor)) {
|
|
|
+ proxyData.setSpaceContrl(data);
|
|
|
+ proxyData.timeColor = new Date().getTime();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
proxyData.setSpaceContrl(data);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
},
|
|
|
// 控制结束处理
|
|
|
- changContrlValEnd(type:any){
|
|
|
- if(type==1){
|
|
|
- proxyData.changContrlVal(1,1)
|
|
|
- }else if(type==2){
|
|
|
- proxyData.changContrlVal(2,1)
|
|
|
+ changContrlValEnd(type: any) {
|
|
|
+ if (type == 1) {
|
|
|
+ proxyData.changContrlVal(1, 1);
|
|
|
+ } else if (type == 2) {
|
|
|
+ proxyData.changContrlVal(2, 1);
|
|
|
}
|
|
|
},
|
|
|
// 定时控制
|
|
|
setTimeContrl(type: any) {
|
|
|
if (type == 1) {
|
|
|
- proxyData.timeTemp=new Date().getTime()
|
|
|
+ proxyData.timeTemp = new Date().getTime();
|
|
|
} else if (type == 2) {
|
|
|
- proxyData.timeColor=new Date().getTime()
|
|
|
+ proxyData.timeColor = new Date().getTime();
|
|
|
}
|
|
|
},
|
|
|
// 设置调节滚动条的最大值和最小值
|
|
@@ -165,26 +174,28 @@ export default defineComponent({
|
|
|
proxyData.setLightDataMax();
|
|
|
if (type == 1) {
|
|
|
// 亮度
|
|
|
- let value:any=proxyData.lightData.brightMaxValue -proxyData.lightData.brightMinValue
|
|
|
- let bright: any =
|
|
|
- value / (sliderWidth - barWidth);
|
|
|
+ let value: any =
|
|
|
+ proxyData.lightData.brightMaxValue -
|
|
|
+ proxyData.lightData.brightMinValue;
|
|
|
+ let bright: any = value / (sliderWidth - barWidth);
|
|
|
let rate: any = 100 / value;
|
|
|
proxyData.lightData.brightValueRate = left * bright * rate;
|
|
|
proxyData.lightData.brightValueRate = Math.floor(
|
|
|
proxyData.lightData.brightValueRate
|
|
|
);
|
|
|
let width: any =
|
|
|
- proxyData.lightData.brightValueRate > 98
|
|
|
+ proxyData.lightData.brightValueRate >= 98
|
|
|
? 98
|
|
|
: proxyData.lightData.brightValueRate;
|
|
|
proxyData.lightData.brightValue =
|
|
|
proxyData.lightData.brightValueRate * rate;
|
|
|
- proxyData.itemWidth = width + "%";
|
|
|
+ proxyData.itemWidth = left + barWidth / 2 + "px";
|
|
|
} else if (type == 2) {
|
|
|
- let value:any=proxyData.lightData.colorTempMaxValue -proxyData.lightData.colorTempMinValue
|
|
|
+ let value: any =
|
|
|
+ proxyData.lightData.colorTempMaxValue -
|
|
|
+ proxyData.lightData.colorTempMinValue;
|
|
|
// 色温
|
|
|
- let colorVal: any =
|
|
|
- value / (sliderWidth - barWidth);
|
|
|
+ let colorVal: any = value / (sliderWidth - barWidth);
|
|
|
let rate: any = 100 / value;
|
|
|
proxyData.lightData.colorTempValueRate = left * colorVal * rate;
|
|
|
proxyData.lightData.colorTempValueRate = Math.floor(
|
|
@@ -200,7 +211,10 @@ export default defineComponent({
|
|
|
let left: any = "";
|
|
|
if (type == 1) {
|
|
|
proxyData.lightData.brightValue =
|
|
|
- proxyData.lightData.brightValue || 0;
|
|
|
+ proxyData.lightData.brightValue <=
|
|
|
+ proxyData.lightData.brightMinValue
|
|
|
+ ? 0
|
|
|
+ : proxyData.lightData.brightValue;
|
|
|
if (
|
|
|
proxyData.lightData.brightValue > proxyData.lightData.brightMaxValue
|
|
|
) {
|
|
@@ -215,14 +229,13 @@ export default defineComponent({
|
|
|
proxyData.lightData.brightValueRate = Math.floor(
|
|
|
proxyData.lightData.brightValue / rate
|
|
|
);
|
|
|
- let width: any =
|
|
|
- proxyData.lightData.brightValue / rate > 98
|
|
|
- ? 98
|
|
|
- : proxyData.lightData.brightValue / rate;
|
|
|
- proxyData.itemWidth = width + "%";
|
|
|
+ proxyData.itemWidth = left + barWidth / 2 + "px";
|
|
|
} else if (type == 2) {
|
|
|
proxyData.lightData.colorTempValue =
|
|
|
- proxyData.lightData.colorTempValue || 0;
|
|
|
+ proxyData.lightData.colorTempValue <=
|
|
|
+ proxyData.lightData.colorTempMinValue
|
|
|
+ ? 0
|
|
|
+ : proxyData.lightData.colorTempValue;
|
|
|
if (
|
|
|
proxyData.lightData.colorTempValue >
|
|
|
proxyData.lightData.colorTempMaxValue
|
|
@@ -248,10 +261,11 @@ export default defineComponent({
|
|
|
let isMove: any = false;
|
|
|
let barLeft: any = 0;
|
|
|
let sliderWidth: any = sliderBox ? sliderBox.offsetWidth : 1;
|
|
|
- let barWidth: any = handBox ? handBox.offsetWidth : 20;
|
|
|
+
|
|
|
if (!handBox) {
|
|
|
return;
|
|
|
}
|
|
|
+ let barWidth: any = handBox.getBoundingClientRect().width;
|
|
|
proxyData.getDefaultVal(1, sliderWidth, barWidth, handBox);
|
|
|
|
|
|
handBox.addEventListener("touchstart", function (e: any) {
|
|
@@ -259,11 +273,11 @@ export default defineComponent({
|
|
|
? 0
|
|
|
: parseInt(handBox.style.left);
|
|
|
isMove = true;
|
|
|
- proxyData.setTimeContrl(1)
|
|
|
+ proxyData.setTimeContrl(1);
|
|
|
});
|
|
|
handBox.addEventListener("touchend", function (e: any) {
|
|
|
isMove = false;
|
|
|
- proxyData.changContrlValEnd(1)
|
|
|
+ proxyData.changContrlValEnd(1);
|
|
|
});
|
|
|
|
|
|
swiper(handBox, {
|
|
@@ -276,7 +290,7 @@ export default defineComponent({
|
|
|
// debugger
|
|
|
handBox.style.left = left + "px";
|
|
|
proxyData.setBarValue(1, sliderWidth, left, barWidth);
|
|
|
- proxyData.changContrlVal(1)
|
|
|
+ proxyData.changContrlVal(1);
|
|
|
}
|
|
|
},
|
|
|
swipeRight: function (e: any) {
|
|
@@ -289,7 +303,7 @@ export default defineComponent({
|
|
|
left >= sliderWidth - barWidth ? sliderWidth - barWidth : left;
|
|
|
handBox.style.left = left + "px";
|
|
|
proxyData.setBarValue(1, sliderWidth, left, barWidth);
|
|
|
- proxyData.changContrlVal(1)
|
|
|
+ proxyData.changContrlVal(1);
|
|
|
}
|
|
|
},
|
|
|
});
|
|
@@ -302,21 +316,21 @@ export default defineComponent({
|
|
|
let isMove: any = false;
|
|
|
let barLeft: any = 0;
|
|
|
let sliderWidth: any = sliderBox ? sliderBox.offsetWidth : 1;
|
|
|
- let barWidth: any = handBox ? handBox.offsetWidth : 20;
|
|
|
if (!handBox) {
|
|
|
return;
|
|
|
}
|
|
|
+ let barWidth: any = handBox.getBoundingClientRect().width;
|
|
|
proxyData.getDefaultVal(2, sliderWidth, barWidth, handBox);
|
|
|
handBox.addEventListener("touchstart", function (e: any) {
|
|
|
barLeft = isNaN(parseInt(handBox.style.left))
|
|
|
? 0
|
|
|
: parseInt(handBox.style.left);
|
|
|
isMove = true;
|
|
|
- proxyData.setTimeContrl(2)
|
|
|
+ proxyData.setTimeContrl(2);
|
|
|
});
|
|
|
handBox.addEventListener("touchend", function (e: any) {
|
|
|
isMove = false;
|
|
|
- proxyData.changContrlValEnd(2)
|
|
|
+ proxyData.changContrlValEnd(2);
|
|
|
});
|
|
|
|
|
|
swiper(handBox, {
|
|
@@ -329,7 +343,7 @@ export default defineComponent({
|
|
|
// debugger
|
|
|
handBox.style.left = left + "px";
|
|
|
proxyData.setBarValue(2, sliderWidth, left, barWidth);
|
|
|
- proxyData.changContrlVal(2)
|
|
|
+ proxyData.changContrlVal(2);
|
|
|
}
|
|
|
},
|
|
|
swipeRight: function (e: any) {
|
|
@@ -342,7 +356,7 @@ export default defineComponent({
|
|
|
left >= sliderWidth - barWidth ? sliderWidth - barWidth : left;
|
|
|
handBox.style.left = left + "px";
|
|
|
proxyData.setBarValue(2, sliderWidth, left, barWidth);
|
|
|
- proxyData.changContrlVal(2)
|
|
|
+ proxyData.changContrlVal(2);
|
|
|
}
|
|
|
},
|
|
|
});
|
|
@@ -421,6 +435,7 @@ export default defineComponent({
|
|
|
bottom: -2px;
|
|
|
z-index: 333;
|
|
|
border-radius: 50%;
|
|
|
+ border: 2px solid #fff;
|
|
|
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.06),
|
|
|
0px 0px 8px rgba(0, 0, 0, 0.1);
|
|
|
}
|