Browse Source

修改通讯记录

shilin 4 years ago
parent
commit
6116cf68ca

+ 93 - 73
components/mine/addressBook/InitializeThe.vue

@@ -1,35 +1,26 @@
 <template>
 	<view>
-		<view v-for="item in userListshow"   >
-		     <web-view :src="go(item.id,item.nickname)"  v-if="item.state" :key="item.id"  ></web-view>
-		</view>
-		  <view v-for="item in userList"   >
-			  
-			   <web-view :src="go(item.id,item.nickname)"  v-show="item.state" :key="item.id"  ></web-view>
-		  </view>
-		 
+
 	</view>
 </template>
 
 <script>
+	var wv = [];
 	export default {
 		data() {
 			return {
-				userList:[],
-				userListshow:[],
-				list:[],
-				lastUserName:'',
-				userid:'',
-				identify:'',
-				bool:'',
+				userList: [],
+				userListshow: [],
+				list: [],
+				lastUserName: '',
+				userid: '',
+				identify: '',
+				bool: '',
 			}
 		},
-		created(){
-		   this.getUserList();
-		},
-		onUnload() {
-			
-			this.userList=[];
+
+		created() {
+			this.getUserList();
 		},
 		computed: {
 			sisStageIp: function() {
@@ -47,35 +38,9 @@
 			windpowerstationNameToId: function() {
 				return this.$store.state.windpowerstationNameToId;
 			},
-			},
+		},
 		methods: {
-			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;
-				// }
-			
-					if (_this.identify == id && _this.bool == 0) {
-						return "https://" + _this.backStageIp + ":" + _this.backStagePort + "/websocket/usercontroller/viewoffline?send=" + _this
-							.userid + "&receive=" + id + "&sendname=" + _this.lastUserName + "&receivename=" + nickname  ;
-					} else {
-						return "https://" + _this.backStageIp + ":" + _this.backStagePort + "/websocket/usercontroller/view?send=" +
-							_this.userid + "&receive=" + id + "&sendname=" + _this.lastUserName + "&receivename=" + nickname ;
-					}
-					
-	
-						
-			},
+		
 			getUserList() {
 				this.lastUserName = uni.getStorageSync('gyeeusername');
 				this.userid = uni.getStorageSync('userid');
@@ -86,42 +51,97 @@
 					data: {},
 					method: 'GET',
 					success: function(res) {
-						_this.userList=[];
-						_this.userListshow=[];
+						_this.userList = [];
+
 						for (var i = 0; i < res.data.length; i++) {
-							
-							if(res.data[i].id!=_this.userid)
-							{
-								if (_this.identify == res.data[i].id && _this.bool == 1) {
-									res.data[i].state = true;
-									_this.userListshow.push(res.data[i]);
-								}else
-								{
-									res.data[i].state = false;
-									_this.userList.push(res.data[i]);
+
+							if (res.data[i].id != _this.userid) {
+
+								var pages = getCurrentPages();
+								var page = pages[pages.length - 1];
+								let webView = plus.webview.create("", "webview"+res.data[i].id, {
+									plusrequire: "none", //禁止远程网页使用plus的API,有些使用mui制作的网页可能会监听plus.key,造成关闭页面混乱,可以通过这种方式禁止
+									'uni-app': 'none', //不加载uni-app渲染层框架,避免样式冲突
+									top: uni.getSystemInfoSync().statusBarHeight + 44 //放置在titleNView下方。如果还想在webview上方加个地址栏的什么的,可以继续降低TOP值
+								})
+
+								let url = '';
+								if (_this.identify == res.data[i].id && _this.bool == 0) {
+									url = "https://" + _this.backStageIp + ":" + _this.backStagePort +
+										"/websocket/usercontroller/viewoffline?send=" + _this
+										.userid + "&receive=" + res.data[i].id + "&sendname=" + _this.lastUserName + "&receivename=" + res.data[i].nickName;
+								} else {
+									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});
+								webView.hide();
+								
+								wv.push(webView)
+
 							}
-							
-						
-					};
-						
-				
+
+						};
+
+
 					},
 					fail: () => {
 						_this.tips = '网络错误,小程序端请检查合法域名';
 					},
 				});
-				
+
 			},
-			childMethod(id,bool){
+			childMethod(id, bool,state) {
 				console.log(id);
-				this.identify=id;
+				this.identify = id;
 				this.bool = bool;
-				this.getUserList();
+				//this.getUserList();
+				let webview;
+				for (var i = 0; i < wv.length; i++) {
+					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)
+						{
+	
+							webview.show()
+						}else
+						{
+							webview.hide();
+						}
+						break;
+					}
+				}
+								
 			}
