Browse Source

通讯录最后一条记录

zhaomiao 4 years ago
parent
commit
75a4e61270
1 changed files with 89 additions and 25 deletions
  1. 89 25
      components/mine/addressBook/addressBook.vue

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

@@ -1,6 +1,6 @@
 <template>
-	<view>
-		<cu-custom bgColor="bg-blacks" :isBack="false">
+	<view  >
+		<cu-custom bgColor="bg-blacks" :isBack="false" v-show="but1">
 		    <block slot="right">
 				<image src="../../../static/picture/fourLine.png" style="width: 30px;height: 30px;margin-left: 2%;" @tap="openDrawer"></image>
 			</block>
@@ -20,6 +20,8 @@
 			</block>
 		</cu-custom>
 		
+		
+		
 		<!-- 抽屉组件 -->
 				<div>
 					<drawer ref="drawer"></drawer>
@@ -29,23 +31,36 @@
 				</div>
 		<!-- 组件左右移动 -->
 		
-		<scroll-view @tap="hideModal" scroll-y class="DrawerPage" :class="modalName == 'viewModal' ? 'show' : ''">
-		<!-- <view @tap="closeFrame">
-			<cu-custom bgColor="bg-gradual-sisBlack" :isBack="true">
-				<block slot="backText">
-					<view style="height: 80rpx;line-height: 80rpx;color: silver;">返回</view>
-				</block>
-				<block slot="content">
-					<view style="color: silver;">聊天通讯</view>
-				</block>
-			</cu-custom>
+		<!-- 返回组件 -->
+		<!-- <view> @tap="common.navTo('/components/mine/addressBook/addressBook')"   @click="changeState()"
+		<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>
+			<block slot="content">
+				<view style="color: silver;">聊天通讯</view>
+			</block>
+		</cu-custom>
 		</view> -->
