Browse Source

接口对接

ming 4 years ago
parent
commit
cb45a3a07d

+ 21 - 3
pages.json

@@ -77,7 +77,7 @@
 			}
 		},
 		{
-			"path": "pages/deviceManage/deviceManage",
+			"path": "pages/device-Manage/device-Manage",
 			"style": {
 				"navigationBarTitleText": "设备管理"
 			}
@@ -184,7 +184,7 @@
 			}
 
 		}, {
-			"path": "pages/deviceManage/deviceManage",
+			"path": "pages/device-Manage/device-Manage",
 			"style": {
 				"navigationBarTitleText": "设备管理",
 				"enablePullDownRefresh": false
@@ -206,7 +206,7 @@
 			}
 
 		}, {
-			"path": "pages/deviceManage/deviceDetail/deviceDetail",
+			"path": "pages/device-Manage/deviceDetail/deviceDetail",
 			"style": {
 				"navigationBarTitleText": "监控画面",
 				"enablePullDownRefresh": false
@@ -322,6 +322,24 @@
             }
             
         }
+        ,{
+            "path" : "pages/deviceManage/deviceManage",
+            "style" :                                                                                    
+            {
+                "navigationBarTitleText": "设备管理",
+                "enablePullDownRefresh": false
+            }
+            
+        }
+        ,{
+            "path" : "pages/deviceAdd/deviceAdd",
+            "style" :                                                                                    
+            {
+                "navigationBarTitleText": "",
+                "enablePullDownRefresh": false
+            }
+            
+        }
     ],
 	"globalStyle": {
 		"navigationBarTextStyle": "black",

+ 158 - 54
pages/deviceManage/deviceManage.vue

@@ -1,83 +1,187 @@
 <template>
+	<view class="site-wrapper">
+		<!-- 筛选框start -->
+		<view class="ding">
+			<view class="cu-bar search bg-gray filter-section">
+				<view class="search-form round bg-white">
+					<text class="cuIcon-search"></text>
+					<input class=""  type="text" placeholder="请输入设备名称"
+					 confirm-type="search" v-model="deviceName"></input>
+				</view>
+				<view class="action">
+					<button class="cu-btn bg-blue round" @click="searchSiteList">查询</button>
+				</view>
+			</view>
+		</view>
+		<!-- 筛选框end -->
 
-	<view class="">
-		<view class="cu-list menu-avatar">
-			
-			
-			<view class="cu-item deviceTypeItem" :class="modalName=='move-box-'+ index?'move-cur':''" v-for="(item,index) in deviceData"
-			 :key="index" :data-target="'move-box-' + index" @tap="goDeviceDetail(item)">
-				<view class="cu-avatar round lg" style="background-image:url(../../static/jx.png)"></view>
-				<view class="content" >
-					<view class="">{{item.deviceName}}</view>
-				</view>
-				<view class="nav-right num">
-					<view class="text-grey">
-						{{item.trueStatus?'离线':'在线'}}
-						<text class="icon iconfont margin-right-xs margin-left-lg">&#xe629;</text>
-					</view>
-				</view>
+		<!-- 站点列表start -->
+		<view class="site-items">
+			<view class="cu-list menu-avatar">
+				<view class="cu-item" :class="modalName=='move-box-'+ index?'move-cur':''" v-for="(item,index) in siteList" :key="index"
+				 @touchstart="ListTouchStart" @touchmove="ListTouchMove" @touchend="ListTouchEnd" :data-target="'move-box-' + index">
+					<view class="cu-avatar round lg" style="background-image: url(../../static/site-icon.png);"></view>
+
+					<view class="content">
+						<view class="text-grey site-tit">{{item.deviceName}}</view>
+					</view>
+
+					<view class="nav-right num">
+						<view class="text-grey text-xs">
+							<image @click="mapLocation(item)" src="../../static/nav-icon.png" style="width:25rpx;height:25rpx;margin-right:26rpx"></image>
+						</view>
+					</view>
+					<view class="move">
+						<view class="bg-grey" @click.stop="editItem(item)">编辑</view>
+						<view class="bg-red" @click.stop="deleteItem(item)">删除</view>
+					</view>
+				</view>
 			</view>
+			<view v-if="!siteList.length&&siteListRes==1" class="text-center margin-top"> 暂无数据</view>
+		</view>
+		<!-- 站点列表end -->
+
+		<!-- 新增按钮start -->
+		<view class="plus">
+			<image src="../../static/plus.png" style="width:125rpx;height:125rpx" @tap="goAddPage()"></image>
 		</view>
+		<!-- 新增按钮end -->
 	</view>
+
 </template>
 
 <script>
 	export default {
 		data() {
-			return {
-				deviceData:[],
-				
+			return {
 				modalName: null,
+				listTouchStart: 0,
+				listTouchDirection: null,
+
+				deviceName: '',
+				siteList: [],
+				siteListRes: 0,
 			};
-		},
-		
-		onLoad:function(option){
-			console.log(111)
-			console.log(option.companyCode)
-			this.companyCode=option.companyCode
-			this.deviceType=option.deviceType
-			this.getDeviceManage({"companyCode":option.companyCode,"deviceType":option.deviceType})
 		},
-		methods: {
-			
-			async getDeviceManage(ming={}) {
-				const res= await this.$myRequest({
-					url:'OperationMonitoring/getDeviceList',
-					data:ming,
-					showLoading:true
-				})
-				console.log(res.data.data)
-				this.deviceData=res.data.data
-				// this.powerDeviceCount= res.data.data[0].powerDeviceCount
-				// this.videoDeviceCount= res.data.data[0].videoDeviceCount
-				
+
+		onLoad: function(option) {
+			
+			//站点列表渲染
+			this.getDeviceList()
+			
+		},
+		
+		methods: {
+			//筛选
+			searchSiteList() {
+				this.getDeviceList({
+					"deviceName": this.deviceName
+				})
 			},
 			
-			// 页面跳转
-			goDeviceDetail(item) {
+			//编辑
+			editItem(item) {
 				uni.navigateTo({
-					url: '/pages/deviceManage/deviceDetail/deviceDetail?deviceType=1&companyCode='+this.companyCode+'&deviceCode='+item.deviceCode+'',
-					success: res => {},
-					fail: () => {},
-					complete: () => {}
+					url: '/pages/deviceAdd/deviceAdd?id=' + item.siteId + '',
 				});
 			},
+
+			//删除
+			deleteItem(item) {
+				uni.showModal({
+					title: '确认删除吗?',
+					content: '',
+					success: function(result) {
+						if (result.confirm) {
+							this.setDelSite({
+								"id": item.id
+							})
+						} else if (result.cancel) {
+							// console.log('用户点击取消');
+						}
+					}.bind(this)
+				});
+			},
+			
+			// 打开导航
+			mapLocation(item) {
+				uni.openLocation({
+					latitude: parseInt(item.latitude),
+					longitude: parseInt(item.longitude),
+					success: function() {
+						// console.log('success');
+					}
+				});
+			},
+
+			async setDelSite(ming = {}) {
+				const res = await this.$myRequest({
+					url: 'DeviceManagement/setDelSite',
+					data: ming
+				})
+				if (!res.data.flag) {
+					uni.showToast({
+						title: "删除失败",
+						icon: "none"
+					});
+				}else{
+					uni.showToast({
+						title: "删除成功",
+					});
+					setTimeout(() => {
+						this.getDeviceList()
+					}, 1000);
+				}
+				
+			},
+
+			async getDeviceList(ming = {}) {
+				const res = await this.$myRequest({
+					url: 'DeviceManagement/getDeviceList',
+					showLoading: true,
+					data: ming
+				})
+				this.siteListRes = 1;
+				this.siteList = res.data.data
+				console.log(res.data.data);
+			},
+			
+			// 新增跳转
+			goAddPage() {
+				uni.navigateTo({
+					url: '/pages/deviceAdd/deviceAdd',
+					success: res => {},
+					fail: () => {},
+					complete: () => {}
+				});
+			},
 			
+		
 
+			// ListTouch触摸开始
+			ListTouchStart(e) {
+				this.listTouchStart = e.touches[0].pageX
+			},
 
+			// ListTouch计算方向
+			ListTouchMove(e) {
+				this.listTouchDirection = e.touches[0].pageX - this.listTouchStart < -80 ? 'left' : 'right'
+			},
 
+			// ListTouch计算滚动
+			ListTouchEnd(e) {
+				if (this.listTouchDirection == 'left') {
+					this.modalName = e.currentTarget.dataset.target
+				} else {
+					this.modalName = null
+				}
+				this.listTouchDirection = null
+			}
 		}
 
 	}
 </script>
 
-<style lang="scss">
-	.cu-list.menu-avatar>.cu-item .content>uni-view:first-child {
-		font-size: 32rpx;
-	}
+<style>
 
-	.num {
-		font-size: 30rpx;
-		color: #666;
-	}
 </style>

+ 2 - 2
pages/deviceType/deviceType.vue

@@ -95,7 +95,7 @@
 			goDeviceManage(item){
 				if(this.powerDeviceCount){
 					uni.navigateTo({
-						url: '/pages/deviceManage/deviceManage?deviceType=1&companyCode='+this.companyCode+'',
+						url: '/pages/device-Manage/device-Manage?deviceType=1&companyCode='+this.companyCode+'',
 						success: res => {},
 						fail: () => {},
 						complete: () => {}
@@ -125,7 +125,7 @@
 						url = "/pages/videoList/videoList" //进口水果
 						break;
 					case 1:
-						url = "/pages/deviceManage/deviceManage" //热门品种
+						url = "/pages/device-Manage/device-Manage" //热门品种
 						break;
 
 					default:

+ 24 - 8
pages/index/index.vue

@@ -143,12 +143,18 @@
 			}
 		},
 
-		onLoad() {
-			
-			
-			this.getPageAuthorization()
-			
-			
+		onLoad(option) {
+			console.log('option')
+			console.log(option)
+			if(!option.code){
+				alert(1)
+				 this.getPageAuthorization()
+				
+			}else{
+				alert(option.code);
+				this.getPageAuthorization({"code":option.code})
+			}
+
 			this.hackReset = false;
 			this.$nextTick(() => {
 				this.hackReset = true;
@@ -158,11 +164,13 @@
 		},
 		methods: {
 			//首页初始化授权
-			async getPageAuthorization() {
+			async getPageAuthorization(ming={}) {
 				const res = await this.$myRequest({
 					url: 'Com/getPageAuthorization',
+					data:ming
 				})
 				alert(res.data.flag)
+				
 				console.log('res.data'); 
 				console.log(res.data); 
 		
@@ -171,6 +179,11 @@
 						url: '/pages/login/login',
 					});
 				}
+				if(res.data.flag==3002){
+					uni.navigateTo({
+						url: 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx4eab2e3b5531d58b&redirect_uri=' +res.data.tourl+'&response_type=code&scope=snsapi_base&state=abc123#wechat_redirect',
+					});
+				}
 		
 			},
 
@@ -178,7 +191,10 @@
 				const res = await this.$myRequest({
 					url: 'Index/getDataStatistics',
 					showLoading:true
-				})
+				})
+				
+				// alert(res.data.flag);
+				
 				this.staticData = res.data.data[0]
 			},
 

+ 2 - 2
pages/siteManage/siteManage.vue

@@ -22,7 +22,7 @@
 				 @touchstart="ListTouchStart" @touchmove="ListTouchMove" @touchend="ListTouchEnd" :data-target="'move-box-' + index">
 					<view class="cu-avatar round lg" style="background-image: url(../../static/site-icon.png);"></view>
 
-					<view class="content">
+					<view class="content" @tap="goDeviceManage">
 						<view class="text-grey site-tit">{{item.siteName}}</view>
 					</view>
 
@@ -159,7 +159,7 @@
 			//跳转到设备管理页面
 			goDeviceManage() {
 				uni.navigateTo({
-					url: '/pages/siteManage/siteManage',
+					url: '/pages/deviceManage/deviceManage',
 					success: res => {},
 					fail: () => {},
 					complete: () => {}