mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-17 16:36:03 +08:00
添加控制功能和页面逻辑
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
{
|
||||
"pages": [
|
||||
"pages/index/index",
|
||||
"pages/login/index",
|
||||
"pages/roomSystem/index"
|
||||
"pages/index/index",
|
||||
"pages/roomSystem/index",
|
||||
"pages/my/index"
|
||||
],
|
||||
"window": {
|
||||
"backgroundColor": "#F6F6F6",
|
||||
@@ -11,6 +12,20 @@
|
||||
"navigationBarTitleText": "智慧宿舍",
|
||||
"navigationBarTextStyle": "black"
|
||||
},
|
||||
"tabBar": {
|
||||
"list": [{
|
||||
"pagePath": "pages/index/index",
|
||||
"text": "首页",
|
||||
"iconPath": "icons/home.png",
|
||||
"selectedIconPath": "icons/home_selected.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/my/index",
|
||||
"text": "我的",
|
||||
"iconPath": "icons/user.png",
|
||||
"selectedIconPath": "icons/user_selected.png"
|
||||
}]
|
||||
},
|
||||
"sitemapLocation": "sitemap.json",
|
||||
"permission": {
|
||||
"scope.userLocation": {
|
||||
|
||||
BIN
wechat/miniprogram/images/door.png
Normal file
BIN
wechat/miniprogram/images/door.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
BIN
wechat/miniprogram/images/light.png
Normal file
BIN
wechat/miniprogram/images/light.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.5 KiB |
@@ -42,7 +42,16 @@ Page({
|
||||
username: this.data.username
|
||||
},
|
||||
})
|
||||
if (res.data.code !== 200) {
|
||||
wx.showToast({
|
||||
title: '登录失败',
|
||||
});
|
||||
return;
|
||||
}
|
||||
wx.setStorageSync('token', res.data.token);
|
||||
wx.switchTab({
|
||||
url: '/pages/index/index',
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"van-field": "@vant/weapp/field/index"
|
||||
"van-field": "@vant/weapp/field/index",
|
||||
"van-button": "@vant/weapp/button/index"
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
<!--miniprogram/pages/index/index.wxml-->
|
||||
<view class="title">欢迎登录智慧宿舍系统</view>
|
||||
<view class="form">
|
||||
<view class="input">
|
||||
<van-field
|
||||
@@ -14,6 +15,7 @@
|
||||
value="{{ password }}"
|
||||
placeholder="请输入密码"
|
||||
bind:change="inputPassword"
|
||||
type='password'
|
||||
label='密码'
|
||||
title-width='100rpx'
|
||||
right-icon=''
|
||||
@@ -34,8 +36,9 @@
|
||||
<image src='data:image/gif;base64,{{ img }}' />
|
||||
</view>
|
||||
</view>
|
||||
<view class="btn">
|
||||
<van-button block bind:click="submit" round type="info">登录</van-button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<button bindtap="submit">提交</button>
|
||||
<button bindtap="query">查询</button>
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
/* miniprogram/pages/index/index.wxss */
|
||||
.title{
|
||||
display: block;
|
||||
width: 80vw;
|
||||
margin: 60rpx auto;
|
||||
font-size: 40rpx;
|
||||
margin-top: 35%;
|
||||
}
|
||||
.form{
|
||||
width: 90vw;
|
||||
width: 80vw;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.input{
|
||||
@@ -31,3 +38,7 @@
|
||||
display: inline-block;
|
||||
height: 77rpx;
|
||||
}
|
||||
.btn{
|
||||
margin: 45rpx auto;
|
||||
width: 40vw;
|
||||
}
|
||||
19
wechat/miniprogram/pages/my/index.js
Normal file
19
wechat/miniprogram/pages/my/index.js
Normal file
@@ -0,0 +1,19 @@
|
||||
var app = getApp();
|
||||
|
||||
Page({
|
||||
data: {
|
||||
userInfo: {},
|
||||
mode: ['信息反馈', '联系客服', '关于我们']
|
||||
},
|
||||
onLoad: function () {
|
||||
},
|
||||
getOut(){
|
||||
wx.clearStorage({
|
||||
success: (res) => {
|
||||
wx.reLaunch({
|
||||
url: '/pages/login/index',
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
})
|
||||
3
wechat/miniprogram/pages/my/index.json
Normal file
3
wechat/miniprogram/pages/my/index.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
||||
16
wechat/miniprogram/pages/my/index.wxml
Normal file
16
wechat/miniprogram/pages/my/index.wxml
Normal file
@@ -0,0 +1,16 @@
|
||||
<!--miniprogram/pages/my/index.wxml-->
|
||||
<view class="personal_info">
|
||||
<view class="photo_wrap">
|
||||
<open-data type="userAvatarUrl"></open-data>
|
||||
</view>
|
||||
<view class="nickname">
|
||||
<open-data type="userNickName"></open-data>
|
||||
</view>
|
||||
</view>
|
||||
<view class="wode_item_wrap">
|
||||
<view class="wode_item" wx:for="{{mode}}">
|
||||
{{item}}
|
||||
<span class="arrow_wrap"></span>
|
||||
</view>
|
||||
</view>
|
||||
<view class="wode_out" bindtap="getOut">退出</view>
|
||||
54
wechat/miniprogram/pages/my/index.wxss
Normal file
54
wechat/miniprogram/pages/my/index.wxss
Normal file
@@ -0,0 +1,54 @@
|
||||
.personal_info {
|
||||
padding: 20px 0;
|
||||
background-color: #FFF;
|
||||
}
|
||||
.photo_wrap {
|
||||
overflow:hidden;
|
||||
display: block;
|
||||
width: 160rpx;
|
||||
height: 160rpx;
|
||||
margin: auto;
|
||||
margin-top: 50rpx;
|
||||
border-radius: 50%;
|
||||
border: 2px solid #fff;
|
||||
box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
.photo {
|
||||
width: 90px;
|
||||
height: 90px;
|
||||
border-radius: 90px;
|
||||
}
|
||||
.nickname {
|
||||
margin-top: 15px;
|
||||
text-align: center;
|
||||
color: #696969;
|
||||
}
|
||||
.wode_item_wrap {
|
||||
background-color: #FFF;
|
||||
font-size: 14px;
|
||||
margin-top: 10px;
|
||||
border-top: 1px solid #E5E5E5;
|
||||
}
|
||||
.wode_item {
|
||||
height: 45px;
|
||||
border-bottom: 1px solid #E5E5E5;
|
||||
padding: 0 10px;
|
||||
line-height: 45px;
|
||||
position: relative;
|
||||
}
|
||||
.arrow_wrap {
|
||||
position: absolute;
|
||||
width: 50px;
|
||||
height: 45px;
|
||||
right: 0;
|
||||
top: 0;
|
||||
}
|
||||
.wode_out {
|
||||
height: 45px;
|
||||
line-height: 45px;
|
||||
text-align: center;
|
||||
background-color: #FFF;
|
||||
margin-top: 10px;
|
||||
border-bottom: 1px solid #E5E5E5;
|
||||
border-top: 1px solid #E5E5E5;
|
||||
}
|
||||
@@ -16,9 +16,12 @@ Page({
|
||||
curtainAutoChecked:true,
|
||||
curtainManvalChecked:false,
|
||||
curtainPowerChecked:false,
|
||||
fanAutoChecked:true,
|
||||
fanManvalChecked:false,
|
||||
fanPowerChecked:false,
|
||||
fanShow:false,
|
||||
tempShow:false,
|
||||
realMaxTempValue:50,
|
||||
realMaxTempValue:'',
|
||||
maxTempValue:0,
|
||||
currentValue:0,
|
||||
deviceInfo:{},
|
||||
@@ -32,11 +35,6 @@ Page({
|
||||
wx.setNavigationBarTitle({
|
||||
title: '智能宿舍系统',
|
||||
})
|
||||
this.setData({
|
||||
currentValue:this.data.realMaxTempValue,
|
||||
maxTempValue:this.data.realMaxTempValue
|
||||
});
|
||||
|
||||
this.getLastPageData();
|
||||
this.query();
|
||||
},
|
||||
@@ -46,14 +44,24 @@ Page({
|
||||
async query(){
|
||||
const res = await requestApi(`/system/status/newByNum/${this.data.deviceInfo.deviceNum}`,{ method:'GET' });
|
||||
let light_power;
|
||||
let relayStatus;
|
||||
if (res.data.data.lightStatus === 0) {
|
||||
light_power = false;
|
||||
}else if (res.data.data.lightStatus === 1) {
|
||||
light_power =true;
|
||||
}
|
||||
if (res.data.data.relayStatus === 0) {
|
||||
relayStatus = false;
|
||||
}else if (res.data.data.relayStatus === 1) {
|
||||
relayStatus = true;
|
||||
}
|
||||
this.setData({
|
||||
nowDeviceData:res.data.data,
|
||||
light_power
|
||||
light_power,
|
||||
curtainPowerChecked:relayStatus,
|
||||
currentValue:res.data.data.airTemperature,
|
||||
maxTempValue:res.data.data.airTemperature,
|
||||
realMaxTempValue: res.data.data.airTemperature
|
||||
})
|
||||
},
|
||||
|
||||
@@ -69,29 +77,11 @@ Page({
|
||||
|
||||
|
||||
initParams(){
|
||||
// const params = {
|
||||
// deviceNum: this.data.deviceInfo.deviceNum,
|
||||
// relayStatus: this.data.nowDeviceData.relayStatus,
|
||||
// lightStatus: this.data.nowDeviceData.lightStatus,
|
||||
// isOnline: this.data.nowDeviceData.isOnline,
|
||||
// rssi: this.data.nowDeviceData.rssi,
|
||||
// deviceTemperature: this.data.nowDeviceData.deviceTemperature,
|
||||
// airTemperature: this.data.nowDeviceData.airTemperature,
|
||||
// airHumidity: this.data.nowDeviceData.airHumidity,
|
||||
// triggerSource: this.data.nowDeviceData.triggerSource,
|
||||
// brightness: this.data.nowDeviceData.brightness,
|
||||
// lightInterval: this.data.nowDeviceData.lightInterval,
|
||||
// lightMode: this.data.nowDeviceData.lightMode,
|
||||
// fadeTime: this.data.nowDeviceData.fadeTime,
|
||||
// red: this.data.nowDeviceData.red,
|
||||
// green: this.data.nowDeviceData.green,
|
||||
// blue: this.data.nowDeviceData.blue,
|
||||
// other:this.data.nowDeviceData.other
|
||||
// };
|
||||
const params = this.data.nowDeviceData;
|
||||
return params;
|
||||
},
|
||||
|
||||
//灯开关
|
||||
async lightPower(){
|
||||
let light_power = this.data.light_power;
|
||||
let lightStatus;
|
||||
@@ -137,10 +127,77 @@ Page({
|
||||
curtainManvalChecked:curtainManvalChecked
|
||||
})
|
||||
},
|
||||
onChangeCurtainPower(){
|
||||
let curtainPowerChecked = this.data.curtainPowerChecked;
|
||||
if (this.data.curtainManvalChecked) {
|
||||
this.setData({ curtainPowerChecked:!curtainPowerChecked })
|
||||
|
||||
//窗帘开关
|
||||
async onChangeCurtainPower(){
|
||||
// let curtainPowerChecked = this.data.curtainPowerChecked;
|
||||
// let relayStatus;
|
||||
// if (curtainPowerChecked === false) {
|
||||
// relayStatus = 1;
|
||||
// }else if (curtainPowerChecked === true) {
|
||||
// relayStatus = 0;
|
||||
// }
|
||||
// if (this.data.curtainManvalChecked) {
|
||||
// let params = this.initParams();
|
||||
// params.relayStatus = relayStatus;
|
||||
// const res = await requestApi(`/system/status`,{
|
||||
// method:'PUT',
|
||||
// data:params
|
||||
// });
|
||||
// console.log('窗帘:',res);
|
||||
// if (res.data.code !== 200) {
|
||||
// wx.showToast({
|
||||
// title: '操作失败',
|
||||
// icon:'error'
|
||||
// })
|
||||
// return;
|
||||
// }
|
||||
// this.setData({ curtainPowerChecked:!curtainPowerChecked })
|
||||
// }
|
||||
},
|
||||
|
||||
|
||||
|
||||
onAutoFanMode(){
|
||||
let fanAutoChecked = !this.data.fanAutoChecked;
|
||||
this.setData({
|
||||
fanAutoChecked:fanAutoChecked,
|
||||
fanManvalChecked:!fanAutoChecked
|
||||
})
|
||||
},
|
||||
onManvalFanMode(){
|
||||
let fanManvalChecked = !this.data.fanManvalChecked;
|
||||
this.setData({
|
||||
fanAutoChecked:!fanManvalChecked,
|
||||
fanManvalChecked:fanManvalChecked
|
||||
})
|
||||
},
|
||||
|
||||
//风扇开关
|
||||
async onChangeFanPower(){
|
||||
let fanPowerChecked = this.data.fanPowerChecked;
|
||||
let relayStatus;
|
||||
if (fanPowerChecked === false) {
|
||||
relayStatus = 1;
|
||||
}else if (fanPowerChecked === true) {
|
||||
relayStatus = 0;
|
||||
}
|
||||
if (this.data.fanManvalChecked) {
|
||||
let params = this.initParams();
|
||||
params.relayStatus = relayStatus;
|
||||
const res = await requestApi(`/system/status`,{
|
||||
method:'PUT',
|
||||
data:params
|
||||
});
|
||||
console.log('窗帘:',res);
|
||||
if (res.data.code !== 200) {
|
||||
wx.showToast({
|
||||
title: '操作失败',
|
||||
icon:'error'
|
||||
})
|
||||
return;
|
||||
}
|
||||
this.setData({ fanPowerChecked:!fanPowerChecked })
|
||||
}
|
||||
},
|
||||
|
||||
@@ -155,6 +212,7 @@ Page({
|
||||
})
|
||||
},
|
||||
onChangeValue(e){
|
||||
|
||||
this.setData({ maxTempValue:e.detail,currentValue:e.detail })
|
||||
},
|
||||
onDrag(e){
|
||||
@@ -167,7 +225,20 @@ Page({
|
||||
tempShow:false
|
||||
})
|
||||
},
|
||||
onMakeSure(){
|
||||
async onMakeSure(){
|
||||
const params = this.initParams();
|
||||
params.airTemperature = this.data.maxTempValue;
|
||||
const res = await requestApi('/system/status',{
|
||||
method:'PUT',
|
||||
data:params
|
||||
});
|
||||
if (res.data.code !== 200) {
|
||||
wx.showToast({
|
||||
title: '操作失败',
|
||||
icon:'error'
|
||||
})
|
||||
return;
|
||||
}
|
||||
this.setData({
|
||||
realMaxTempValue:this.data.maxTempValue,
|
||||
tempShow:false
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
<view class='body'>
|
||||
<view class='top'>
|
||||
<view class='around center power'>
|
||||
<view class='power_light center' bindtap='lightPower' style='{{ light_power?"box-shadow:0 0 50rpx 20rpx #0023ff":"" }}'>
|
||||
<view class='power_light center' bindtap='lightPower' style='{{ light_power===true?"box-shadow:0 0 50rpx 20rpx #0023ff":"" }}'>
|
||||
<image src='{{ light_power?"/images/power_on.png":"/images/power_off.png" }}' />
|
||||
</view>
|
||||
</view>
|
||||
<view class='TH around center'>
|
||||
<van-circle value="{{ nowDeviceData.airTemperature }}" color="{{ gradientColor }}" stroke-width="8" size="165" >
|
||||
<van-circle value="{{ nowDeviceData.deviceTemperature }}" color="{{ gradientColor }}" stroke-width="8" size="165" >
|
||||
<slots>
|
||||
<view class='temp_text'>温度:{{ nowDeviceData.deviceTemperature }} ℃</view>
|
||||
<view class='humi_text'>湿度:{{ nowDeviceData.airHumidity }}%</view>
|
||||
@@ -16,6 +16,12 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class='group'>
|
||||
<view class='door item'>
|
||||
<van-cell title="门的状态" size='large' value="{{ nowDeviceData.remark.doorStatus===1?'开':'关' }}" icon='/images/door.png' />
|
||||
</view>
|
||||
<view class=' item'>
|
||||
<van-cell title="光照强度" size='large' value="{{ nowDeviceData.remark.light }}" icon='/images/light.png' />
|
||||
</view>
|
||||
<view class='curtain item'>
|
||||
<van-cell title="窗帘" value="{{ curtainAutoChecked?'自动':'手动' }}" size='large'
|
||||
icon='/images/curtain.png' is-link bindtap='showCurtain'
|
||||
@@ -59,24 +65,26 @@
|
||||
<view class='choose'>
|
||||
<van-cell size='large' title="自动模式">
|
||||
<view slots='value'>
|
||||
<van-switch checked="{{ checked }}" bind:change="onChange" />
|
||||
<van-switch checked="{{ fanAutoChecked }}" bind:change="onAutoFanMode" />
|
||||
</view>
|
||||
</van-cell>
|
||||
</view>
|
||||
<view class='choose'>
|
||||
<van-cell size='large' title="手动模式">
|
||||
<view slots='value'>
|
||||
<van-switch checked="{{ checked }}" bind:change="onChange" />
|
||||
<van-switch checked="{{ fanManvalChecked }}" bind:change="onManvalFanMode" />
|
||||
</view>
|
||||
</van-cell>
|
||||
</view>
|
||||
<block wx:if='{{ fanManvalChecked }}'>
|
||||
<view class='curtain_power'>
|
||||
<van-cell title="风扇开关">
|
||||
<van-cell title="风扇开关" title-style='color:blue;'>
|
||||
<view slots='value'>
|
||||
<van-switch checked="{{ checked }}" bind:change="onChange" />
|
||||
<van-switch checked="{{ fanManvalChecked && fanPowerChecked }}" bind:change="onChangeFanPower" />
|
||||
</view>
|
||||
</van-cell>
|
||||
</view>
|
||||
</block>
|
||||
</van-popup>
|
||||
<van-popup show="{{ tempShow }}" round position="bottom" bind:close="onClose">
|
||||
<view class='tempZu'>设置温度最大值:{{ maxTempValue }}℃</view>
|
||||
|
||||
@@ -29,6 +29,12 @@
|
||||
"pathName": "pages/login/index",
|
||||
"query": "",
|
||||
"scene": null
|
||||
},
|
||||
{
|
||||
"name": "pages/my/index",
|
||||
"pathName": "pages/my/index",
|
||||
"query": "",
|
||||
"scene": null
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user