更新微信小程序

This commit is contained in:
Aladdin-Wang 2020-04-21 14:24:54 +08:00
parent 43543bec12
commit 8c216cea0e
2 changed files with 29 additions and 9 deletions

View File

@ -42,12 +42,32 @@ Page({
},
controlDeviceData:function(e){
console.log('提交的数据信息:',e.detail.value)
var rgb_red = 0;
var rgb_green = 0;
var rgb_blue = 0;
var len = e.detail.value.color.length;
for (var i=0;i<len;i++) {
if(e.detail.value.color[i] == "0")
{
rgb_red = 1;
}
if(e.detail.value.color[i] == "1")
{
rgb_green = 1;
}
if(e.detail.value.color[i] == "2")
{
rgb_blue = 1;
}
}
this.setData({
modelData: {
"method": "thing.event.property.post",
"id": "12345",
"params": {
"color": e.detail.value.color,
"rgb_red": rgb_red,
"rgb_green": rgb_green,
"rgb_blue": rgb_blue,
"airconditioners":e.detail.value.airconditioners_switch,
"windows":e.detail.value.windows_switch,
"temperatyre_threshold":e.detail.value.temperatyre_threshold,

View File

@ -38,13 +38,13 @@
<view class="cell">
<view>空调</view>
<view>
<switch name="airconditioners_switch" checked="{{deviceData.airconditioners_switch}}" />
<switch name="airconditioners_switch" />
</view>
</view>
<view class="cell">
<view>窗户</view>
<view>
<switch name="windows_switch" checked="{{deviceData.windows_switch}}" />
<switch name="windows_switch" />
</view>
</view>
<view class="cell">
@ -58,23 +58,23 @@
<view class="cell">
<view>氛围灯</view>
<view>
<radio-group name="color">
<label style="color:{{item.color}}" class="radio" wx:for="{{items}}" wx:key="unique" wx:for-index="idx">
<radio color="{{item.color}}" value="{{item.value}}" checked="{{idx == deviceData.color.Value}}" />{{item.name}}
<checkbox-group name="color">
<label style="color:{{item.color}}" class="checkbox" wx:for="{{items}}" wx:key="unique" wx:for-index="idx">
<checkbox color="{{item.color}}" value="{{item.value}}" />{{item.name}}
</label>
</radio-group>
</checkbox-group>
</view>
</view>
<view class="cell">
<view>温度阈值</view>
<view style="width:70%">
<slider name="temperatyre_threshold" min="0" max="100" value="{{deviceData.temperatyre.Value}}" show-value/>
<slider name="temperatyre_threshold" min="0" max="100" show-value/>
</view>
</view>
<view class="cell">
<view>湿度阈值</view>
<view style="width:70%">
<slider name="humidity_threshold" min="0" max="100" value="{{deviceData.humidity.Value}}" show-value/>
<slider name="humidity_threshold" min="0" max="100" show-value/>
</view>
</view>
</view>