|
|
|
@ -0,0 +1,68 @@
|
|
|
|
|
<template>
|
|
|
|
|
<div class="card" style="box-sizing:border-box;height:150px;margin:10px;">
|
|
|
|
|
<div class="card-header">
|
|
|
|
|
{{device.displayName}}
|
|
|
|
|
<span class="float-right text-success" v-if="device.isOnline"><i class="ion ion-ios-wifi"></i></span>
|
|
|
|
|
<span class="float-right text-danger" v-else><i class="ion ion-ios-wifi"></i></span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="card-body">
|
|
|
|
|
<div class="row" style="height:100%;width:300px;margin: 0 auto;">
|
|
|
|
|
<div class="col col-md-4 col-sm-4 align-self-center">
|
|
|
|
|
<div class="mh-100" :style="'width:48px;height:48px;background:'+hsl"></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col col-md-8 col-sm-8 align-self-center">
|
|
|
|
|
<div class="row" style="height:58px;">
|
|
|
|
|
<input v-on:change="changeHue($event.target.value)" type="range" min="0" step="1" max="255" name="hue" :value="hue" style="height:10px;-webkit-appearance:none;background: -webkit-linear-gradient(left, #F00 0%, #FF0 16.66%, #0F0 33.33%, #0FF 50%,#00F 66.66%, #F0F 83.33%, #F00 100%);" />
|
|
|
|
|
<input v-on:change="changeSaturation($event.target.value)" type="range" min="0" step="1" max="254" name="saturation" :value="saturation" :style="'height:10px;-webkit-appearance:none;background: -webkit-linear-gradient(left, #fff 0%, '+color+' 100%);'"/>
|
|
|
|
|
<input v-on:change="changeBrightness($event.target.value)" type="range" min="0" step="1" max="254" name="brightness" :value="brightness" style="height:10px;-webkit-appearance:none;background: -webkit-linear-gradient(left, #000 0%, #fff 100%);"/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<script>
|
|
|
|
|
({
|
|
|
|
|
props: ['device'],
|
|
|
|
|
methods: {
|
|
|
|
|
changeHue: function (hue) {
|
|
|
|
|
execApi(this.device.number, '/ColorLight/Change', 'hue=' + hue + '&saturation=' + this.saturation + '&brightness=' + this.brightness);
|
|
|
|
|
getData(this.device, '色调').value = hue;
|
|
|
|
|
},
|
|
|
|
|
changeSaturation: function (saturation) {
|
|
|
|
|
execApi(this.device.number, '/ColorLight/Change', 'hue=' + this.hue + '&saturation=' + saturation + '&brightness=' + this.brightness);
|
|
|
|
|
getData(this.device, '饱和度').value = saturation;
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
changeBrightness: function (brightness) {
|
|
|
|
|
execApi(this.device.number, '/ColorLight/Change', 'hue=' + this.hue + '&saturation=' + this.saturation + '&brightness=' + brightness);
|
|
|
|
|
getData(this.device, '亮度').value = brightness;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
hue: function () {
|
|
|
|
|
return getDeviceDataValue(this.device, '色调');
|
|
|
|
|
},
|
|
|
|
|
saturation: function () {
|
|
|
|
|
return getDeviceDataValue(this.device, '饱和度');
|
|
|
|
|
},
|
|
|
|
|
brightness: function () {
|
|
|
|
|
return getDeviceDataValue(this.device, '亮度');
|
|
|
|
|
},
|
|
|
|
|
color: function () {
|
|
|
|
|
var h = Math.round(parseInt(this.hue || 128) * 360 / 255);
|
|
|
|
|
var result = 'hsl(' + h + ',100%,50%)';
|
|
|
|
|
console.log('color:'+result);
|
|
|
|
|
return result;
|
|
|
|
|
},
|
|
|
|
|
hsl: function () {
|
|
|
|
|
var h = Math.round(parseInt(this.hue || 128) * 360 / 255);
|
|
|
|
|
var s = Math.round(parseInt(this.saturation || 128) * 100 / 254);
|
|
|
|
|
var l = Math.round(parseInt(this.brightness || 128) * 100 / 254);
|
|
|
|
|
var result = 'hsl(' + h + ',' + s + '%,' + l + '%);';
|
|
|
|
|
console.log('hsl:'+result);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
</script>
|