Browse Source

update service

luke 6 năm trước cách đây
mục cha
commit
ec50e4f6bf
2 tập tin đã thay đổi với 48 bổ sung35 xóa
  1. 18 5
      service/src/App.vue
  2. 30 30
      service/src/pages/LeaveMessage.vue

+ 18 - 5
service/src/App.vue

@@ -16,7 +16,7 @@
 			return{
 				reconnectData:null,
 				lockReconnect:false,    //避免重复连接,因为onerror之后会立即触发 onclose
-				timeout:10000,          //10s一次心跳检测
+				timeout:5000,          //10s一次心跳检测
 				timeoutObj:null,
 				serverTimeoutObj:null,
 				apiToken:'',
@@ -44,6 +44,19 @@
 			//连接成功
 			websocketonopen() {
 				console.log('已经链接');
+				let user_info = this.$store.getters.get_user_info;
+				if(user_info){
+					this.$websocket.send(JSON.stringify({
+						type: 'init',
+						data: {
+							uid: 'KF' + user_info.id,
+							group: user_info.group_id,
+							token: user_info.token,
+							name: user_info.user_name,
+							avatar: user_info.user_avatar,
+						}
+					}));
+				}
 				this.$store.dispatch("SET_SOCKET_OPEN",true);//列表下标  
 				this.heatBeat();
 			},
@@ -182,7 +195,7 @@
 
 				//reLoginErr
 				if(redata.message_type == "reLoginErr"){
-					console.log('haha');
+					// console.log('haha');
 					this.init()
 				}
 
@@ -200,7 +213,7 @@
 			/******************************************/
 			//断开链接数据初始化
 			init(){
-				this.$store.dispatch("SET_STATEVALUE",'隐身');
+				this.$store.dispatch("SET_STATEVALUE",'在线');
 				this.$store.dispatch("SET_SESSION",[]);
 				this.$store.dispatch("SET_OFFLINE",[]);
 				this.$store.dispatch("SET_SESSION",[]);//会话列表
@@ -247,8 +260,8 @@
 					// console.log('发送',{type:'ping'});
 					this.$websocket.send(JSON.stringify({type:'ping'}))   //根据后台要求发送
 					this.serverTimeoutObj = setTimeout(()=> {
-						this.$websocket.close(); //如果  5秒之后我们没有收到 后台返回的心跳检测数据 断开socket,断开后会启动重连机制
-					}, 5000);
+						this.$websocket.close(); //如果4秒之后我们没有收到 后台返回的心跳检测数据 断开socket,断开后会启动重连机制
+					}, 4000);
 				}, this.timeout)
 			},
 

+ 30 - 30
service/src/pages/LeaveMessage.vue

@@ -220,6 +220,9 @@
 				getUserItem: [],
 				img_http: 'http://kfadmin.bocai186.com',//图片路径域
 				// img_http: 'http://192.168.2.187:8090',//图片路径域
+
+				uploadImg:[],
+				users:[]
 			};
 		},
 		components: {
@@ -232,6 +235,7 @@
 			this.frceArr = frce.frce;
 			this.value = this.options[2].value;
 			this.getSessionList(1)
+			this.get_vuex_info();
 		},
 		computed: {
 
@@ -265,7 +269,7 @@
 
 			// 上传之前
 			beforeAvatarUpload(file) {
-				console.log(file, '上传之前')
+				// console.log(file, '上传之前')
 				const isJPG = file.type == 'image/jpeg' || 'image/jpg' || 'image/png' || 'image/svg';
 				if (!isJPG) {
 					this.$message.error('上传只能是图片格式!');
@@ -288,8 +292,6 @@
 				this.$message.error('上传失败,请重新上传')
 			},
 			handleRemove(file, fileList) {
-				// console.log('123',fileList)
-				// 重置为空数组赋值
 				// this.uploadImg = []
 				// fileList.forEach((res,index) => {
 				//   this.uploadImg.push(URL.createObjectURL(res.raw))
@@ -298,14 +300,26 @@
 			},
 			// 每次改变图片状态返回的回调
 			uploadChange(file, fileList) {
-				if (fileList.length > 4) {
-					this.$message.error('上传图片最多4张')
-					return false
-				}
+
 			},
 			handleExceed(files, fileList) {
 				this.$message.error(`图片上传数量最多4张`);
 			},
+			sendMessage() {
+				this.$refs.upload.submit();
+				console.log(this.uploadImg, '图片');
+				let formData = new FormData();
+				formData.append("user_id",this.users.id);
+				formData.append("message_id", this.uid);
+				formData.append("reply_content", this.leaveInfor);
+				formData.append("images",this.uploadImg);
+
+				this.post('/api/service/Message/dealmessage', formData).then(res => {
+					console.log(res,'提交成功')
+					return false;
+				})
+			},
+
 			/*****************获取当前聊天用户信息****************/
 			get_user(id) {
 				let obj = {
@@ -318,34 +332,19 @@
 
 				this.post('api' + this.$ports.userInfo.accountInfo, obj).then(res => {
 					if (res.data.code == 1) {
-						console.log(res.data.data, '用户信息');
+						// console.log(res.data.data, '用户信息');
 						this.userInfo = res.data.data;
 					}
 				})
 			},
 
-			sendMessage() {
-				// 手动上传
-				this.$refs.upload.submit();
-				let _this = this;
-				setTimeout(function () {
-					let params = {
-						'name': _this.call,
-						'email': _this.eMail,
-						'content': _this.leaveInfor,
-						'phone': _this.phone,
-						'qq': _this.QQ,
-						'wechat': _this.WX,
-						'file': _this.uploadImg.join(',')
-					}
-					_this.$axios.post('/api/service/Message/dealmessage', params).then(res => {
-						console.log('res', res)
-						return false;
-					})
-				}, 500)
+			get_vuex_info(){
+				this.users = this.$store.getters.get_user_info
+				console.log(this.users,'用户信息');
 			},
 
 
+
 			widthCheck(str, len) {
 				var temp = 0
 				for (var i = 0; i < str.value.length; i++) {
@@ -396,7 +395,8 @@
 						pageSize: size,
 						pageNumber: page
 					},
-					obj
+					obj,
+					str
 				).then(res => {
 					if (res.data.data) {
 						this.tableData = res.data.data;
@@ -407,8 +407,8 @@
 			},
 			click_row(row, column, event) {
 				// console.log(this.value);
-				// console.log(row.uid)
-				this.uid = row.uid;
+				console.log(row)
+				this.uid = row.message_id;
 				this.drawer = true;
 				// this.isShow = true;
 				this.getUserItem = row;