Harley 6 lat temu
rodzic
commit
e32bd74431

+ 7 - 1
service/src/App.vue

@@ -74,7 +74,12 @@
 			websocketonmessage(e){
 				this.heatBeat();//收到消息会刷新心跳检测,如果一直收到消息,就推迟心跳发送
 				const redata = JSON.parse(e.data);//接收数据源
-				if(redata.type != "pong"){
+				//
+				if(redata.message_type == "ping"){
+					this.websock.send('{"type":"pong"}')
+					return false;
+				}
+				if(redata.type != "pong" || redata.message_type != "ping"){
 					console.log(redata);
 				}
 				let  getters = this.$store.getters;
@@ -215,6 +220,7 @@
 			init(){
 				this.$store.dispatch("SET_STATEVALUE",'在线');
 				this.$store.dispatch("SET_SESSION",[]);
+				this.$store.dispatch("SET_USER",'');
 				this.$store.dispatch("SET_OFFLINE",[]);
 				this.$store.dispatch("SET_SESSION",[]);//会话列表
 				this.$store.dispatch("SET_OFFLINE",[]);//离线列表

+ 1 - 0
service/src/components/hader.vue

@@ -98,6 +98,7 @@
 			isExit() {
 				this.$store.dispatch("SET_STATEVALUE", '在线');
 				this.$store.dispatch("SET_SESSION",[]);//会话列表
+				this.$store.dispatch("SET_USER",'');//用户退出
 				this.$store.dispatch("SET_OFFLINE",[]);//离线列表
 		  		this.$store.dispatch("SET_TYPE",1);//选择类型(会话/离线)
 				this.$store.dispatch("SET_NUM",0);//列表下标

+ 28 - 22
service/src/pages/LeaveMessage.vue

@@ -117,7 +117,7 @@
 										<el-upload style="margin:10px;"
 												   action="/api/index/upload/uploadImg"
 												   :before-upload="beforeAvatarUpload"
-												   :on-progress="onProgress"
+												   
 												   :on-change='uploadChange'
 												   :on-success='uploadSuccess'
 												   :on-error="uploadError"
@@ -220,8 +220,8 @@
 				getUserItem: [],
 				img_http: 'http://kfadmin.bocai186.com',//图片路径域
 				// img_http: 'http://192.168.2.187:8090',//图片路径域
-
 				uploadImg:[],
+				imgUrl:'',
 				users:[]
 			};
 		},
@@ -282,9 +282,11 @@
 			},
 			// 上传成功时的回调
 			uploadSuccess(res, file, fileList) {
-				console.log(res)
-				console.log(file)
-				console.log(fileList)
+				console.log(res.data.src)
+				this.imgUrl = this.imgUrl ? this.imgUrl + "," + res.data.src :res.data.src;
+				console.log(this.imgUrl)
+
+				
 
 			},
 			// 发送中
@@ -295,32 +297,36 @@
 			uploadError() {
 				this.$message.error('上传失败,请重新上传')
 			},
-			handleRemove(res, file, fileList) {
-				this.uploadImg = []
-				fileList.forEach((res,index) => {
-				  this.uploadImg.push(URL.createObjectURL(res.raw))
-				});
+			//删除回掉
+			handleRemove(file, fileList,) {
+				this.uploadImg = fileList
 			},
 			// 每次改变图片状态返回的回调
 			uploadChange(file, fileList) {
-				this.uploadImg.push(file.raw);
+				console.log(file, fileList)
+
+				// this.uploadImg.push(file);
 			},
 			handleExceed(files, fileList) {
 				this.$message.error(`图片上传数量最多4张`);
 			},
 			sendMessage() {
-				console.log(this.uploadImg,"上传的图片")
+				console.log(this.uploadImg);
 				this.$refs.upload.submit();
-				// let parmas = {
-				// 	"user_id":this.users.id,
-				// 	"message_id":this.uid,
-				// 	"reply_content":this.leaveInfor,
-				// 	"images":this.uploadImg,
-				// }
-				// this.post('/api/service/Message/dealmessage', parmas).then(res => {
-				// 	console.log(res);
-				// 	this.$message.success(res.data.msg);
-				// })
+
+				setTimeout(()=>{
+					console.log(this.imgUrl,"上传的图片")
+					let parmas = {
+						"user_id":this.users.id,
+						"message_id":this.uid,
+						"reply_content":this.leaveInfor,
+						"images":this.imgUrl,
+					}
+					this.post('/api/service/Message/dealmessage', parmas).then(res => {
+						console.log(res);
+						this.$message.success(res.data.msg);
+					})
+				},1500)
 			},
 
 			/*****************获取当前聊天用户信息****************/