添加了一些页面

This commit is contained in:
qianlile
2021-08-17 13:36:34 +08:00
parent 7c061bbb9b
commit a341927725
47 changed files with 2430 additions and 686 deletions

View File

@@ -12,7 +12,9 @@ Page({
data: {
weather:{}, //天气信息
products:[],
DeviceList:[],
DeviceList:[],
onlineList:[],
unlineList:[],
fourGDeviceList:[],
show: false,
actions: [
@@ -32,16 +34,29 @@ Page({
// }, 2000);
},
//获取设备列表
async getDevices(){
const res = await requestApi('/system/device/list');
console.log(res);
this.setData({ DeviceList:res.data.rows })
const res = await requestApi('/system/device/list',{ method:'GET' });
console.log(res);
const result = JSON.parse(res.result);
let onlineList = [];
let unlineList = [];
result.rows.forEach(v=>{
if (v.isOnline == 1) {
onlineList.push(v)
} else if (v.isOnline == 0) {
unlineList.push(v);
}
})
this.setData({
onlineList,
unlineList,
DeviceList:result.rows
})
},
//获取天气
getWeather:async function(){
let that = this;
@@ -61,15 +76,28 @@ Page({
},
goToDeviceControl(e){
if (e.currentTarget.dataset.info.categoryId !== 5) {
return;
}
wx.navigateTo({
url: '/pages/roomSystem/index',
success:(res)=>{
res.eventChannel.emit('getDeviceInfo',e.currentTarget.dataset.info)
}
})
switch (e.currentTarget.dataset.info.categoryId) {
case 4:
if (e.currentTarget.dataset.info.deviceNum === 'E8DB84933081') {
wx.navigateTo({
url: '/pages/someData/index',
success:(res)=>{
res.eventChannel.emit('getDeviceInfo',e.currentTarget.dataset.info)
}
})
}
break;
case 5:
wx.navigateTo({
url: '/pages/roomSystem/index',
success:(res)=>{
res.eventChannel.emit('getDeviceInfo',e.currentTarget.dataset.info)
}
})
break;
}
},
deviceFail(){

View File

@@ -24,11 +24,11 @@
<view class='devices'>
<view class='devices_tab'>全部 ({{ DeviceList.length }})</view>
<van-tabs swipeable animated>
<van-tab title="WiFi设备({{ DeviceList.length }})">
<van-tab title="在线设备({{ onlineList.length }})">
<scroll-view scroll-y>
<view class="devices_list">
<block wx:if="{{ DeviceList.length !== 0 }}">
<view wx:for='{{ DeviceList }}' wx:key='index' class='border'>
<block wx:if="{{ onlineList.length !== 0 }}">
<view wx:for='{{ onlineList }}' wx:key='index' class='border'>
<block wx:if="{{ item.isOnline === 2 }}">
<view class='devices_item' style="background-color:rgba(0,0,0,.05)" bindtap='deviceNone' data-info='{{item}}'>
<view class="info">
@@ -73,62 +73,62 @@
</block>
</view>
</block>
<block wx:elif='{{ DeviceList.length === 0 }}'>
<block wx:elif='{{ onlineList.length === 0 }}'>
<view class='noDevice'> 暂无设备,请添加。 </view>
</block>
</view>
</scroll-view>
</van-tab>
<van-tab title="4G设备({{ fourGDeviceList.length }})">
<van-tab title="离线设备({{ unlineList.length }})">
<scroll-view scroll-y>
<view class="devices_list">
<block wx:if="{{ fourGDeviceList.length !== 0 }}">
<view wx:for='{{ fourGDeviceList }}' wx:key='index' class='border'>
<block wx:if="{{ item.status === 1 }}">
<block wx:if="{{ unlineList.length !== 0 }}">
<view wx:for='{{ unlineList }}' wx:key='index' class='border'>
<block wx:if="{{ item.isOnline === 2 }}">
<view class='devices_item' style="background-color:rgba(0,0,0,.05)" bindtap='deviceNone' data-info='{{item}}'>
<view class="info">
<view class='img'>
<image src='/icons/device.jpg' />
<image src='/images/room.jpeg' />
</view>
<view class="_right">
<view style="color:#bfbfbf" class="status">未激活</view>
<view style="font-size:24rpx;color:#666">{{ item.device_name }}</view>
<view style="font-size:24rpx;color:#666">{{ item.categoryName }}</view>
</view>
</view>
<view class='name'>{{ item.product_name }}</view>
<view class='name'>{{ item.deviceName }}</view>
</view>
</block>
<block wx:if="{{ item.status === 2 }}">
<block wx:if="{{ item.isOnline === 1 }}">
<view class='devices_item' bindtap='goToDeviceControl' data-info='{{item}}'>
<view class="info">
<view class='img'>
<image src='/icons/device.jpg' />
<image src='/images/room.jpeg' />
</view>
<view class="_right">
<view style="color:green" class="status">在线</view>
<view style="font-size:24rpx;color:#666">{{ item.device_name }}</view>
<view style="font-size:24rpx;color:#666">{{ item.categoryName }}</view>
</view>
</view>
<view class='name'>{{ item.product_name }}</view>
<view class='name'>{{ item.deviceName }}</view>
</view>
</block>
<block wx:if="{{ item.status === 3 }}">
<block wx:if="{{ item.isOnline === 0 }}">
<view style="background-color:rgba(0,0,0,.05)" class='devices_item' bindtap='deviceFail' data-info='{{item}}'>
<view class="info">
<view class='img'>
<image src='/icons/device.jpg' />
<image src='/images/room.jpeg' />
</view>
<view class="_right">
<view style="color:#ff0000" class="status">离线</view>
<view style="font-size:24rpx;color:#666">{{ item.device_name }}</view>
<view style="font-size:24rpx;color:#666">{{ item.categoryName }}</view>
</view>
</view>
<view class='name'>{{ item.product_name }}</view>
<view class='name'>{{ item.deviceName }}</view>
</view>
</block>
</view>
</block>
<block wx:elif='{{ fourGDeviceList.length === 0 }}'>
<block wx:elif='{{ unlineList.length === 0 }}'>
<view class='noDevice'> 暂无设备,请添加。 </view>
</block>
</view>