|
@@ -12,13 +12,13 @@
|
|
|
<span v-for="(item,index) in 4">供应商{{index}}</span>
|
|
|
对话
|
|
|
</view>
|
|
|
- <view class="messageLine">
|
|
|
+ <!-- <view class="messageLine">
|
|
|
<view class="messageTxt">大众 速腾 2006款 1.6L自动时尚型LFV456HH85777845</view>
|
|
|
<view class="messageTxt">我想要机油</view>
|
|
|
<view class="messageImgBox">
|
|
|
<image class="messageImg" src="/static/images/uniapp.png" mode="widthFix"></image>
|
|
|
</view>
|
|
|
- </view>
|
|
|
+ </view> -->
|
|
|
</view>
|
|
|
|
|
|
<checkbox-group @change="selectMessages">
|
|
@@ -268,23 +268,50 @@
|
|
|
messageSelector: {
|
|
|
visible: false,
|
|
|
messages: []
|
|
|
- }
|
|
|
+ },
|
|
|
+ toList:[
|
|
|
+ "A69257B1-8603-4BCD-9D32-07C18E6E14D7",
|
|
|
+ "1292F5DA-793B-4549-844E-C5F606869D0C",
|
|
|
+ "421DB63C-B274-478C-8442-CD43AD052A7B",
|
|
|
+ "AB6D0669-A5F8-423F-A6FE-81AC12084AFC"
|
|
|
+ ],
|
|
|
+ currentUser:'',
|
|
|
}
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
//聊天对象
|
|
|
- let id = options.to;
|
|
|
+ //let id = options.to;
|
|
|
this.friend = uni.getStorageSync("friend");
|
|
|
//this.friend = restApi.findUserById(id);
|
|
|
this.currentUser = uni.$currentUser;
|
|
|
- this.to = {
|
|
|
+ this.currentUser={
|
|
|
+ avatar: "/static/images/Avatar-1.png",
|
|
|
+ email: "Mattie@goeasy.io",
|
|
|
+ id: "08c0a6ec-a42b-47b2-bb1e-15e0f5f9a19a",
|
|
|
+ name: "测试群发",
|
|
|
+ password: "123",
|
|
|
+ phone: "138xxxxxxxx",
|
|
|
+ }
|
|
|
+ /* this.to = {
|
|
|
id: this.friend.ID,
|
|
|
type: GoEasy.IM_SCENE.PRIVATE,
|
|
|
data: {
|
|
|
name: this.friend.Name,
|
|
|
avatar: '/static/images/Avatar-1.png'
|
|
|
}
|
|
|
- };
|
|
|
+ }; */
|
|
|
+ this.currentUser = uni.getStorageSync('currentUser')
|
|
|
+ //this.connectGoEasy()
|
|
|
+ this.to = {
|
|
|
+ id: 'A69257B1-8603-4BCD-9D32-07C18E6E14D7',
|
|
|
+ type: GoEasy.IM_SCENE.PRIVATE,
|
|
|
+ data: {
|
|
|
+ name: "群发测试",
|
|
|
+ avatar: '/static/images/Avatar-1.png'
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ this.toList=uni.getStorageSync('supplierlist')
|
|
|
|
|
|
this.initGoEasyListeners();
|
|
|
// 语音播放器
|
|
@@ -312,6 +339,26 @@
|
|
|
GoEasy.im.off(GoEasy.IM_EVENT.HISTORY_EXPIRED, this.onHistoryExpired);
|
|
|
},
|
|
|
methods: {
|
|
|
+ connectGoEasy() {
|
|
|
+ console.log(this.currentUser)
|
|
|
+
|
|
|
+ GoEasy.connect({
|
|
|
+ id: this.currentUser.id,
|
|
|
+ data: {
|
|
|
+ name: this.currentUser.name,
|
|
|
+ avatar: this.currentUser.avatar
|
|
|
+ },
|
|
|
+ onSuccess: () => {
|
|
|
+ console.log('GoEasy connect successfully.')
|
|
|
+ },
|
|
|
+ onFailed: (error) => {
|
|
|
+ console.log('Failed to connect GoEasy, code:' + error.code + ',error:' + error.content);
|
|
|
+ },
|
|
|
+ onProgress: (attempts) => {
|
|
|
+ console.log('GoEasy is connecting', attempts);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
//渲染文本消息,如果包含表情,替换为图片
|
|
|
//todo:本不需要该方法,可以在标签里完成,但小程序有兼容性问题,被迫这样实现
|
|
|
renderTextMessage(message) {
|
|
@@ -385,25 +432,34 @@
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
- GoEasy.im.createAudioMessage({
|
|
|
- to: this.to,
|
|
|
- file: file,
|
|
|
- notification: {
|
|
|
- title: this.currentUser.name + '发来一段语音',
|
|
|
- body: '[语音消息]', // 字段最长 50 字符
|
|
|
- sound: 'message',
|
|
|
- badge: '+1'
|
|
|
- },
|
|
|
- onProgress: function (progress) {
|
|
|
- console.log(progress)
|
|
|
- },
|
|
|
- onSuccess: (message) => {
|
|
|
- this.sendMessage(message);
|
|
|
- },
|
|
|
- onFailed: (e) => {
|
|
|
- console.log('error :', e);
|
|
|
- }
|
|
|
- });
|
|
|
+ this.toList.forEach((item,index)=>{
|
|
|
+ this.to.id=item.id
|
|
|
+ this.to.data.name=item.supplierName
|
|
|
+ var num=0
|
|
|
+ if(index == this.toList.length-1){
|
|
|
+ num=1
|
|
|
+ }
|
|
|
+ GoEasy.im.createAudioMessage({
|
|
|
+ to: this.to,
|
|
|
+ file: file,
|
|
|
+ notification: {
|
|
|
+ title: this.currentUser.name + '发来一段语音',
|
|
|
+ body: '[语音消息]', // 字段最长 50 字符
|
|
|
+ sound: 'message',
|
|
|
+ badge: '+1'
|
|
|
+ },
|
|
|
+ onProgress: function (progress) {
|
|
|
+ console.log(progress)
|
|
|
+ },
|
|
|
+ onSuccess: (message) => {
|
|
|
+ this.sendMessage(message,num);
|
|
|
+ },
|
|
|
+ onFailed: (e) => {
|
|
|
+ console.log('error :', e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })
|
|
|
+
|
|
|
});
|
|
|
},
|
|
|
/**
|
|
@@ -428,8 +484,11 @@
|
|
|
return IMAGE_MAX_HEIGHT * 2;
|
|
|
}
|
|
|
},
|
|
|
- sendMessage(message) {
|
|
|
- this.history.messages.push(message);
|
|
|
+ sendMessage(message,num) {
|
|
|
+ if(num==1){
|
|
|
+ this.history.messages.push(message);
|
|
|
+ }
|
|
|
+
|
|
|
this.scrollToBottom();
|
|
|
GoEasy.im.sendMessage({
|
|
|
message: message,
|
|
@@ -451,48 +510,69 @@
|
|
|
if (this.text.length >= 50) {
|
|
|
body = this.text.substring(0, 30) + '...';
|
|
|
}
|
|
|
- GoEasy.im.createTextMessage({
|
|
|
- text: this.text,
|
|
|
- to: this.to,
|
|
|
- notification: {
|
|
|
- title: this.currentUser.name + '发来一段文字',
|
|
|
- body: body,
|
|
|
- sound: 'message',
|
|
|
- badge: '+1'
|
|
|
- },
|
|
|
- onSuccess: (message) => {
|
|
|
- this.sendMessage(message);
|
|
|
- },
|
|
|
- onFailed: (e) => {
|
|
|
- console.log('error :', e);
|
|
|
- }
|
|
|
- });
|
|
|
+
|
|
|
+ this.toList.forEach((item,index)=>{
|
|
|
+ this.to.id=item.id
|
|
|
+ this.to.data.name=item.supplierName
|
|
|
+ var num=0
|
|
|
+ if(index == this.toList.length-1){
|
|
|
+ num=1
|
|
|
+ }
|
|
|
+ GoEasy.im.createTextMessage({
|
|
|
+ text: this.text,
|
|
|
+ to: this.to,
|
|
|
+ notification: {
|
|
|
+ title: this.currentUser.name + '发来一段文字',
|
|
|
+ body: body,
|
|
|
+ sound: 'message',
|
|
|
+ badge: '+1'
|
|
|
+ },
|
|
|
+ onSuccess: (message) => {
|
|
|
+ this.sendMessage(message,num);
|
|
|
+ },
|
|
|
+ onFailed: (e) => {
|
|
|
+ console.log('error :', e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
this.text = '';
|
|
|
},
|
|
|
sendVideoMessage() {
|
|
|
uni.chooseVideo({
|
|
|
success: (res) => {
|
|
|
- GoEasy.im.createVideoMessage({
|
|
|
- to: this.to,
|
|
|
- file: res,
|
|
|
- notification: {
|
|
|
- title: this.currentUser.name + '发来一个视频',
|
|
|
- body: '[视频消息]', // 字段最长 50 字符
|
|
|
- sound: 'message',
|
|
|
- badge: '+1'
|
|
|
- },
|
|
|
- onProgress: function (progress) {
|
|
|
- console.log(progress)
|
|
|
- },
|
|
|
- onSuccess: (message) => {
|
|
|
- this.otherTypesMessagePanelVisible = false;
|
|
|
- this.sendMessage(message);
|
|
|
- },
|
|
|
- onFailed: (e) => {
|
|
|
- console.log('error :', e);
|
|
|
- }
|
|
|
- });
|
|
|
+ this.toList.forEach((item,index)=>{
|
|
|
+ this.to.id=item.id
|
|
|
+ this.to.data.name=item.supplierName
|
|
|
+ var num=0
|
|
|
+ if(index == this.toList.length-1){
|
|
|
+ num=1
|
|
|
+ }
|
|
|
+ GoEasy.im.createVideoMessage({
|
|
|
+ to: this.to,
|
|
|
+ file: res,
|
|
|
+ notification: {
|
|
|
+ title: this.currentUser.name + '发来一个视频',
|
|
|
+ body: '[视频消息]', // 字段最长 50 字符
|
|
|
+ sound: 'message',
|
|
|
+ badge: '+1'
|
|
|
+ },
|
|
|
+ onProgress: function (progress) {
|
|
|
+ console.log(progress)
|
|
|
+ },
|
|
|
+ onSuccess: (message) => {
|
|
|
+ this.otherTypesMessagePanelVisible = false;
|
|
|
+ this.sendMessage(message,num);
|
|
|
+ },
|
|
|
+ onFailed: (e) => {
|
|
|
+ console.log('error :', e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
}
|
|
|
})
|
|
|
},
|
|
@@ -501,26 +581,36 @@
|
|
|
count: 9,
|
|
|
success: (res) => {
|
|
|
res.tempFiles.forEach(file => {
|
|
|
- GoEasy.im.createImageMessage({
|
|
|
- to: this.to,
|
|
|
- file: file,
|
|
|
- notification: {
|
|
|
- title: this.currentUser.name + '发来一张图片',
|
|
|
- body: '[图片消息]', // 字段最长 50 字符
|
|
|
- sound: 'message',
|
|
|
- badge: '+1'
|
|
|
- },
|
|
|
- onProgress: function (progress) {
|
|
|
- console.log(progress)
|
|
|
- },
|
|
|
- onSuccess: (message) => {
|
|
|
- this.otherTypesMessagePanelVisible = false;
|
|
|
- this.sendMessage(message);
|
|
|
- },
|
|
|
- onFailed: (e) => {
|
|
|
- console.log('error :', e);
|
|
|
- }
|
|
|
- });
|
|
|
+ this.toList.forEach((item,index)=>{
|
|
|
+ this.to.id=item.id
|
|
|
+ this.to.data.name=item.supplierName
|
|
|
+ var num=0
|
|
|
+ if(index == this.toList.length-1){
|
|
|
+ num=1
|
|
|
+ }
|
|
|
+ GoEasy.im.createImageMessage({
|
|
|
+ to: this.to,
|
|
|
+ file: file,
|
|
|
+ notification: {
|
|
|
+ title: this.currentUser.name + '发来一张图片',
|
|
|
+ body: '[图片消息]', // 字段最长 50 字符
|
|
|
+ sound: 'message',
|
|
|
+ badge: '+1'
|
|
|
+ },
|
|
|
+ onProgress: function (progress) {
|
|
|
+ console.log(progress)
|
|
|
+ },
|
|
|
+ onSuccess: (message) => {
|
|
|
+ this.otherTypesMessagePanelVisible = false;
|
|
|
+ this.sendMessage(message,num);
|
|
|
+ },
|
|
|
+ onFailed: (e) => {
|
|
|
+ console.log('error :', e);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
})
|
|
|
}
|
|
|
});
|