Просмотр исходного кода

refactor: 优化多页面设备相关逻辑与样式

1. 调整首页事件传递参数,增加menu和device_model字段
2. 修复设备列表2页面跳转逻辑,根据设备型号跳转不同页面
3. 移除scd组件中多余的斑马纹样式
4. 重构视频监控页面,统一使用webview配置并添加导航栏标题
5. 完善scd详情页的摄像头数据获取与跳转逻辑
6. 优化图片列表加载逻辑,新增初始化重置列表功能
7. 调整孢子仪设备设置页面的表单显示逻辑与参数顺序
8. 注释并隐藏设备图片页的部分识别结果展示代码
9. 临时修改api基础地址为测试环境地址
10. 在webview页面添加调试日志
allen 47 минут назад
Родитель
Сommit
24acba137b

+ 9 - 9
pages/cb/bzy/equip-set/equip-set.vue

@@ -23,7 +23,7 @@
 		<view class="tit" v-if="device_model == 0">
 			载玻片滴液时间
 		</view>
-		<view class="uni-list-cell" @click="selectFun('drop_time')">
+		<view class="uni-list-cell" @click="selectFun('drop_time')" v-if="device_model == 0">
 			<text class="uni-input">{{setFrom.drop_time}}</text>
 			<view class="arrow"></view>
 			<u-select v-model="drop_time_show" mode="single-column" :list="drop_time_List" @confirm="confirm($event,'drop')"></u-select>
@@ -34,29 +34,29 @@
 		<view class="" v-if="device_model == 0">
 			<slider :value="setFrom.cul_time" show-value="true" :min="1" :max="24" @change="sliderChange($event,'cul_time')"  block-color="#57C878" activeColor="#57C878" step="1" />
 		</view>
-		<view class="tit">
+		<view class="tit" v-if="device_model == 0">
 			保温仓设定温度(℃)
 		</view>
-		<view class="">
+		<view class="" v-if="device_model == 0">
 			<slider :value="setFrom.set_temp" show-value="true" :min="10" :max="40" @change="sliderChange($event,'set_temp')"  block-color="#57C878" activeColor="#57C878" step="1" />
 		</view>
 		<view class="tit">
-			高温保护阈值(℃)
+			数据上传时间间隔(min)
 		</view>
 		<view class="">
-			<slider :value="setFrom.tph" show-value="true" :min="50" :max="70" @change="sliderChange($event,'tph')"  block-color="#57C878" activeColor="#57C878" step="1" />
+			<slider :value="setFrom.datt" show-value="true" :min="10" :max="60" @change="sliderChange($event,'datt')"  block-color="#57C878" activeColor="#57C878" step="1" />
 		</view>
 		<view class="tit">
-			温保护阈值(℃)
+			温保护阈值(℃)
 		</view>
 		<view class="">
-			<slider :value="setFrom.tpl" show-value="true" :min="-30" :max="20" @change="sliderChange($event,'tpl')"  block-color="#57C878" activeColor="#57C878" step="1" />
+			<slider :value="setFrom.tph" show-value="true" :min="50" :max="70" @change="sliderChange($event,'tph')"  block-color="#57C878" activeColor="#57C878" step="1" />
 		</view>
 		<view class="tit">
-			数据上传时间间隔(min)
+			低温保护阈值(℃)
 		</view>
 		<view class="">
-			<slider :value="setFrom.datt" show-value="true" :min="10" :max="60" @change="sliderChange($event,'datt')"  block-color="#57C878" activeColor="#57C878" step="1" />
+			<slider :value="setFrom.tpl" show-value="true" :min="-30" :max="20" @change="sliderChange($event,'tpl')"  block-color="#57C878" activeColor="#57C878" step="1" />
 		</view>
 		<view class="tit">
 			采集开启和关闭时间

+ 15 - 7
pages/cb/cbd/equip-set/imgpage.vue

@@ -123,7 +123,7 @@
 				// console.log(e)
 			},
 			//forecast.forecast_system.equip_photofo
