李程龙 3 년 전
부모
커밋
088283b706
3개의 변경된 파일75개의 추가작업 그리고 21개의 파일을 삭제
  1. 2 2
      api/worm.js
  2. 72 18
      pages/worm/index.vue
  3. 1 1
      utils/utils.js

+ 2 - 2
api/worm.js

@@ -13,10 +13,10 @@ export const getWormLampList = (params) => wormRequest('lamp_list',params);
 
 
 // 测报灯详情
-export const getWormLampDetails = (params) => wormRequest('device_status_data'params);
+export const getWormLampDetails = (params) => wormRequest('device_status_data',params);
 
 // 害虫预警
-export const getPestWarningList = (params) => wormRequest('cbd_pest_warning'params);
+export const getPestWarningList = (params) => wormRequest('cbd_pest_warning',params);
 
 // 图片列表
 export const getWormImageList = (params) => request.post(`api/api_gateway?method=forecast.forecast_system.device_photo_list`, params);

+ 72 - 18
pages/worm/index.vue

@@ -2,41 +2,95 @@
 	<!--虫情监测列表 -->
 	<view>
 		<!-- 搜索框 -->
-		<ui-search placeholder="请输入设备ID"></ui-search>
+		<ui-search placeholder="请输入设备ID" @confirm="searchLampList"></ui-search>
 		<!-- 搜索框end -->
 		<!-- 监测列表 -->
-		<view class="ui-card forecast-item" @click="openDetails()">
-			<view class="flex-1 info">
-				<view class="font-16  title on">测报灯</view>
-				<view class="text">设备ID:87845748629</view>
-				<view class="text">最新上报时间:2022-08-31 11:21:01</view>
+		<block v-for="(item,index) in lampList" :key="index">
+			<view class="ui-card forecast-item" @click="openLampDetails(item)">
+				<view class="flex-1 info">
+					<view class="font-16  title" :class="item.is_online?'on':'off'">{{item.device_name}}</view>
+					<view class="text">设备ID:{{item.imei}}</view>
+					<view class="text">最新上报时间:{{ item.uptime | timeFrom}}</view>
+				</view>
+				<ui-state :state="item.is_online"></ui-state>
 			</view>
-			<ui-state state="1"></ui-state>
-		</view>
-		
+		</block>
 		<!-- 监测列表end -->
 	</view>
 </template>
 
 <script>
+	import {
+		getWormLampList
+	} from '@/api/worm.js'
 	export default {
 		data() {
 			return {
-
+				// 列表搜索条件
+				params: {
+					device_type_id: 3, //3虫情测报灯 7孢子仪
+					device_id: '', // 搜索项,设备号、设备名称搜索
+					page: 1,
+					page_size: 10,
+					// device_status: // 筛选项 1在线  0离线
+				},
+				total: 0, // 设备总数
+				lampList: [], // 测报灯列表
 			};
 		},
-		methods:{
+		onLoad() {
+			this.getLampList();
+		},
+		// 触底请求
+		onReachBottom(e) {
+			if (this.lampList.length >= this.total) {
+				return;
+			}
+			this.params.page += 1;
+			this.getLampList();
+		},
+		//下拉刷新
+		onPullDownRefresh() {
+			this.refreshLampList();
+			uni.stopPullDownRefresh()
+		},
+		methods: {
+			// 刷新测试灯列表
+			refreshLampList() {
+				this.params.page = 1;
+				this.lampList = [];
+				this.getLampList();
+			},
+			// 获取测试灯列表
+			async getLampList() {
+				const {
+					ids,
+					nums
+				} = await getWormLampList();
+				this.lampList = [...this.lampList, ...ids];
+				this.total = nums ?? 0;
+			},
+			/**
+			 * 测试灯
+			 * @param {String} val 搜索内容
+			 */
+			searchLampList(val) {
+				this.params.device_id = val;
+				this.refreshLampList();
+			},
 			// 打开虫情详情列表
-			openDetails(){
+			openLampDetails(item) {
+				let params = {
+					equip_name: item.equip_name, //设备名称
+					equip_id: item.equip_id, //设备号
+					address: item.address, //组织地址
+					is_online: item.is_online, //在线状态 0离线 1在线
+					uptime: item.uptime //数据更新时间  秒级时间戳
+				}
 				uni.navigateTo({
-					url:`details?id=`
+					url: `details?params=${JSON.stringify(params)}`
 				})
 			}
-			
 		},
 	}
 </script>
-
-<style lang="scss">
-	
-</style>

+ 1 - 1
utils/utils.js

@@ -111,7 +111,7 @@ export const createMap = (obj, keys) => {
  * @param {String} fmt 格式化规则 yyyy:mm:dd|yyyy:mm|yyyy年mm月dd日|yyyy年mm月dd日 hh时MM分等 ss 秒,可自定义组合 默认yyyy-mm-dd
  * @returns {string} 返回格式化后的字符串
  */
-export function timeFormat(dateTime = null, formatStr = 'yyyy-mm-dd') {
+export function timeFormat(dateTime = null, formatStr = 'yyyy-mm-dd hh:MM:ss') {
 	let date
 	// 若传入时间为假值,则取当前时间
 	if (!dateTime) {