Browse Source

通讯录组件

zhaomiao 4 years ago
parent
commit
158ab14296

+ 4 - 0
common/store.js

@@ -7,6 +7,10 @@ const store = new Vuex.Store({
     state: {
 		wholeSituationBackStageIp:'117.78.18.24',//117.78.18.24
 		wholeSituationBackStagePort:'9988',
+		
+		GlobalLocalIp:'192.168.1.102',//192.168.1.102
+		GlobalLocalPort:'4397',
+		
 		windpowerstationNameToId:{},
 		
 		default_wpid:'0',	

+ 58 - 30
components/mine/addressBook/InitializeThe.vue

@@ -1,6 +1,9 @@
 <template>
 	<view>
-		 <!-- <web-view :webview-styles="" :src=""></web-view> -->
+		  <view v-for="item in userList"  v-if="judge(item.id)" >
+			  
+		       <web-view :src="go(item.id,item.nickname)" v-bind:id="item.id"  >{{item.id}}</web-view>
+		  </view>
 	</view>
 </template>
 
@@ -16,46 +19,71 @@
 					username:'',
 					remak2:'', */
 				},
-				userid:'',
 				list:[],
+				lastUserName:'',
+				userid:'',
+				identify:'',
+				bool:'',
 			}
 		},
 		onLoad() {
 			this.getUserList();
 		},
+		computed: {
+			backStageIp: function() {
+				return this.$store.state.GlobalLocalIp;
+			},
+			backStagePort: function() {
+				return this.$store.state.GlobalLocalPort;
+			},
+			windpowerstationNameToId: function() {
+				return this.$store.state.windpowerstationNameToId;
+			},
+			},
 		methods: {
-			async getUserList() {
+			judge(id){
+				if(id==this.identify){
+					return true;
+				}
+				else{
+					return false;
+				}
+			},
+			go(id,nickname){
+				let _this=this;
+				if(_this.bool == 1){
+					 return "https://"+_this.backStageIp+":"+_this.backStagePort+"/websocket/usercontroller/view?send="+_this.userid+"&receive="+id+"&sendname="+_this.lastUserName+"&receivename="+nickname;
+				}else{
+					 return "https://"+ _this.backStageIp+":"+_this.backStagePort+"/websocket/usercontroller/viewoffline?send="+_this.userid+"&receive="+id+"&sendname="+_this.lastUserName+"&receivename="+nickname;
+				}
+			},
+			getUserList() {
+				this.lastUserName = uni.getStorageSync('gyeeusername');
+				this.userid = uni.getStorageSync('userid');
+
 				let _this = this;
-				// 创建一个this.socketTask对象【发送、接收、关闭socket都由这个对象操作】
-				this.socketTask_getUserList = uni.connectSocket({
-					// 【非常重要】必须确保你的服务器是成功的,如果是手机测试千万别使用ws://127.0.0.1:9099【特别容易犯的错误】
-					url: 'ws://117.78.18.24:9988/websocket/pageNumber_4/functionNumber_3/all',
-					success(data) {
-						console.log(data);
-					}
-				});
-				/* let windpowerstationid = uni.getStorageSync('windpowerstationName'); */
-				// 消息的发送和接收必须在正常连接打开中,才能发送或接收【否则会失败】
-				this.socketTask_getUserList.onOpen(res => {
-					console.log('WebSocket连接正常打开中...!');
-					this.is_open_socket = true;
+				uni.request({
+					url: 'http://' + this.backStageIp + ':' + this.backStagePort + '/GyeeuserController/selectUserList',
+					data: {},
+					method: 'GET',
+					success: function(res) {
+						_this.userList =res.data;
+						
 				
-					// 注:只有连接正常打开中 ,才能正常收到消息
-					this.socketTask_getUserList.onMessage(res => {/* 
-						console.log("收到服务器内容:" + res.data); */
-						/* _this.windpowerstationdetail.getUserList = JSON.parse(res.data); */
-						_this.userList = JSON.parse(res.data);
-						_this.userid = uni.getStorageSync('userid');
-						let list = [{}];
-						for(let i =0;i<_this.userList.length;i++){
-							list[i] = {};
-							list[i].id =_this.userList[i].id+'-'+_this.userid;
-						}
-						_this.list = list;
-						console.log(list);
-					});
+					},
+					fail: () => {
+						_this.tips = '网络错误,小程序端请检查合法域名';
+					},
 				});
+				
 			},
+			childMethod(id,bool){
+				console.log(id);
+				this.identify=id;
+				this.bool = bool;
+				this.getUserList();
+			}
+			
 			
 		}
 	}

+ 25 - 5
components/mine/addressBook/addressBook.vue

@@ -122,12 +122,17 @@
 		<view v-show="!hidden" class="indexToast">
 			<!-- {{listCur}} -->
 		</view>
+		<initial ref="initial"></initial>
 	</view>
 </template>
 
 <script>
 	import pinyin from './index.js';
+	import initial  from './InitializeThe.vue';
 	export default {
+		components: {
+			initial: initial
+		},
 		data() {
 			return {
 				userid:'',
@@ -217,15 +222,30 @@
 		  },
 		methods: {
 			go(userid,lastUserName,nickname,id,bool){
+				
 				let _this=this;
-				if(bool==0){
-					/* console.log("https://192.168.1.102:4397/websocket/usercontroller/viewoffline?send="+userid+"&receive="+id+"&sendname="+lastUserName+"&receivename="+nickname); */
+				
+				/* if(bool==0){
+					
 					 window.location.href="https://192.168.1.102:4397/websocket/usercontroller/viewoffline?send="+userid+"&receive="+id+"&sendname="+lastUserName+"&receivename="+nickname;
 				}
 				if(bool==1){
 					 window.location.href="https://192.168.1.102:4397/websocket/usercontroller/view?send="+userid+"&receive="+id+"&sendname="+lastUserName+"&receivename="+nickname;
-				}
-				/* */
+				} */
+				this.child(id,bool);
+				/*
+				 let _this=this;
+				 if(bool==0){
+				 	
+				 	 window.location.href="https://192.168.1.102:4397/websocket/usercontroller/viewoffline?send="+userid+"&receive="+id+"&sendname="+lastUserName+"&receivename="+nickname;
+				 }
+				 if(bool==1){
+				 	 window.location.href="https://192.168.1.102:4397/websocket/usercontroller/view?send="+userid+"&receive="+id+"&sendname="+lastUserName+"&receivename="+nickname;
+				 }
+				 */
+			},
+			child(id){
+				this.$refs.initial.childMethod(id);
 			},
 			accordingOut(){
 				this.play=true;
@@ -255,7 +275,7 @@
 				// 创建一个this.socketTask对象【发送、接收、关闭socket都由这个对象操作】
 				this.socketTask_getUserList = uni.connectSocket({
 					// 【非常重要】必须确保你的服务器是成功的,如果是手机测试千万别使用ws://127.0.0.1:9099【特别容易犯的错误】
-					url: 'ws://117.78.18.24:9988/websocket/pageNumber_4/functionNumber_3/all',
+					url: 'ws://' + this.backStageIp + ':' + this.backStagePort + '/websocket/pageNumber_4/functionNumber_3/all',
 					success(data) {
 						console.log(data);
 					}