device.vue 10.7 KB
<template>
	<view class="device-page">
		<f-navbar>
			<view class="u-flex" slot="left" style="justify-content: space-between;flex-direction: row;">
				<view style="width: 580rpx;"><u--input prefixIcon="search" placeholder="输入设备SN或名称搜索" border="surround" shape="circle"></u--input></view>
				<view style="margin-left: 7rpx;">
					<view class=""><text style="color:#333333;font-size: 14px;">筛选</text></view>
				</view>
				<view style="margin-left: 7rpx;"><image @click="openSearchDialog" style="width: 40rpx;height: 40rpx;" src="../../static/shaixuan.png" mode=""></image></view>
			</view>
		</f-navbar>
		<!-- 公共组件-每个页面必须引入 -->
		<public-module></public-module>
		<view class="org-sty">
			<view class="org-item">
				<view class="u-flex" style="flex-direction: row;margin-top: 26rpx;margin-left: 15rpx;">
					<text style="color:#333333;font-size: 15px;margin-left: 14rpx;">组织关系</text>
				</view>
				<view style="margin-top: 5rpx;margin-left: 15rpx;flex-direction: row;" class="u-flex">
					<image style="margin-left: 14rpx;width: 30rpx;height: 30rpx;" src="../../static/org.png" mode=""></image>
					<text style="margin-left: 10rpx;color:#666666;font-size: 12px;">设备数:1234</text>
				</view>
			</view>
			<view class="org-item" style="">
				<image @click="openOrg" style="width: 6px;height: 10px;float: right; margin-right: 34rpx; margin-top: 58rpx;" src="../../static/right-arrow.png" mode=""></image>
			</view>
		</view>
		<mescroll-body ref="mescrollRef" @init="mescrollInit" :down="downOption" @down="downCallback" @up="upCallback">
			<view class="device-list">
				<view @click="openDeviceDetail(item.id)" class="list-item" v-for="(item, index) in list" :key="index">
					<view class="u-flex item" style="justify-content: flex-start;flex-direction: column;align-items: center;">
						<view style="width: 450rpx;text-align: left;">
							<text style="color:#333333;font-size: 15px;">{{ item.name1 }}</text>
						</view>
						<view style="width: 450rpx;text-align: left;">
							<text style="color:#666666;font-size: 15px;">{{ item.name2 }}</text>
						</view>
						<view style="width: 450rpx;text-align: left;">
							<text style="color:#666666;font-size: 15px;">{{ item.name3 }}</text>
						</view>
					</view>
					<view class="item">
						<view class="u-flex" style="flex-direction: row;margin-top: -6rpx;">
							<image style="width: 30rpx;height: 30rpx;margin-top: 5rpx;margin-right: 5rpx;" :src="item.name4" mode=""></image>
							<view class="">
								<text style="color: #377DFF;font-size: 13px;margin-left: 5rpx;margin-top: 20rpx;">{{ item.name5 }}</text>
							</view>
						</view>
					</view>
				</view>
			</view>
		</mescroll-body>
		<view style="height: 30rpx;"></view>
		<!-- 设备筛选 -->
		<u-popup @close="close" closeable bgColor="transparent" :overlay="true" :show="show" mode="bottom">
			<view style="height: 900rpx;background:#f5f5f5;border-radius: 20rpx;">
				<view style="text-align: center;position: relative;top: 68rpx;margin-top: -40rpx;"><text style="font-size: 16px;color: #333333;">筛选条件</text></view>
				<view style="margin-top: 97rpx;margin-left: 43rpx;">
					<view style="width: 750rpx;margin-left: 14rpx;" class=""><text style="color: #333333;font-size: 14px;">设备状态</text></view>
					<view
						class="u-flex"
						style="margin-top: 15rpx;width:650rpx;height: 60rpx;flex-direction: row;
					flex-wrap: wrap;justify-content: space-between; align-content: space-between;"
					>
						<view
							v-for="(item, index) in deviceStatus"
							:key="index"
							style="margin: 10rpx;line-height: 45rpx;text-align: center;
						width:180rpx;height: 60rpx;
						border: 0.02px solid rgba(55, 125, 255, 0.3);
						background-color:#F6F6F6;border-radius:32px"
						>
							<text style="color:#333333;font-size: 13px;">{{ item.name }}</text>
						</view>
					</view>
				</view>
				<view style="margin-top: 145rpx;margin-left: 43rpx;">
					<view style="width: 750rpx;margin-left: 14rpx;" class=""><text style="color: #333333;font-size: 14px;">告警状态</text></view>
					<view
						class="u-flex"
						style="margin-top: 15rpx;width:650rpx;height: 60rpx;flex-direction: row;
				flex-wrap: wrap;justify-content: space-between; align-content: space-between;"
					>
						<view
							v-for="(item, index) in alertStatus"
							:key="index"
							style="margin: 10rpx;line-height: 45rpx;text-align: center;
					width:180rpx;height: 60rpx;
					border: 0.02px solid rgba(55, 125, 255, 0.3);
					background-color:#F6F6F6;border-radius:32px"
						>
							<text style="color:#333333;font-size: 13px;">{{ item.name }}</text>
						</view>
					</view>
				</view>
				<view style="margin-top: 66rpx;margin-left: 43rpx;">
					<view style="width: 750rpx;margin-left: 14rpx;" class=""><text style="color: #333333;font-size: 14px;">设备类型</text></view>
					<view
						class="u-flex"
						style="margin-top: 15rpx;width:650rpx;height: 60rpx;flex-direction: row;
					flex-wrap: wrap;justify-content: space-between; align-content: space-between;"
					>
						<view
							v-for="(item, index) in typeStatus"
							:key="index"
							style="margin: 10rpx;line-height: 45rpx;text-align: center;
						width:180rpx;height: 60rpx;
						border: 0.02px solid rgba(55, 125, 255, 0.3);
						background-color:#F6F6F6;border-radius:32px"
						>
							<text style="color:#333333;font-size: 13px;">{{ item.name }}</text>
						</view>
					</view>
				</view>
				<view class="u-flex" style="flex-direction: row;margin-top: 128rpx;margin-left: 55rpx;">
					<view style="width: 300rpx"><u-button type="info" shape="circle" text="重置"></u-button></view>
					<view style="width: 300rpx;margin-left:46rpx ;"><u-button type="success" shape="circle" text="确认"></u-button></view>
				</view>
			</view>
		</u-popup>
		<f-tabbar></f-tabbar>
	</view>