-			
-			
+
+
 		}
 	}
 </script>

+ 30 - 15
components/mine/addressBook/addressBook.vue

@@ -33,7 +33,7 @@
 
 		<!-- 返回组件 -->
 		 <view @click="changeState()">    
-		<cu-custom bgColor="bg-gradual-sisBlack" :isBack="false"  v-show="but2" >
+		<cu-custom bgColor="bg-gradual-sisBlack" :isBack="true"   v-show="but2" >
 			<block slot="backText">
 				<view style="height: 80rpx;line-height: 80rpx;color: silver;">返回</view>
 			</block>
@@ -54,20 +54,18 @@
 
 		<scroll-view @tap="" scroll-y class="DrawerPage" :class="modalName == 'viewModal' ? 'show' : ''">
 
-
-			`
 			<view v-if="judge==1">
 
 
 				<!-- 搜索标签 -->
 				<view class="cu-bar bg-white search" style="z-index: 999999;">
 					<!-- :style="[{top:CustomBar + 'px'}]" -->
-					<view class="search-form round" @touchstart="accordingTo">
+					<view class="search-form round"  @touchstart="accordingTo">
 						<text class="cuIcon-search"></text>
-						<input type="text" placeholder="输入搜索的关键词" confirm-type="search" v-model="search"></input>
+						<input type="text" placeholder="输入搜索的关键词"  confirm-type="search" v-model="search"></input>
 					</view>
-					<view class="action">
-						<button class="cu-btn bg-gradual-sisBlack shadow-blur round" @click="accordingOut">取消</button>
+					<view class="action" >
+						<button class="cu-btn bg-gradual-sisBlack shadow-blur round" style="width:200upx;" @click="accordingOut">取消</button>
 					</view>
 				</view>
 				<!-- 搜索列表 -->
@@ -180,7 +178,9 @@
 			</view>
 
 		</scroll-view>
+		
 		<initial ref="initial"></initial>
+	
 	</view>
 </template>
 
@@ -194,6 +194,8 @@
 
 	import mine from '../../../components/mine/Mine.vue';
 	import chatindex from '../../../components/mine/chat/Chatindex.vue';
+	
+	var wv;
 	export default {
 		components: {
 			initial: initial,
@@ -251,6 +253,7 @@
 					time: '',
 					type: '',
 				},
+				webshowid:0,
 			};
 		},
 		created: function() {
@@ -328,6 +331,7 @@
 			initial() {
 				let userid = uni.getStorageSync('userid');
 				this.theLastStatement(userid);
+				
 			},
 			displayTheData(id) {
 				// this.theLastStatement(id);
@@ -353,11 +357,13 @@
 			},
 			changeState() {
 				console.log("更改状态")
+				this.child(this.webshowid,null,0);
 				this.but1 = true;
 				this.but2 = false;
 				this.judge = 1;
+				//wv.hide();
 				//this.$set(this.judge,judge,1);
-				//this.child('',1);
+				
 			},
 			showModal(e) {
 				this.modalName = e.currentTarget.dataset.target;
@@ -404,8 +410,8 @@
 				} */
 				this.but1 = false;
 				this.but2 = true;
-				this.child(id, bool);
-
+				this.child(id, bool,1);
+				
 				/*
 				 let _this=this;
 				 if(bool==0){
@@ -417,8 +423,9 @@
 				 }
 				 */
 			},
-			child(id,bool) {
-				///this.$refs.initial.childMethod(id,bool);
+			child(id,bool,state) {
+				this.$refs.initial.childMethod(id,bool,state);
+				this.webshowid=id;
 				this.judge = 0;
 			},
 			accordingOut() {
@@ -719,9 +726,7 @@
 	.DrawerPage .cu-bar.tabbar .action button.cuIcon {
 		width: 64upx;
 		height: 64upx;
-		line-height: 64upx;
-		margin: 0;
-		display: inline-block;
+
 	}
 
 	.DrawerPage .cu-bar.tabbar .action .cu-avatar {
@@ -753,4 +758,14 @@
 	.DrawerPage .cu-bar.tabbar .action {
 		flex: initial;
 	}
+	
+		.display-block {
+			display: block;
+			z-index: 99999;
+		}
+	
+		.display-none {
+			display: none;
+			z-index: -1;
+		}
 </style>