xiaobin.zhang 2 år sedan
förälder
incheckning
f063b9d2c1

+ 12 - 1
chat/components/chat/inputbar/suit/attach/index.vue

@@ -24,6 +24,7 @@ let WebIM = require("../../../../../../hxChatSDK/utils/WebIM")["default"];
 let msgType = require("../../../msgtype");
 let disp = require("../../../../../../hxChatSDK/utils/broadcast");
 let msgStorage = require("../../../msgstorage");
+const req = require('../../../../../../utils/request.js');
 const str = WebIM.config.appkey.split("#");
 const token = WebIM.conn.context.accessToken;
 export default {
@@ -46,7 +47,8 @@ export default {
       // 文件上传大小限制
       size: 10,
       // 是否打印日志
-      debug: true
+      debug: true,
+	  userInfo:'',
     };
   },
   props: {
@@ -59,6 +61,10 @@ export default {
       default: msgType.chatType.SINGLE_CHAT
     }
   },
+  created() {
+  	this.userInfo = req.getStorage('userInfo');
+  },
+  
   onReady() {},
   methods: {
     getSendToParam() {
@@ -93,6 +99,11 @@ export default {
         to: me.getSendToParam(),
         roomType: false,
         chatType: me.chatType,
+		ext: {
+			nickName: me.userInfo.nickName,
+			avatar: me.userInfo.avatar,
+			id: me.userInfo.id,
+		},
         success: function (argument) {
           disp.fire("em.chat.sendSuccess", id);
         }

+ 11 - 1
chat/components/chat/inputbar/suit/audio/audio.vue

@@ -27,6 +27,7 @@
 </template>
 
 <script>
+const req = require('../../../../../../utils/request.js');
 let WebIM = require("../../../../../../hxChatSDK/utils/WebIM")["default"];
 let msgType = require("../../../msgtype");
 let RECORD_CONST = require("./record_status");
@@ -53,7 +54,8 @@ export default {
       recordClicked: false,
       isLongPress: false,
       recordTime: 0,
-      rec: null // h5 audio record
+      rec: null ,// h5 audio record
+	  userInfo:''
     };
   },
   components: {},
@@ -67,6 +69,9 @@ export default {
       default: msgType.chatType.SINGLE_CHAT
     }
   },
+  created() {
+  	this.userInfo = req.getStorage('userInfo');
+  },
 
   destroyed() {
     clearInterval(recordTimeInterval);
@@ -360,6 +365,11 @@ export default {
             to: me.getSendToParam(),
             roomType: false,
             chatType: me.chatType,
+			ext: {
+				nickName: me.userInfo.nickName,
+				avatar: me.userInfo.avatar,
+				id: me.userInfo.id,
+			},
             success: function (argument) {
               disp.fire("em.chat.sendSuccess", id);
             }

+ 14 - 1
chat/components/chat/inputbar/suit/image/image.vue

@@ -6,9 +6,12 @@
 	let msgType = require("../../../msgtype");
 	let disp = require("../../../../../../hxChatSDK/utils/broadcast");
 	let msgStorage = require("../../../msgstorage");
+	const req = require('../../../../../../utils/request.js');
 	export default {
 		data() {
-			return {};
+			return {
+				 userInfo:''
+			};
 		},
 
 		components: {},
@@ -22,6 +25,11 @@
 				default: msgType.chatType.SINGLE_CHAT
 			}
 		},
+		
+		created() {
+			this.userInfo = req.getStorage('userInfo');
+		},
+		
 		methods: {
 			openCamera() {
 				var me = this;
@@ -133,6 +141,11 @@
 										to: me.getSendToParam(),
 										roomType: false,
 										chatType: me.chatType,
+										ext: {
+											nickName: me.userInfo.nickName,
+											avatar: me.userInfo.avatar,
+											id: me.userInfo.id,
+										},
 										success: function(argument) {
 											disp.fire('em.chat.sendSuccess', id);
 										}

+ 89 - 79
chat/components/chat/inputbar/suit/location/location.vue

@@ -1,95 +1,105 @@
 <template>
-<view></view>
+	<view></view>
 </template>
 <script>
-let WebIM = require("../../../../../../hxChatSDK/utils/WebIM")["default"];
-let msgType = require("../../../msgtype");
-let msgStorage = require("../../../msgstorage");
-export default {
-  data() {
-    return {};
-  },
+	const req = require('../../../../../../utils/request.js');
+	let WebIM = require("../../../../../../hxChatSDK/utils/WebIM")["default"];
+	let msgType = require("../../../msgtype");
+	let msgStorage = require("../../../msgstorage");
+	export default {
+		data() {
+			return {
+				 userInfo:''
+			};
+		},
 
-  components: {},
-  props: {
-    username: {
-      type: Object,
-      default: () => ({})
-    },
-    chatType: {
-      type: String,
-      default: msgType.chatType.SINGLE_CHAT
-    }
-  },
-  methods: {
-    isGroupChat() {
-      return this.chatType == msgType.chatType.CHAT_ROOM;
-    },
+		components: {},
+		props: {
+			username: {
+				type: Object,
+				default: () => ({})
+			},
+			chatType: {
+				type: String,
+				default: msgType.chatType.SINGLE_CHAT
+			}
+		},
+		created() {
+			this.userInfo = req.getStorage('userInfo');
+		},
+		methods: {
+			isGroupChat() {
+				return this.chatType == msgType.chatType.CHAT_ROOM;
+			},
 
-    getSendToParam() {
-      return this.isGroupChat() ? this.username.groupId : this.username.your;
-    },
+			getSendToParam() {
+				return this.isGroupChat() ? this.username.groupId : this.username.your;
+			},
 
-    sendLocation() {
-      var me = this;
-      uni.authorize({
-        scope: "scope.userLocation",
+			sendLocation() {
+				var me = this;
+				uni.authorize({
+					scope: "scope.userLocation",
 
-        fail() {
-          uni.showToast({
-            title: "已拒绝",
-            icon: "none"
-          });
-        },
+					fail() {
+						uni.showToast({
+							title: "已拒绝",
+							icon: "none"
+						});
+					},
 
-        success() {
-          uni.chooseLocation({
-            fail() {
-              console.log(arguments);
-            },
+					success() {
+						uni.chooseLocation({
+							fail() {
+								console.log(arguments);
+							},
 
-            complete() {
-              console.log(arguments);
-            },
+							complete() {
+								console.log(arguments);
+							},
 
-            success(respData) {
-              var id = WebIM.conn.getUniqueId();
-              var msg = new WebIM.message(msgType.LOCATION, id);
-              msg.set({
-                msg: "",
-                from: me.username.myName,
-                to: me.getSendToParam(),
-                roomType: false,
-                lng: respData.longitude,
-                lat: respData.latitude,
-                addr: respData.address,
-                chatType: me.chatType,
+							success(respData) {
+								var id = WebIM.conn.getUniqueId();
+								var msg = new WebIM.message(msgType.LOCATION, id);
+								msg.set({
+									msg: "",
+									from: me.username.myName,
+									to: me.getSendToParam(),
+									roomType: false,
+									lng: respData.longitude,
+									lat: respData.latitude,
+									addr: respData.address,
+									chatType: me.chatType,
+									ext: {
+										nickName: me.userInfo.nickName,
+										avatar: me.userInfo.avatar,
+										id: me.userInfo.id,
+									},
+									success(id, serverMsgId) {}
 
-                success(id, serverMsgId) {}
+								});
 
-              });
+								if (me.chatType == msgType.chatType.CHAT_ROOM) {
+									msg.setGroup("groupchat");
+								}
 
-              if (me.chatType == msgType.chatType.CHAT_ROOM) {
-                msg.setGroup("groupchat");
-              }
+								WebIM.conn.send(msg.body);
+								let obj = {
+									msg: msg,
+									type: msgType.IMAGE
+								}
+								me.saveSendMsg(obj);
+							}
 
-              WebIM.conn.send(msg.body);
-                let obj = {
-                  msg: msg,
-                  type: msgType.IMAGE
-                }
-              me.saveSendMsg(obj);
-            }
+						});
+					}
 
-          });
-        }
+				});
+			},
+			saveSendMsg(evt) {
+				msgStorage.saveMsg(evt.msg, evt.type);
+			}
 
-      });
-    },
-    saveSendMsg(evt) {
-      msgStorage.saveMsg(evt.msg, evt.type);
-    }
-
-  }
-};
-</script>
+		}
+	};
+</script>

+ 105 - 95
chat/components/chat/inputbar/suit/videoComp/videoComp.vue

@@ -1,110 +1,120 @@
 <template>
-  <div></div>
+	<div></div>
 </template>
 
 <script>
-let WebIM = require("../../../../../../hxChatSDK/utils/WebIM")["default"];
-let msgType = require("../../../msgtype");
-let msgStorage = require("../../../msgstorage");
-let disp = require("../../../../../../hxChatSDK/utils/broadcast");
+	let WebIM = require("../../../../../../hxChatSDK/utils/WebIM")["default"];
+	let msgType = require("../../../msgtype");
+	let msgStorage = require("../../../msgstorage");
+	let disp = require("../../../../../../hxChatSDK/utils/broadcast");
+	const req = require('../../../../../../utils/request.js');
+	export default {
+		data() {
+			return {
+				userInfo: ''
+			};
+		},
 
-export default {
-  data() {
-    return {};
-  },
+		components: {},
+		props: {
+			username: {
+				type: Object,
+				default: () => ({}),
+			},
+			chatType: {
+				type: String,
+				default: msgType.chatType.SINGLE_CHAT,
+			},
+		},
 
-  components: {},
-  props: {
-    username: {
-      type: Object,
-      default: () => ({}),
-    },
-    chatType: {
-      type: String,
-      default: msgType.chatType.SINGLE_CHAT,
-    },
-  },
-  methods: {
-    isGroupChat() {
-      return this.chatType == msgType.chatType.CHAT_ROOM;
-    },
+		created() {
+			this.userInfo = req.getStorage('userInfo');
+		},
 
-    getSendToParam() {
-      return this.isGroupChat() ? this.username.groupId : this.username.your;
-    },
+		methods: {
+			isGroupChat() {
+				return this.chatType == msgType.chatType.CHAT_ROOM;
+			},
 
-    // 未启用
-    sendVideo() {
-      var me = this;
-      var token = WebIM.conn.context.accessToken;
-      uni.chooseVideo({
-        sourceType: ["album", "camera"],
-        maxDuration: 60,
-        camera: "back",
-        success(res) {
-          var tempFilePaths = res.tempFilePath;
-          var str = WebIM.config.appkey.split("#");
-          uni.uploadFile({
-            url:
-              "https://a1.easemob.com/" + str[0] + "/" + str[1] + "/chatfiles",
-            filePath: tempFilePaths,
-            name: "file",
-            header: {
-              "Content-Type": "multipart/form-data",
-              Authorization: "Bearer " + token,
-            },
-            success(res) {
-              var data = res.data;
-              var dataObj = JSON.parse(data);
-              var id = WebIM.conn.getUniqueId(); // 生成本地消息id
-              var msg = new WebIM.message(msgType.VIDEO, id);
-              msg.set({
-                apiUrl: WebIM.config.apiURL,
-                accessToken: token,
-                body: {
-                  type: msgType.VIDEO,
-                  url: dataObj.uri + "/" + dataObj.entities[0].uuid,
-                  filetype: "mp4",
-                  filename: tempFilePaths,
+			getSendToParam() {
+				return this.isGroupChat() ? this.username.groupId : this.username.your;
+			},
+
+			// 未启用
+			sendVideo() {
+				var me = this;
+				var token = WebIM.conn.context.accessToken;
+				uni.chooseVideo({
+					sourceType: ["album", "camera"],
+					maxDuration: 60,
+					camera: "back",
+					success(res) {
+						var tempFilePaths = res.tempFilePath;
+						var str = WebIM.config.appkey.split("#");
+						uni.uploadFile({
+							url: "https://a1.easemob.com/" + str[0] + "/" + str[1] + "/chatfiles",
+							filePath: tempFilePaths,
+							name: "file",
+							header: {
+								"Content-Type": "multipart/form-data",
+								Authorization: "Bearer " + token,
+							},
+							success(res) {
+								var data = res.data;
+								var dataObj = JSON.parse(data);
+								var id = WebIM.conn.getUniqueId(); // 生成本地消息id
+								var msg = new WebIM.message(msgType.VIDEO, id);
+								msg.set({
+									apiUrl: WebIM.config.apiURL,
 									accessToken: token,
-                },
-                from: me.username.myName,
-                to: me.getSendToParam(),
-                roomType: false,
-                chatType: me.chatType,
-                success: function (argument) {
-									disp.fire('em.chat.sendSuccess', id);
+									body: {
+										type: msgType.VIDEO,
+										url: dataObj.uri + "/" + dataObj.entities[0].uuid,
+										filetype: "mp4",
+										filename: tempFilePaths,
+										accessToken: token,
+									},
+									from: me.username.myName,
+									to: me.getSendToParam(),
+									roomType: false,
+									chatType: me.chatType,
+									ext: {
+										nickName: me.userInfo.nickName,
+										avatar: me.userInfo.avatar,
+										id: me.userInfo.id,
+									},
+									success: function(argument) {
+										disp.fire('em.chat.sendSuccess', id);
+									}
+								});
+								if (me.isGroupChat()) {
+									msg.setGroup("groupchat");
 								}
-              });
-              if (me.isGroupChat()) {
-                msg.setGroup("groupchat");
-              }
-              WebIM.conn.send(msg.body);
-              let obj = {
-                msg: msg,
-                type: msgType.VIDEO,
-              };
-              me.saveSendMsg(obj);
-            },
-          });
-        },
-      });
-    },
-    saveSendMsg(evt) {
-      msgStorage.saveMsg(evt.msg, evt.type);
-    },
-  },
-
-  // lifetimes
-  created() {},
+								WebIM.conn.send(msg.body);
+								let obj = {
+									msg: msg,
+									type: msgType.VIDEO,
+								};
+								me.saveSendMsg(obj);
+							},
+						});
+					},
+				});
+			},
+			saveSendMsg(evt) {
+				msgStorage.saveMsg(evt.msg, evt.type);
+			},
+		},
 
-  beforeMount() {},
+		// lifetimes
+		created() {},
 
-  moved() {},
+		beforeMount() {},
 
-  destroyed() {},
+		moved() {},
 
-  mounted() {},
-};
-</script>
+		destroyed() {},
 
+		mounted() {},
+	};
+</script>