</template>

<script>
import fTabbar from '@/components/module/f-tabbar/f-tabbar';
import fNavbar from '@/components/module/f-navbar/f-navbar';
import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";

export default {
	mixins: [MescrollMixin], // 使用mixin (在main.js注册全局组件)
	components: {
		fTabbar,
		fNavbar
	},
	data() {
		return {
			downOption: {
				auto: false //是否在初始化后,自动执行downCallback; 默认true
			},
			show: false,
			deviceStatus: [
				{
					index: 1,
					name: '全部',
					bgColor: '#377DFF',
					textColor: '#377DFF'
				},
				{
					index: 2,
					name: '在线',
					bgColor: '#F6F6F6',
					textColor: '#F6F6F6'
				},
				{
					index: 3,
					name: '离线',
					bgColor: '#F6F6F6',
					textColor: '#F6F6F6'
				},
				{
					index: 4,
					name: '待激活',
					bgColor: '#F6F6F6',
					textColor: '#F6F6F6'
				}
			],
			alertStatus: [
				{
					index: 1,
					name: '全部',
					bgColor: '#377DFF',
					textColor: '#377DFF'
				},
				{
					index: 2,
					name: '告警',
					bgColor: '#F6F6F6',
					textColor: '#F6F6F6'
				},
				{
					index: 3,
					name: '正常',
					bgColor: '#F6F6F6',
					textColor: '#F6F6F6'
				}
			],
			typeStatus: [
				{
					index: 1,
					name: '全部',
					bgColor: '#377DFF',
					textColor: '#377DFF'
				},
				{
					index: 2,
					name: '网关设备',
					bgColor: '#F6F6F6',
					textColor: '#F6F6F6'
				},
				{
					index: 3,
					name: '网关子设备',
					bgColor: '#F6F6F6',
					textColor: '#F6F6F6'
				},
				{
					index: 4,
					name: '直连设备',
					bgColor: '#F6F6F6',
					textColor: '#F6F6F6'
				}
			],
			list: [
				{
					name1: '1号楼1楼三单元水表',
					name2: '设备编号:SN987633433',
					name3: '所属组:XXXXXX',
					name4: '../../static/online.png',
					name5: '在线',
					id: 'xx1'
				},
				{
					name1: '2号楼1楼三单元水表',
					name2: '设备编号:SN987633433',
					name3: '所属组:XXXXXX',
					name4: '../../static/online.png',
					name5: '在线',
					id: 'xx2'
				},
				{
					name1: '3号楼1楼三单元水表',
					name2: '设备编号:SN987633433',
					name3: '所属组:XXXXXX',
					name4: '../../static/baojing.png',
					name5: '离线',
					id: 'xx3'
				},
				{
					name1: '4号楼1楼三单元水表',
					name2: '设备编号:SN987633433',
					name3: '所属组:XXXXXX',
					name4: '../../static/unonline.png',
					name5: '未激活',
					id: 'xx4'
				},
				{
					name1: '5号楼1楼三单元水表',
					name2: '设备编号:SN987633433',
					name3: '所属组:XXXXXX',
					name4: '../../static/online.png',
					name5: '在线',
					id: 'xx5'
				},
				{
					name1: '6号楼1楼三单元水表',
					name2: '设备编号:SN987633433',
					name3: '所属组:XXXXXX',
					name4: '../../static/online.png',
					name5: '在线',
					id: 'xx5'
				}
			]
		};
	},
	onLoad() {
		// 隐藏原生的tabbar
		uni.hideTabBar();
	},
	methods: {
		/*下拉刷新的回调 */
		downCallback() {
			//联网加载数据
			this.loadData(1)
		},
		/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
		upCallback(page) {
			//联网加载数据
			this.loadData(page.num)
		},
		//获取设备
		loadData(pageNo) {
		    let httpData = {
		        page: pageNo,
		        pageSize: 10,
		    }
		    uni.$u.http.get('/yt/device', {params: httpData, custom: {load:false}}).then(res => {
		        uni.stopPullDownRefresh();
				console.log('获取后端数据',res);
		        //方法一(推荐): 后台接口有返回列表的总页数 totalPage
		        // this.mescroll.endByPage(res.length, res.pages); //必传参数(当前页的数据个数, 总页数)
		        // if (pageNo == 1) {
		        // 	this.list = res
		        // } else {
		        // 	this.list = this.list.concat(res);
		        // }
		    }).catch(() => {
		        //联网失败, 结束加载
		        this.mescroll.endErr();
		    });
		},
		openOrg() {
			uni.navigateTo({
				url: './org/org'
			});
		},
		open() {},
		close() {
			this.show = false;
		},
		openSearchDialog() {
			this.show = true;
		},
		openDeviceDetail(e) {
			console.log(e);
			uni.navigateTo({
				url: 'deviceDetail'
			});
		}
	}
};
</script>

<style lang="scss" scoped>
.device-page {
	// padding: 0rpx 15rpx;
	min-height: 100vh;
	background-color: #f8f9fa;
}
.org-sty {
	width: 750rpx;
	height: 150rpx;
	margin-top: 1rpx;
	background-color: #fff;
	display: flex;
	flex-direction: row;
	justify-content: space-between;
	.org-item {
		width: 350rpx;
		height: 200rpx;
	}
}
.device-list {
	display: flex;
	flex-direction: column;
	padding-left: 20rpx;
	.list-item {
		width: 713rpx;
		height: 200rpx;
		background-color: #fff;
		margin-top: 24rpx;
		display: flex;
		flex-direction: row;
		border-radius: 10px;
		justify-content: space-between;
		.item {
			margin: 30rpx;
		}
	}
}
</style>