diff --git a/wechat/miniprogram/app.json b/wechat/miniprogram/app.json index cd6cf10d..f323e4f1 100644 --- a/wechat/miniprogram/app.json +++ b/wechat/miniprogram/app.json @@ -1,8 +1,9 @@ { - "pages": [ - "pages/index/index", + "pages": [ "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": { diff --git a/wechat/miniprogram/images/door.png b/wechat/miniprogram/images/door.png new file mode 100644 index 00000000..8a8e04e7 Binary files /dev/null and b/wechat/miniprogram/images/door.png differ diff --git a/wechat/miniprogram/images/light.png b/wechat/miniprogram/images/light.png new file mode 100644 index 00000000..4903a04a Binary files /dev/null and b/wechat/miniprogram/images/light.png differ diff --git a/wechat/miniprogram/pages/login/index.js b/wechat/miniprogram/pages/login/index.js index ebb0ac3c..c2cb4fda 100644 --- a/wechat/miniprogram/pages/login/index.js +++ b/wechat/miniprogram/pages/login/index.js @@ -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', + }) }, diff --git a/wechat/miniprogram/pages/login/index.json b/wechat/miniprogram/pages/login/index.json index e52daced..da07a9a9 100644 --- a/wechat/miniprogram/pages/login/index.json +++ b/wechat/miniprogram/pages/login/index.json @@ -1,5 +1,6 @@ { "usingComponents": { - "van-field": "@vant/weapp/field/index" + "van-field": "@vant/weapp/field/index", + "van-button": "@vant/weapp/button/index" } } \ No newline at end of file diff --git a/wechat/miniprogram/pages/login/index.wxml b/wechat/miniprogram/pages/login/index.wxml index c6f89272..bc22b75a 100644 --- a/wechat/miniprogram/pages/login/index.wxml +++ b/wechat/miniprogram/pages/login/index.wxml @@ -1,4 +1,5 @@ +欢迎登录智慧宿舍系统 + + 登录 + - - diff --git a/wechat/miniprogram/pages/login/index.wxss b/wechat/miniprogram/pages/login/index.wxss index 8e86a300..cc3461f2 100644 --- a/wechat/miniprogram/pages/login/index.wxss +++ b/wechat/miniprogram/pages/login/index.wxss @@ -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{ @@ -30,4 +37,8 @@ width: 200rpx; display: inline-block; height: 77rpx; +} +.btn{ + margin: 45rpx auto; + width: 40vw; } \ No newline at end of file diff --git a/wechat/miniprogram/pages/my/index.js b/wechat/miniprogram/pages/my/index.js new file mode 100644 index 00000000..1bb51805 --- /dev/null +++ b/wechat/miniprogram/pages/my/index.js @@ -0,0 +1,19 @@ +var app = getApp(); + +Page({ + data: { + userInfo: {}, + mode: ['信息反馈', '联系客服', '关于我们'] + }, + onLoad: function () { + }, + getOut(){ + wx.clearStorage({ + success: (res) => { + wx.reLaunch({ + url: '/pages/login/index', + }) + }, + }) + } +}) \ No newline at end of file diff --git a/wechat/miniprogram/pages/my/index.json b/wechat/miniprogram/pages/my/index.json new file mode 100644 index 00000000..8835af06 --- /dev/null +++ b/wechat/miniprogram/pages/my/index.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/wechat/miniprogram/pages/my/index.wxml b/wechat/miniprogram/pages/my/index.wxml new file mode 100644 index 00000000..a7735dbd --- /dev/null +++ b/wechat/miniprogram/pages/my/index.wxml @@ -0,0 +1,16 @@ + + + + + + + + + + + + {{item}} + + + +退出 \ No newline at end of file diff --git a/wechat/miniprogram/pages/my/index.wxss b/wechat/miniprogram/pages/my/index.wxss new file mode 100644 index 00000000..219e14b9 --- /dev/null +++ b/wechat/miniprogram/pages/my/index.wxss @@ -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; +} \ No newline at end of file diff --git a/wechat/miniprogram/pages/roomSystem/index.js b/wechat/miniprogram/pages/roomSystem/index.js index 2c219cb8..ea110915 100644 --- a/wechat/miniprogram/pages/roomSystem/index.js +++ b/wechat/miniprogram/pages/roomSystem/index.js @@ -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 diff --git a/wechat/miniprogram/pages/roomSystem/index.wxml b/wechat/miniprogram/pages/roomSystem/index.wxml index 8f4f1475..5227eca4 100644 --- a/wechat/miniprogram/pages/roomSystem/index.wxml +++ b/wechat/miniprogram/pages/roomSystem/index.wxml @@ -2,12 +2,12 @@ - + - + 温度:{{ nowDeviceData.deviceTemperature }} ℃ 湿度:{{ nowDeviceData.airHumidity }}% @@ -16,6 +16,12 @@ + + + + + + - + - - - - - - - - + + + + + + + + + + 设置温度最大值:{{ maxTempValue }}℃ diff --git a/wechat/project.private.config.json b/wechat/project.private.config.json index 0bb67bf6..b9c5e3de 100644 --- a/wechat/project.private.config.json +++ b/wechat/project.private.config.json @@ -29,6 +29,12 @@ "pathName": "pages/login/index", "query": "", "scene": null + }, + { + "name": "pages/my/index", + "pathName": "pages/my/index", + "query": "", + "scene": null } ] }