Browse Source

Merge branch 'master' of http://49.4.49.126:3000/Gyee_web/sisMobilePhone

zhaomiao 4 years ago
parent
commit
ecd0ea6570

+ 2 - 2
common/store.js

@@ -5,11 +5,11 @@ Vue.use(Vuex)
 
 const store = new Vuex.Store({
     state: {
-		wholeSituationBackStageIp:'117.78.18.24',//117.78.18.24
+		wholeSituationBackStageIp:'192.168.0.91',//117.78.18.24
 		wholeSituationBackStagePort:'9988',
 		
 		GlobalLocalIp:'192.168.0.91',//192.168.1.102
-		GlobalLocalPort:'4397',
+		GlobalLocalPort:'9987',
 		
 		windpowerstationNameToId:{},
 		

+ 266 - 59
components/login/Login.vue

@@ -1,6 +1,7 @@
 <template>
 	<view>
-		<view v-show="accountIsShow">
+		
+		<view v-if="accountIsShow">
 			<view class="title">账号密码登录</view>
 			<view class="usernameAndPassword">
 				<view class="usernameContent">
@@ -21,7 +22,7 @@
 				点击登录,即代表已阅读并同意<a href="#">隐私政策</a>和<a href="#">用户协议</a>
 			</view>
 		</view>
-		<view v-show="phoneIsShow">
+		<view v-if="phoneIsShow">
 			<view class="title">手机验证码登录</view>
 			<view class="usernameAndPassword">
 				<view class="phoneContent">
@@ -41,11 +42,17 @@
 				点击登录,即代表已阅读并同意<a href="#">隐私政策</a>和<a href="#">用户协议</a>
 			</view>
 		</view>
+		
+			
+		<initial ref="mywebview"></initial> 
+
 	</view>
 </template>
 
 <script>
+
 	export default {
+
 		data: function() {
 			return {
 				passwordShow: true,
@@ -76,7 +83,7 @@
 			};
 		},
 		created() {
-
+			uni.setStorageSync('im_show','0');
 			this.windowWidth = uni.getSystemInfoSync().windowWidth;
 			this.windowHeight = uni.getSystemInfoSync().windowHeight;
 			//console.log(this.windowWidth);
@@ -97,6 +104,12 @@
 			this.getUsernamePassword();
 		},
 		computed: {
+			sisStageIp: function() {
+				return this.$store.state.wholeSituationBackStageIp;
+			},
+			sisStagePort: function() {
+				return this.$store.state.wholeSituationBackStagePort;
+			},
 			backStageIp: function() {
 				return this.$store.state.wholeSituationBackStageIp;
 			},
@@ -114,9 +127,14 @@
 			}
 		},
 		methods: {
+			
 			showPass(e) {
 				this.passwordShow = e;
 			},
+			destroyUseWebViews() {
+				this.$refs.mywebview.destroyUseWebViews();
+				
+			},
 			usernameInput(e) {
 				if (e.detail.value != "") {
 					this.usernameFlag = true;
@@ -249,76 +267,264 @@
 						title: "请先用密码登录!"
 					});
 				}
-			},
-			getUsernamePassword: function() {
-				this.lastUserName = uni.getStorageSync('gyeeusername');
-				this.lastPassWord = uni.getStorageSync('gyeepassword');
-				if (this.lastUserName != '' && this.lastPassWord != '') {
-					uni.switchTab({
-						url: '/pages/index/Index'
+			},getFingerPrintPassword: function() {
+				let _this = this;
+				if (uni.getStorageSync('fingerPrintname') != '' && uni.getStorageSync('fingerPrintpassword') != '') {
+				
+					uni.setStorageSync('gyeeusername', uni.getStorageSync('fingerPrintname'));
+					uni.setStorageSync('gyeepassword', uni.getStorageSync('fingerPrintpassword'));
+					uni.setStorageSync('userid', uni.getStorageSync('fingerPrintuserid'));
+					
+					
+					this.username = uni.getStorageSync('gyeeusername');
+					this.password = uni.getStorageSync('gyeepassword');
+					uni.request({
+						url: 'http://' + this.backStageIp + ':' + this.backStagePort + '/GyeeuserController/login?username=' + this.username +
+							'&password=' + this.password,
+						data: {},
+						method: 'GET',
+						success: function(res) {
+							//console.log(res.data);
+							_this.userid = res.data.data;
+					
+					
+							uni.setStorageSync('userid', _this.userid);
+							uni.setStorageSync('fingerPrintuserid', _this.userid);
+							//sessionStorage.setItem('userid',_this.userid);
+							if (res.data.code == 200) {
+					
+								
+								_this.dataprocessing.viewUserid();
+								_this.dataprocessing.monitoringAuthority();
+								
+						
+								_this.createUserOnline();
+								_this.setUsernamePassword();
+								_this.loginFalg = true;
+								_this.lastUserName = _this.username;
+								_this.lastPassWord = _this.password;
+								uni.switchTab({
+									url: '/pages/index/Index'
+								});
+							} else {
+								uni.showModal({
+									content: '用户名密码输入错误,请核对'
+								});
+								_this.username = '';
+								_this.password = '';
+							}
+						},
+						fail: () => {
+							_this.tips = '网络错误,小程序端请检查合法域名';
+						}
 					});
+
 				}
+				
 			},
+			// getUsernamePassword: function() {
+			// 	this.lastUserName = uni.getStorageSync('gyeeusername');
+			// 	this.lastPassWord = uni.getStorageSync('gyeepassword');
+				
+			// 	this.createUserOnline();
+				
+			// 	if (this.lastUserName != '' && this.lastPassWord != '') {
+			// 		uni.switchTab({
+			// 			url: '/pages/index/Index'
+			// 		});
+			// 	}
+			// },
 			removeUsernamePassword: function() {
 				uni.removeStorageSync('gyeeusername');
 				uni.removeStorageSync('gyeepassword');
 				//uni.removeStorageSync('userid');
+			},getUsernamePassword: function() {
+					let _this = this;
+				 	this.username = uni.getStorageSync('gyeeusername');
+				 	this.password = uni.getStorageSync('gyeepassword');
+					if(this.username!="" && this.password!="")
+					{
+						uni.request({
+							url: 'http://' + this.backStageIp + ':' + this.backStagePort + '/GyeeuserController/login?username=' + this.username +
+								'&password=' + this.password,
+							data: {},
+							method: 'GET',
+							success: function(res) {
+								//console.log(res.data);
+								_this.userid = res.data.data;
+						
+						
+								uni.setStorageSync('userid', _this.userid);
+								uni.setStorageSync('fingerPrintuserid', _this.userid);
+								//sessionStorage.setItem('userid',_this.userid);
+								if (res.data.code == 200) {
+						
+									
+									_this.dataprocessing.viewUserid();
+									_this.dataprocessing.monitoringAuthority();
+									
+									// let plusDrawerList = uni.getStorageSync('plusList');
+									
+									// _this.dataprocessing.putWindPowerStationId(plusDrawerList[0].windId);
+									// _this.dataprocessing.putWindPowerStationName(plusDrawerList[0].name);
+									
+									// if(_this.dataprocessing.getWindPowerStationId()=='')
+									// {
+									// 	//debugger
+									// 	_this.dataprocessing.putWindPowerStationId(_this.$store.state.default_wpid);
+									// }
+						
+									// if(_this.dataprocessing.getWindPowerStationName()=='')
+									// {
+									// 	//debugger
+									// 	_this.dataprocessing.putWindPowerStationName(_this.$store.state.default_wpname);
+									// }
+									_this.createUserOnline();
+									_this.setUsernamePassword();
+									_this.loginFalg = true;
+									_this.lastUserName = _this.username;
+									_this.lastPassWord = _this.password;
+									uni.switchTab({
+										url: '/pages/index/Index'
+									});
+								} else {
+									uni.showModal({
+										content: '用户名密码输入错误,请核对'
+									});
+									_this.username = '';
+									_this.password = '';
+								}
+							},
+							fail: () => {
+								_this.tips = '网络错误,小程序端请检查合法域名';
+							},
+							
+							});
+					}
+				
+				
 			},
+			
 			login: function() {
 				let _this = this;
-				uni.request({
-					url: 'http://' + this.backStageIp + ':' + this.backStagePort + '/GyeeuserController/login?username=' + this.username +
-						'&password=' + this.password,
-					data: {},
-					method: 'GET',
-					success: function(res) {
-						//console.log(res.data);
-						_this.userid = res.data.data;
-
-
-						uni.setStorageSync('userid', _this.userid);
-						uni.setStorageSync('fingerPrintuserid', _this.userid);
-						//sessionStorage.setItem('userid',_this.userid);
-						if (res.data.code == 200) {
-
-							
-							_this.dataprocessing.viewUserid();
-							_this.dataprocessing.monitoringAuthority();
-							
-							// let plusDrawerList = uni.getStorageSync('plusList');
+				
+				if(this.username!="" && this.password!="")
+				{
+					uni.request({
+						url: 'http://' + this.backStageIp + ':' + this.backStagePort + '/GyeeuserController/login?username=' + this.username +
+							'&password=' + this.password,
+						data: {},
+						method: 'GET',
+						success: function(res) {
+							//console.log(res.data);
+							_this.userid = res.data.data;
+					
+					
+							uni.setStorageSync('userid', _this.userid);
+							uni.setStorageSync('fingerPrintuserid', _this.userid);
+							//sessionStorage.setItem('userid',_this.userid);
+							if (res.data.code == 200) {
+					
+								
+								_this.dataprocessing.viewUserid();
+								_this.dataprocessing.monitoringAuthority();
+								
+								// let plusDrawerList = uni.getStorageSync('plusList');
+								
+								// _this.dataprocessing.putWindPowerStationId(plusDrawerList[0].windId);
+								// _this.dataprocessing.putWindPowerStationName(plusDrawerList[0].name);
+								
+								// if(_this.dataprocessing.getWindPowerStationId()=='')
+								// {
+								// 	//debugger
+								// 	_this.dataprocessing.putWindPowerStationId(_this.$store.state.default_wpid);
+								// }
+					
+								// if(_this.dataprocessing.getWindPowerStationName()=='')
+								// {
+								// 	//debugger
+								// 	_this.dataprocessing.putWindPowerStationName(_this.$store.state.default_wpname);
+								// }
+								_this.createUserOnline();
+								_this.setUsernamePassword();
+								_this.loginFalg = true;
+								_this.lastUserName = _this.username;
+								_this.lastPassWord = _this.password;
+								uni.switchTab({
+									url: '/pages/index/Index'
+								});
+							} else {
+								uni.showModal({
+									content: '用户名密码输入错误,请核对'
+								});
+								_this.username = '';
+								_this.password = '';
+							}
+						},
+						fail: () => {
+							_this.tips = '网络错误,小程序端请检查合法域名';
+						},
+					});
+				}else
+				{
+					uni.showToast({
+					    title: "用户名和密码不能为空!",
+					    icon: "none"
+					})
+				}
+				
+			
+			},
+			async createUserOnline() {
+				let _this = this;
+	
+				let userid=uni.getStorageSync('userid');
+				// 创建一个this.socketTask对象【发送、接收、关闭socket都由这个对象操作】
+				_this.socketTask_getUserList = uni.connectSocket({
+					// 【非常重要】必须确保你的服务器是成功的,如果是手机测试千万别使用ws://127.0.0.1:9099【特别容易犯的错误】
+					url: 'ws://' + _this.sisStageIp + ':' + _this.sisStagePort + '/websocket/pageNumber_4/functionNumber_5/'+userid,
+					success(data) {
+						console.log(data);
+					}
+				});
+				/* let windpowerstationid = uni.getStorageSync('windpowerstationName'); */
+				// 消息的发送和接收必须在正常连接打开中,才能发送或接收【否则会失败】
+				_this.socketTask_getUserList.onOpen(res => {
+					console.log('WebSocket连接正常打开中...!');
+					_this.is_open_socket = true;
+
+					// 注:只有连接正常打开中 ,才能正常收到消息
+					_this.socketTask_getUserList.onMessage(res => {
+						/* _this.windpowerstationdetail.getUserList = JSON.parse(res.data); */
+						_this.lastUserName = uni.getStorageSync('gyeeusername');
+						_this.userid = uni.getStorageSync('userid');
+						let templist=JSON.parse(res.data);
+						
+						if(templist!=null && templist!=undefined)
+						{
+							uni.showToast({
+							    title: "同名用户登录,当前用户下线!",
+							    icon: "none"
+							})
 							
-							// _this.dataprocessing.putWindPowerStationId(plusDrawerList[0].windId);
-							// _this.dataprocessing.putWindPowerStationName(plusDrawerList[0].name);
+				
 							
-							// if(_this.dataprocessing.getWindPowerStationId()=='')
-							// {
-							// 	//debugger
-							// 	_this.dataprocessing.putWindPowerStationId(_this.$store.state.default_wpid);
-							// }
-
-							// if(_this.dataprocessing.getWindPowerStationName()=='')
-							// {
-							// 	//debugger
-							// 	_this.dataprocessing.putWindPowerStationName(_this.$store.state.default_wpname);
-							// }
-							_this.setUsernamePassword();
-							_this.loginFalg = true;
-							_this.lastUserName = _this.username;
-							_this.lastPassWord = _this.password;
-							uni.switchTab({
-								url: '/pages/index/Index'
-							});
-						} else {
-							uni.showModal({
-								content: '用户名密码输入错误,请核对'
+							//plus.runtime.quit();
+							//#ifdef H5
+							_this.destroyUseWebViews();
+							uni.navigateTo({
+							    url: '/components/login/Login'
 							});
-							_this.username = '';
-							_this.password = '';
+							 //#endif
+							//#ifdef APP-PLUS
+							setTimeout(function() {
+							        plus.runtime.quit()
+							       }, 1000);//如果是首页的onload调用时需要延时一下,二级页面无需延时,可直接获取
+							 //#endif
 						}
-					},
-					fail: () => {
-						_this.tips = '网络错误,小程序端请检查合法域名';
-					}
+						//_this.userList = JSON.parse(res.data);
+						
+					});
 				});
 			},
 			checkIsSoterEnrolledInDeviceFingerPrint() {
@@ -337,6 +543,7 @@
 									//_this.setUsernamePassword();
 									//_this.loginFalg = true;
 									//_this.getUser()
+									_this.createUserOnline();
 									_this.getFingerPrintPassword();
 								} else {
 									uni.showToast({

+ 172 - 26
components/mine/addressBook/InitializeThe.vue

@@ -28,6 +28,12 @@
 
 		created() {
 			this.getUserList();
+			this.onlineMonitor();
+			let _this = this;
+			setInterval(function() {
+			        _this.onlineUserMap();
+			       }, 5000);//如果是首页的onload调用时需要延时一下,二级页面无需延时,可直接获取
+			
 		},
 		computed: {
 			sisStageIp: function() {
@@ -47,20 +53,25 @@
 			},
 		},
 		methods: {
-	
+			
+			destroyUseWebViews() {
+				wv=null;
+			
+			},
 			getUserList() {
 
 				let im_show =uni.getStorageSync('im_show');
-				if (im_show != "1") {
+				if (im_show == "1") {
 					this.lastUserName = uni.getStorageSync('gyeeusername');
 					this.userid = uni.getStorageSync('userid');
 
 					let _this = this;
 					uni.request({
-						url: 'http://' + this.sisStageIp + ':' + this.sisStagePort + '/GyeeuserController/selectUserList',
+						url: 'http://' + _this.sisStageIp + ':' + _this.sisStagePort + '/GyeeuserController/selectUserList',
 						data: {},
 						method: 'GET',
 						success: function(res) {
+							//#ifdef APP-PLUS
 							_this.userList = [];
 
 							for (var i = 0; i < res.data.length; i++) {
@@ -78,22 +89,23 @@
 									let url = "https://" + _this.backStageIp + ":" + _this.backStagePort + "/websocket/usercontroller/view?send=" +
 										_this.userid + "&receive=" + res.data[i].id + "&sendname=" + _this.lastUserName + "&receivename=" + res.data[
 											i].nickname;
+											
 									webView.loadURL(url)
 									var currentWebview = page.$getAppWebview(); //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效,非v3编译模式使用this.$mp.page.$getAppWebview()
 									currentWebview.append(webView); //一定要append到当前的页面里!!!才能跟随当前页面一起做动画,一起关闭
 									//wv.setStyle({top:70,height:height});
 									
-									 setTimeout(function() {
+									  setTimeout(function() {
 									          
-									        }, 1000);//如果是首页的onload调用时需要延时一下,二级页面无需延时,可直接获取
+									         }, 1000);//如果是首页的onload调用时需要延时一下,二级页面无需延时,可直接获取
 									webView.hide();
 
 									wv.push(webView)
-
+									
 								}
-
+							
 							};
-
+							//#endif
 
 						},
 						fail: () => {
@@ -101,10 +113,11 @@
 						},
 					});
 					
-					 uni.setStorageSync('im_show','1');
+					 uni.setStorageSync('im_show','0');
 					
 				}else
 				{
+					//#ifdef APP-PLUS
 					var pages = getCurrentPages();
 					var page = pages[pages.length - 1];
 					var currentWebview = page.$getAppWebview(); //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效,非v3编译模式使用this.$mp.page.$getAppWebview()
@@ -113,13 +126,161 @@
 						
 						let webView = wv[i];
 						
+						
 						currentWebview.append(webView); //一定要append到当前的页面里!!!才能跟随当前页面一起做动画,一起关闭
 						
 					}
+					//#endif
 				}
 
 
 			},
+			async onlineUserMap() {
+
+
+			// 		let _this = this;
+			// 		let url='https://' + _this.backStageIp + ':' + _this.backStagePort + '/websocket/usercontroller/onlineUserList';
+			// 		uni.request({
+			// 			url: url,
+			// 			data: {},
+			// 			method: 'GET',
+			// 			sslVerify: false,
+			// 			success: function(res) {
+			
+			// 			_this.userid = uni.getStorageSync('userid');
+						
+
+						
+			// 			let onlineList=[];
+						
+			// 				for (var i = 0; i < res.data.length; i++) {
+								
+			// 					if(res.data[i].id==_this.userid)
+			// 					{
+			// 						onlineList=res.data[i].userlist;
+			// 						break;
+			// 					}
+			// 				}
+						
+			// 				var pages = getCurrentPages();
+			// 				var page = pages[pages.length - 1];
+			// 				var currentWebview = page.$getAppWebview(); //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效,非v3编译模式使用this.$mp.page.$getAppWebview()
+							
+			// 				for (var i = 0; i < wv.length; i++) {
+								
+			// 					let status=true;
+								
+			// 					if(onlineList.length==0)
+			// 					{
+			// 						status=false;
+			// 					}else{
+			// 						for (var j = 0; j < onlineList.length; j++) {
+										
+			// 							if (wv[i].id == "webview" + onlineList[j]) {
+			// 								status=false;
+			// 								break;
+			// 							}
+			// 						}
+			// 					}
+					
+								
+			// 					if(status)
+			// 					{
+			// 						let url=wv[i].getURL();
+			// 						wv[i].loadURL(url);
+			// 					}
+								
+			// 				}
+							
+
+			// 			},
+			// 			fail: function(res) {
+			// 				_this.tips = '网络错误,小程序端请检查合法域名';
+			// 			},
+			// 		});
+					
+			// 		 uni.setStorageSync('im_show','0');
+					
+			},
+			async onlineMonitor() {
+				
+				// let im_monitor =uni.getStorageSync('im_monitor');
+				// if (im_monitor == "1") {
+				
+				// 	let _this = this;
+				// 	// 创建一个this.socketTask对象【发送、接收、关闭socket都由这个对象操作】
+				// 	this.socketTask_getUserList = uni.connectSocket({
+				// 		// 【非常重要】必须确保你的服务器是成功的,如果是手机测试千万别使用ws://127.0.0.1:9099【特别容易犯的错误】
+				// 		url: 'ws://' + this.sisStageIp + ':' + this.sisStagePort + '/websocket/pageNumber_4/functionNumber_4/all',
+				// 		success(data) {
+				// 			console.log(data);
+				// 		}
+				// 	});
+				// 	// 消息的发送和接收必须在正常连接打开中,才能发送或接收【否则会失败】
+				// 	this.socketTask_getUserList.onOpen(res => {
+				// 		console.log('WebSocket连接正常打开中...!');
+				// 		this.is_open_socket = true;
+								
+				// 		// 注:只有连接正常打开中 ,才能正常收到消息
+				// 		this.socketTask_getUserList.onMessage(res => {
+				// 			/* _this.windpowerstationdetail.getUserList = JSON.parse(res.data); */
+							
+				// 			_this.userid = uni.getStorageSync('userid');
+							
+				// 			let obj=JSON.parse(res.data);
+							
+				// 			let onlineList=[];
+							
+				// 				for (var i = 0; i < obj.length; i++) {
+									
+				// 					if(obj[i].id==_this.userid)
+				// 					{
+				// 						onlineList=obj[i].userlist;
+				// 						break;
+				// 					}
+				// 				}
+							
+				// 				var pages = getCurrentPages();
+				// 				var page = pages[pages.length - 1];
+				// 				var currentWebview = page.$getAppWebview(); //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效,非v3编译模式使用this.$mp.page.$getAppWebview()
+								
+				// 				for (var i = 0; i < wv.length; i++) {
+									
+				// 					let status=true;
+									
+				// 					if(onlineList.length==0)
+				// 					{
+				// 						status=false;
+				// 					}else{
+				// 						for (var j = 0; j < onlineList.length; j++) {
+											
+				// 							if (wv[i].id == "webview" + onlineList[j]) {
+				// 								status=false;
+				// 								break;
+				// 							}
+				// 						}
+				// 					}
+						
+									
+				// 					if(status)
+				// 					{
+				// 						let url=wv[i].getURL();
+				// 						wv[i].loadURL(url);
+				// 					}
+									
+				// 				}
+								
+							
+				// 			//_this.userList = JSON.parse(res.data);
+							
+				// 		});
+				// 	});
+					
+				// 	uni.setStorageSync('im_monitor',0);
+					
+				// }
+				
+			},
 			childMethod(id, bool, state) {
 				console.log(id);
 				this.identify = id;
@@ -130,22 +291,6 @@
 					if (wv[i].id == "webview" + id) {
 
 						webview = wv[i];
-						let url = webview.getURL();
-						if (bool != null) {
-							if (bool == 1) {
-
-								if (url.indexOf("/view?") < 0) {
-									url = url.replace("/viewoffline?", "/view?");
-									webview.loadURL(url);
-								}
-							} else {
-								if (url.indexOf("/viewoffline?") < 0) {
-									url = url.replace("/view?", "/viewoffline?");
-									webview.loadURL(url);
-								}
-							}
-						}
-
 
 						if (state == 1) {
 
@@ -157,7 +302,8 @@
 					}
 				}
 
-			}
+			},
+			
 
 		}
 	}

+ 2 - 2
components/mine/addressBook/addressBook.vue

@@ -33,7 +33,7 @@
 
 		<!-- 返回组件 -->
 		 <view @click="changeState()">    
-		<cu-custom bgColor="bg-gradual-sisBlack" :isBack="true"   v-show="but2" >
+		<cu-custom bgColor="bg-gradual-sisBlack" :isBack="false"   v-show="but2" >
 			<block slot="backText">
 				<view style="height: 80rpx;line-height: 80rpx;color: silver;">返回</view>
 			</block>
@@ -260,7 +260,7 @@
 		},
 		created: function() {
 			
-			this.getUserList();
+			//this.getUserList();
 			this.drawerList = uni.getStorageSync('leftlist5');
 			
 			/* this.pinyin(); */

+ 3 - 1
pages/index/Index.vue

@@ -580,7 +580,9 @@ export default {
 		};
 	},
 	created: function() {
-		uni.setStorageSync('im_show','0');
+		uni.setStorageSync('im_show','1');
+		uni.setStorageSync('im_monitor','1');
+		
 		this.play();
 		this.timeNow();
 		this.$nextTick(function() {

+ 1 - 1
pages/mine/Mine.vue

@@ -52,7 +52,7 @@
 			}
 		},
 		created: function() {
-		 uni.setStorageSync('im_show','1');
+		 //uni.setStorageSync('im_show','1');
 		},
 		onShow() {