+		<view class="cu-bar bg-white" v-show="but2" style="z-index: 9999;" @tap="common.navTo('/components/mine/addressBook/addressBook')" >
+			<view class="action">
+				<text class="cuIcon-back text-white" style="font-size: 15px;" ></text> 
+				<text style="    color: silver;">返回</text>
+			</view>
+			<view class="content text-white">
+				通讯录
+			</view>
+		</view>
+		
+		<scroll-view @tap="" scroll-y class="DrawerPage" :class="modalName == 'viewModal' ? 'show' : ''">
+			
+		
 		`
 		<view v-show="judge">
 		
 		
 		<!-- 搜索标签 -->
-		<view class="cu-bar bg-white search">  <!-- :style="[{top:CustomBar + 'px'}]" -->
+		<view class="cu-bar bg-white search" style="z-index: 999999;">  <!-- :style="[{top:CustomBar + 'px'}]" -->
 			<view class="search-form round" @touchstart="accordingTo">
 				<text class="cuIcon-search"></text>
 				<input type="text" placeholder="输入搜索的关键词" confirm-type="search" v-model="search"></input>
@@ -66,8 +81,8 @@
 									<view v-if="item.remak1==1">
 									<view class="content" @click="go(userid,lastUserName,items.nickname,items.id,1)">
 										<view class="text-grey">{{item.username}}({{item.remak2}})<!-- <text class="text-abc">{{items.name}}</text>君 --></view>
-										<view class="text-gray text-sm">
-											有条消息
+										<view class="text-gray text-sm" v-text="displayTheData(item.id)">
+											
 										</view>
 									</view>
 									<!-- 在线离线标识 -->
@@ -77,8 +92,8 @@
 									<view v-if="item.remak1==0">
 										<view class="content" @click="go(userid,lastUserName,item.nickname,item.id,0)">
 											<view class="text-grey">{{item.username}}({{item.remak2}})<!-- <text class="text-abc">{{items.name}}</text>君 --></view>
-											<view class="text-gray text-sm">
-												有条消息
+											<view class="text-gray text-sm" v-text="displayTheData(item.id)" >
+												
 											</view>
 										</view>
 										
@@ -118,8 +133,8 @@
 							<view v-if="items.remak1==1">
 							<view class="content" @click="go(userid,lastUserName,items.nickname,items.id,1)">
 								<view class="text-grey">{{items.username}}({{items.remak2}})<!-- <text class="text-abc">{{items.name}}</text>君 --></view>
-								<view class="text-gray text-sm">
-									有{{items.remak1}}条消息
+								<view class="text-gray text-sm" v-text="displayTheData(items.id)">
+									
 								</view>
 							</view>
 							<!-- 在线标识 -->
@@ -129,8 +144,8 @@
 							<view v-if="items.remak1==0">
 							<view class="content" @click="go(userid,lastUserName,items.nickname,items.id,0)">
 								<view class="text-grey">{{items.username}}({{items.remak2}})<!-- <text class="text-abc">{{items.name}}</text>君 --></view>
-								<view class="text-gray text-sm">
-									有{{items.remak1}}条消息
+								<view class="text-gray text-sm"  v-text="displayTheData(items.id)">
+									
 								</view>
 							</view>
 							<!-- 离线标识 -->
@@ -180,6 +195,9 @@
 		},
 		data() {
 			return {
+				content1:'',
+				but1:true,
+				but2:false,
 				userid:'',
 				lastUserName:'',
 				StatusBar: this.StatusBar,
@@ -242,6 +260,13 @@
 					}
 				],
 				judge:true,
+				LastStatement:{
+					content:'',
+					receive:'',
+					send:'',
+					time:'',
+					type:'',
+				},
 			};
 		},
 		created: function() {
@@ -278,12 +303,18 @@
 			this.pinyin(); */
 		},
 		computed: {
-			backStageIp: function() {
+			sisStageIp: function() {
 				return this.$store.state.wholeSituationBackStageIp;
 			},
-			backStagePort: function() {
+			sisStagePort: function() {
 				return this.$store.state.wholeSituationBackStagePort;
 			},
+			backStageIp: function() {
+				return this.$store.state.GlobalLocalIp;
+			},
+			backStagePort: function() {
+				return this.$store.state.GlobalLocalPort;
+			},
 			windpowerstationNameToId: function() {
 				return this.$store.state.windpowerstationNameToId;
 			},
@@ -307,6 +338,21 @@
 		    }
 		  },
 		methods: {
+			displayTheData(id){
+				this.theLastStatement(id);
+				console.log(this.LastStatement);
+				if(this.LastStatement[0].type=="pic"){
+					return "[图片]";
+				}else{
+					return this.LastStatement[0].content;
+				}
+			},
+			changeState(){
+				console.log("更改状态")
+				this.but1=true;
+				this.but2=false;
+				this.judge = true;
+			},
 			showModal(e) {
 				this.modalName = e.currentTarget.dataset.target;
 				this.$refs.plusDrawer.showModal(this.plusDrawerList, this.modalName);
@@ -350,7 +396,10 @@
 				if(bool==1){
 					 window.location.href="https://192.168.1.102:4397/websocket/usercontroller/view?send="+userid+"&receive="+id+"&sendname="+lastUserName+"&receivename="+nickname;
 				} */
+				this.but1=false;
+				this.but2=true;
 				this.child(id,bool);
+				
 				/*
 				 let _this=this;
 				 if(bool==0){
@@ -394,7 +443,7 @@
 				// 创建一个this.socketTask对象【发送、接收、关闭socket都由这个对象操作】
 				this.socketTask_getUserList = uni.connectSocket({
 					// 【非常重要】必须确保你的服务器是成功的,如果是手机测试千万别使用ws://127.0.0.1:9099【特别容易犯的错误】
-					url: 'ws://' + this.backStageIp + ':' + this.backStagePort + '/websocket/pageNumber_4/functionNumber_3/all',
+					url: 'ws://' + this.sisStageIp + ':' + this.sisStagePort + '/websocket/pageNumber_4/functionNumber_3/all',
 					success(data) {
 						console.log(data);
 					}
@@ -407,7 +456,6 @@
 				
 					// 注:只有连接正常打开中 ,才能正常收到消息
 					this.socketTask_getUserList.onMessage(res => {
-						console.log("收到服务器内容:" + res.data);
 						/* _this.windpowerstationdetail.getUserList = JSON.parse(res.data); */
 						_this.userList = JSON.parse(res.data);
 						_this.lastUserName = uni.getStorageSync('gyeeusername');
@@ -415,6 +463,22 @@
 					});
 				});
 			},
+			//获取最后一条语句  '/websocket/chatDetailController/selectLastInfoByUserId?userid='+id
+			async theLastStatement(id) {
+				let _this = this;
+				uni.request({
+					url: 'http://' + this.sisStageIp + ':' + this.sisStagePort + '/chatDetailController/selectLastInfoByUserId?userid='+id,
+					data: {},
+					method: 'GET',
+					success: function(res) {
+						 _this.LastStatement =res.data;
+					},
+					fail: () => {
+						_this.tips = '网络错误,小程序端请检查合法域名';
+					},
+				});
+				
+			},
 			//获取文字信息
 			getCur(e) {
 				this.hidden = false;