-			async imglistdata(time_begin, time_end) { //获取图片列表
+			async imglistdata(time_begin, time_end,isInit) { //获取图片列表
 				const res = await this.$myRequest({
 					url: '/api/api_gateway?method=forecast.forecast_system.device_photo_list',
 					data: {
@@ -136,7 +136,11 @@
 						time_end: time_end, //结束时间
 					}
 				})
-				this.imglists = this.imglists.concat(res.data)
+				if(isInit){
+					this.imglists = res.data
+				}else{
+					this.imglists = this.imglists.concat(res.data)
+				}
 				console.log(this.imglists)
 				if (this.imglists.length == 0) {
 					this.tishi = true
@@ -145,7 +149,7 @@
 				}
 			},
 			// 孢子仪的图片列表
-			async imglistdataBzy(time_begin, time_end) { //获取图片列表
+			async imglistdataBzy(time_begin, time_end,isInit) { //获取图片列表
 				const res = await this.$myRequest({
 					url: '/api/api_gateway?method=forecast.forecast_system.equip_photo',
 					data: {
@@ -158,7 +162,11 @@
 						time_end: time_end, //结束时间
 					}
 				})
-				this.imglists = this.imglists.concat(res.data)
+				if(isInit){
+					this.imglists = res.data
+				}else{
+					this.imglists = this.imglists.concat(res.data)
+				}
 				console.log(this.imglists)
 				if (this.imglists.length == 0) {
 					this.tishi = true
@@ -201,7 +209,7 @@
 				const res = await this.$myRequest({
 					url: '/api/api_gateway?method=forecast.send_control.admin_device_control',
 					data: {
-						device_type_id: 3,
+						device_type_id: this.device_type,
 						d_id: this.d_id,
 						cmd: "takephoto"
 					}
@@ -215,9 +223,9 @@
 					var that = this
 					setTimeout(() => {
 						if(that.device_type == 7) {
-							that.imglistdataBzy(parseInt(that.timestate), parseInt(that.timeend))
+							that.imglistdataBzy(parseInt(that.timestate), parseInt(that.timeend),true)
 						} else {
-							that.imglistdata(parseInt(that.timestate), parseInt(that.timeend))
+							that.imglistdata(parseInt(that.timestate), parseInt(that.timeend),true)
 						}
 					}, 1000)
 				} else {

+ 21 - 21
pages/cbd/devicePhoto.vue

@@ -95,7 +95,7 @@
     <view class="recognition-result" v-if="pestList.length">
       <view class="result-title">当前图片识别结果</view>
       <!-- 一类害虫 -->
-      <view v-if="is_mark == 0">
+      <view>
         <view class="pest-category" v-for="(pest,index) in pestList" :key="index">
           <view class="category-header">
             <text class="category-title">{{ pest[0] }}</text>
@@ -110,7 +110,7 @@
           </view>
         </view>
       </view>
-      <view v-else>
+      <!-- <view v-else>
         <view class="pest-category" v-for="(pest,index) in pestList" :key="index">
           <view class="pest-item">
             <view class="pest-info">
@@ -120,7 +120,7 @@
             <text class="pest-count">{{ pest[1].value }}</text>
           </view>
         </view>
-      </view>
+      </view> -->
     </view>
     <u-empty v-else text="暂无数据"></u-empty>
 		<u-calendar 
@@ -477,7 +477,7 @@ export default {
           this.bugMarkers = [];
         }
       } else {
-        this.pestList = [];
+        // this.pestList = [];
         const markers = [];
         // 根据原图宽度计算缩放比例
         let scaleRatio = 3.1;
@@ -488,24 +488,24 @@ export default {
         // } else {
         //   scaleRatio = 2.5;
         // }
-        const pestArr = new Map()
+        // const pestArr = new Map()
         this.currentImg.mark.map((item, index) => {
-          if(pestArr.has(item.text)){
-            pestArr.set(item.text,{
-              value: pestArr.get(item.text).value+=1,
-              text: item.text
-            })
-          }else{
-            pestArr.set(item.text, {
-              value: 1,
-              text: item.text
-            })
-          }
-          const pestList = []
-          for(let key of pestArr){
-            pestList.push(key)
-          }
-          this.pestList = pestList
+          // if(pestArr.has(item.text)){
+          //   pestArr.set(item.text,{
+          //     value: pestArr.get(item.text).value+=1,
+          //     text: item.text
+          //   })
+          // }else{
+          //   pestArr.set(item.text, {
+          //     value: 1,
+          //     text: item.text
+          //   })
+          // }
+          // const pestList = []
+          // for(let key of pestArr){
+          //   pestList.push(key)
+          // }
+          // this.pestList = pestList
           this.is_mark = 1
           const { startX, startY,text } = item;
           // 使用缩放比例计算标记位置和尺寸

+ 11 - 6
pages/equipList2/index.vue

@@ -132,6 +132,7 @@
         counts:0,
         online_counts:0,
         offline_counts:0,
+				accessToken: '',
 				current: 0,
 				currents: 0,
 				total: 0,
@@ -313,6 +314,7 @@
       },
 			historys(item) {
 				const type_id = item.type_id;
+				this.accessToken = uni.getStorageSync('session_key')
 				item.pur_id = this.pur_id;
 				switch (type_id) {
 					// 水肥新设备
@@ -338,12 +340,15 @@
 						break;
 					case 2:
 						item.addtime = item.uptime;
-						uni.navigateTo({
-							url: '../prevention/equipmentdetails?shebei=' + JSON.stringify(item),
-						});
-						// uni.navigateTo({
-						// 	url: '../scd/detail?info=' + JSON.stringify(item),
-						// });
+						if(item.device_model == 102){
+							uni.navigateTo({
+								url: '../scd/detail?info=' + JSON.stringify(item),
+							});
+						}else{
+							uni.navigateTo({
+								url: '../prevention/equipmentdetails?shebei=' + JSON.stringify(item),
+							});
+						}
 						break;
 					case 38:
 						var obj = {};

+ 1 - 1
pages/index/index.vue

@@ -299,7 +299,7 @@
 						url: '/pages/equipList2/index',
 						success: () => {
 							setTimeout(() => {
-								uni.$emit('purId',item.pur_id);
+								uni.$emit('purId',{purId,menu:item.children[0]?.menu || '',device_model:item.children[0]?.device_model || ''});
 							}, 50);
 						}
 					});

+ 0 - 11
pages/scd/components/deviceData.vue

@@ -86,7 +86,6 @@
                 v-for="(item, index) in historyData"
                 :key="index"
                 class="fixed-row"
-                :class="{ even: index % 2 === 0 }"
               >
                 <text class="body-cell fixed">{{ formatTime(item.addtime) }}</text>
               </view>
@@ -107,7 +106,6 @@
                 v-for="(item, index) in historyData"
                 :key="index"
                 class="scrollable-row"
-                :class="{ even: index % 2 === 0 }"
               >
                 <text class="body-cell">{{ item.ds == 1? '打开' : '关闭' }}</text>
                 <text class="body-cell">{{ item.at }}</text>
@@ -1086,11 +1084,6 @@ export default {
             height: 80rpx;
             display: flex;
             align-items: center;
-
-            &.even {
-              background: #FAFAFA;
-            }
-
             .body-cell.fixed {
               font-size: 24rpx;
               font-family: 'Source Han Sans CN VF', sans-serif;
@@ -1143,10 +1136,6 @@ export default {
             height: 80rpx;
             align-items: center;
 
-            &.even {
-              background: #FAFAFA;
-            }
-
             .body-cell {
               min-width: 140rpx;
               font-size: 24rpx;

+ 24 - 4
pages/scd/detail.vue

@@ -161,11 +161,15 @@ export default {
       polylineList: [],
       isShowPhoto: false,
       deviceHistoryList: [],
-      deviceStatic: {}
+      deviceStatic: {},
+      accessToken: '',
+      camera_id: ''
     }
   },
   onLoad(options){
     this.deviceInfo = JSON.parse(options.info);
+		this.accessToken = uni.getStorageSync('session_key')
+    this.getDeviceCameraData()
     const newVal = this.deviceInfo;
     if (newVal.device_model == '11'){
       this.isShowPhoto = true
@@ -342,14 +346,30 @@ export default {
     },
     handleTabClick(tab) {
       if(tab === 'videoMonitor'){
+        // uni.navigateTo({
+        //   url:
+        //     '/pages/scd/videoMonitor?videoUrl=' + this.videoUrl
+        // });
         uni.navigateTo({
-          url:
-            '/pages/scd/videoMonitor?videoUrl=' + this.videoUrl
-        }); 
+          url: '/pages/webview/webview?device_id=' +
+            this.camera_id +
+            '&accessToken=' +
+            this.accessToken,
+        });
       }else{
         this.initAction();
       }
     },
+    async getDeviceCameraData(){
+      const res = await this.$myRequest({
+        url: '/api/api_gateway?method=forecast.send_control.get_binding_camera_info',
+        method: 'POST',
+        data: {
+          device_id: this.deviceInfo.id,
+        },
+      });
+      this.camera_id = res?.camera_id || ''
+    },
     async getDeviceData(){
       const res = await this.$myRequest({
         url: '/api/api_gateway?method=forecast.worm_lamp.device_status_data',

+ 37 - 21
pages/scd/videoMonitor.vue

@@ -1,26 +1,42 @@
 <template>
-   <view>
-		<web-view :src="videoUrl" id="webcon" cache-control="no-cache" class="video-monitor" :fullscreen="false">
+	<view class="webview">
+		<web-view :src="url" id="webcon"  cache-control="no-cache">
 		</web-view>
-    </view>
+	</view>
 </template>
+
 <script>
-export default {
-  data() {
-    return {
-     videoUrl:''
-    }
-  },
-  onLoad() {
-    const route = this.$route;
-    const videoUrl = route.query.videoUrl;
-    this.videoUrl = videoUrl;
-  },
-}
+	export default {
+		data() {
+			return {
+				url: '',
+				device_id: '',
+				accessToken: ''
+			}
+		},
+		onLoad(options) {
+			this.device_id = options.device_id
+			this.accessToken = uni.getStorageSync('session_key')
+			
+			this.url = "https://wx.hnyfwlw.com/wexin/h52.html?device_id=" + this.device_id + "&accessToken=" + this.accessToken
+			// this.url = "http://192.168.2.167:5500/index.html?device_id=" + this.device_id + "&accessToken=" + this.accessToken
+			// this.url = "https://demo.nyzhwlw.com/wechat?device_id=" + this.device_id + "&accessToken=" + this.accessToken
+			//设置 webview 界面的状态栏的 title
+			uni.setNavigationBarTitle({
+				title: '监控详情'
+			});
+		},
+		methods: {
+
+
+
+		}
+	}
 </script>
-<style scoped>
-.video-monitor {
-  width: 100%;
-  height: 100%;
-}
-</style>
+
+<style>
+	.webview {
+		width: 100vw;
+		height: 100vh;
+	}
+</style>

+ 1 - 0
pages/webview/webview.vue

@@ -17,6 +17,7 @@
 		onLoad(options) {
 			this.device_id = options.device_id
 			this.accessToken = uni.getStorageSync('session_key')
+			console.log(this.accessToken,'thisaccessToken')
 			
 			this.url = "https://wx.hnyfwlw.com/wexin/h52.html?device_id=" + this.device_id + "&accessToken=" + this.accessToken
 			// this.url = "http://192.168.2.167:5500/index.html?device_id=" + this.device_id + "&accessToken=" + this.accessToken

+ 2 - 2
util/api.js

@@ -1,9 +1,9 @@
 // let BASE_URL = 'http://114.55.0.7:8002';
 // const BASE_URL='http://8.136.98.49:8002'
 // let BASE_URL = 'http://218.28.198.186:10505'
-let BASE_URL = 'https://wx.hnyfwlw.com'
+// let BASE_URL = 'https://wx.hnyfwlw.com'
 // let BASE_URL = 'http://192.168.1.107:8000';
-// let BASE_URL = 'http://218.28.198.186:10508';
+let BASE_URL = 'http://218.28.198.186:10508';
 // let BASE_URL = 'https://uat.hnyfwlw.com'
 export const myRequest = (options) => {
   // BASE_URL=uni.getStorageSync('http')