|
@@ -16,8 +16,15 @@ |
|
@@ -16,8 +16,15 @@ |
16
|
<view class="row" v-for="(item,index) in msgList" :key="index" :id="item.ID">
|
16
|
<view class="row" v-for="(item,index) in msgList" :key="index" :id="item.ID">
|
17
|
<!-- 用户消息 -->
|
17
|
<!-- 用户消息 -->
|
18
|
<block>
|
18
|
<block>
|
|
|
19
|
+ <!-- 礼物消息 -->
|
|
|
20
|
+ <view class="system" v-if="item.flow == 'in' && item.type==TIM.TYPES.MSG_CUSTOM">
|
|
|
21
|
+ <!-- 发送礼物消息 -->
|
|
|
22
|
+ <view class="red-envelope">
|
|
|
23
|
+ {{item.payload.data}}
|
|
|
24
|
+ </view>
|
|
|
25
|
+ </view>
|
19
|
<!-- 自己发出的消息 -->
|
26
|
<!-- 自己发出的消息 -->
|
20
|
- <view class="my" v-if="item.flow=='out'">
|
27
|
+ <view class="my" v-if="item.flow=='out' && item.type==TIM.TYPES.MSG_TEXT">
|
21
|
<!-- 左-消息 -->
|
28
|
<!-- 左-消息 -->
|
22
|
<view class="left">
|
29
|
<view class="left">
|
23
|
<view class="username">
|
30
|
<view class="username">
|
|
@@ -28,7 +35,7 @@ |
|
@@ -28,7 +35,7 @@ |
28
|
<view class="peerStatus">
|
35
|
<view class="peerStatus">
|
29
|
{{item.isPeerRead ? '已读' : '未读'}}
|
36
|
{{item.isPeerRead ? '已读' : '未读'}}
|
30
|
</view>
|
37
|
</view>
|
31
|
- <view v-if="item.type==TIM.TYPES.MSG_TEXT" class="bubble">
|
38
|
+ <view class="bubble">
|
32
|
<rich-text :nodes="nodesFliter(item.payload.text)"></rich-text>
|
39
|
<rich-text :nodes="nodesFliter(item.payload.text)"></rich-text>
|
33
|
</view>
|
40
|
</view>
|
34
|
</view>
|
41
|
</view>
|
|
@@ -40,7 +47,7 @@ |
|
@@ -40,7 +47,7 @@ |
40
|
</view>
|
47
|
</view>
|
41
|
</view>
|
48
|
</view>
|
42
|
<!-- 别人发出的消息 -->
|
49
|
<!-- 别人发出的消息 -->
|
43
|
- <view class="other" v-else>
|
50
|
+ <view class="other" v-if="item.flow=='in' && item.type==TIM.TYPES.MSG_TEXT">
|
44
|
<!-- 左-头像 -->
|
51
|
<!-- 左-头像 -->
|
45
|
<navigator class="left" hover-class="none" :url="'/pages/index/landHome?id='+toUserInfo.id">
|
52
|
<navigator class="left" hover-class="none" :url="'/pages/index/landHome?id='+toUserInfo.id">
|
46
|
<image :src="toUserInfo.avatar" mode="aspectFill"></image>
|
53
|
<image :src="toUserInfo.avatar" mode="aspectFill"></image>
|
|
@@ -75,40 +82,13 @@ |
|
@@ -75,40 +82,13 @@ |
75
|
</view>
|
82
|
</view>
|
76
|
</swiper-item>
|
83
|
</swiper-item>
|
77
|
</swiper>
|
84
|
</swiper>
|
78
|
- <!-- 更多功能 相册-拍照-红包 -->
|
|
|
79
|
- <view class="more-layer" :class="{hidden:hideMore}">
|
|
|
80
|
- <view class="list">
|
|
|
81
|
- <view class="box" @tap="chooseImage">
|
|
|
82
|
- <view class="icon tupian2"></view>
|
|
|
83
|
- </view>
|
|
|
84
|
- <view class="box" @tap="camera">
|
|
|
85
|
- <view class="icon paizhao"></view>
|
|
|
86
|
- </view>
|
|
|
87
|
- <view class="box" @tap="handRedEnvelopes">
|
|
|
88
|
- <view class="icon hongbao"></view>
|
|
|
89
|
- </view>
|
|
|
90
|
- </view>
|
|
|
91
|
- </view>
|
|
|
92
|
</view>
|
85
|
</view>
|
93
|
<!-- 送礼物弹框 -->
|
86
|
<!-- 送礼物弹框 -->
|
94
|
- <send-gift v-if="showSendGift" :toUserId="toUserInfo.id" @closeSendGift="showSendGift = false"></send-gift>
|
87
|
+ <send-gift v-if="showSendGift" :toUserId="toUserInfo.id" @closeSendGift="closeSendGift"></send-gift>
|
95
|
<!-- 底部输入栏 -->
|
88
|
<!-- 底部输入栏 -->
|
96
|
<view class="input-box" :style="{bottom: keyboardHeight+'rpx'}" :class="popupLayerClass" @touchmove.stop.prevent="discard">
|
89
|
<view class="input-box" :style="{bottom: keyboardHeight+'rpx'}" :class="popupLayerClass" @touchmove.stop.prevent="discard">
|
97
|
- <!-- H5下不能录音,输入栏布局改动一下 -->
|
|
|
98
|
- <!-- #ifndef H5 -->
|
|
|
99
|
- <!-- <view class="voice">
|
|
|
100
|
- <view class="icon" :class="isVoice?'jianpan':'yuyin'" @tap="switchVoice"></view>
|
|
|
101
|
- </view> -->
|
|
|
102
|
- <!-- #endif -->
|
|
|
103
|
- <!-- #ifdef H5 -->
|
|
|
104
|
- <!-- <view class="more" @tap="showMore">
|
|
|
105
|
- <view class="icon add"></view>
|
|
|
106
|
- </view> -->
|
|
|
107
|
- <!-- #endif -->
|
|
|
108
|
<view class="textbox">
|
90
|
<view class="textbox">
|
109
|
- <view class="voice-mode" :class="[isVoice?'':'hidden',recording?'recording':'']" @touchstart="voiceBegin"
|
|
|
110
|
- @touchmove.stop.prevent="voiceIng" @touchend="voiceEnd" @touchcancel="voiceCancel">{{voiceTis}}</view>
|
|
|
111
|
- <view class="text-mode" :class="isVoice?'hidden':''">
|
91
|
+ <view class="text-mode">
|
112
|
<view class="box">
|
92
|
<view class="box">
|
113
|
<textarea auto-height="true" v-model="textMsg" @focus="textareaFocus" />
|
93
|
<textarea auto-height="true" v-model="textMsg" @focus="textareaFocus" />
|
114
|
</view>
|
94
|
</view>
|
|
@@ -117,43 +97,10 @@ |
|
@@ -117,43 +97,10 @@ |
117
|
</view>
|
97
|
</view>
|
118
|
</view>
|
98
|
</view>
|
119
|
</view>
|
99
|
</view>
|
120
|
- <!-- #ifndef H5 -->
|
|
|
121
|
- <!-- <view class="more" @tap="showMore">
|
|
|
122
|
- <view class="icon add"></view>
|
|
|
123
|
- </view> -->
|
|
|
124
|
- <!-- #endif -->
|
|
|
125
|
- <view class="send" :class="isVoice?'hidden':''" @tap="sendText">
|
100
|
+ <view class="send" @tap="sendText">
|
126
|
<view class="btn">发送</view>
|
101
|
<view class="btn">发送</view>
|
127
|
</view>
|
102
|
</view>
|
128
|
</view>
|
103
|
</view>
|
129
|
- <!-- 录音UI效果 -->
|
|
|
130
|
- <view class="record" :class="recording?'':'hidden'">
|
|
|
131
|
- <view class="ing" :class="willStop?'hidden':''"><view class="icon luyin2" ></view></view>
|
|
|
132
|
- <view class="cancel" :class="willStop?'':'hidden'"><view class="icon chehui" ></view></view>
|
|
|
133
|
- <view class="tis" :class="willStop?'change':''">{{recordTis}}</view>
|
|
|
134
|
- </view>
|
|
|
135
|
- <!-- 红包弹窗 -->
|
|
|
136
|
- <view class="windows" :class="windowsState">
|
|
|
137
|
- <!-- 遮罩层 -->
|
|
|
138
|
- <view class="mask" @touchmove.stop.prevent="discard" @tap="closeRedEnvelope"></view>
|
|
|
139
|
- <view class="layer" @touchmove.stop.prevent="discard">
|
|
|
140
|
- <view class="open-redenvelope">
|
|
|
141
|
- <view class="top">
|
|
|
142
|
- <view class="close-btn">
|
|
|
143
|
- <view class="icon close" @tap="closeRedEnvelope"></view>
|
|
|
144
|
- </view>
|
|
|
145
|
- <image src="/static/img/im/face/face_1.jpg"></image>
|
|
|
146
|
- </view>
|
|
|
147
|
- <view class="from">来自{{redenvelopeData.from}}</view>
|
|
|
148
|
- <view class="blessing">{{redenvelopeData.blessing}}</view>
|
|
|
149
|
- <view class="money">{{redenvelopeData.money}}</view>
|
|
|
150
|
- <view class="showDetails" @tap="toDetails(redenvelopeData.rid)">
|
|
|
151
|
- 查看领取详情 <view class="icon to"></view>
|
|
|
152
|
- </view>
|
|
|
153
|
- </view>
|
|
|
154
|
- </view>
|
|
|
155
|
-
|
|
|
156
|
- </view>
|
|
|
157
|
</view>
|
104
|
</view>
|
158
|
</template>
|
105
|
</template>
|
159
|
<script>
|
106
|
<script>
|
|
@@ -179,35 +126,11 @@ |
|
@@ -179,35 +126,11 @@ |
179
|
isCompleted:'',
|
126
|
isCompleted:'',
|
180
|
msgList:[],
|
127
|
msgList:[],
|
181
|
TIM:null,
|
128
|
TIM:null,
|
182
|
-
|
|
|
183
|
-
|
|
|
184
|
//文字消息
|
129
|
//文字消息
|
185
|
textMsg:'',
|
130
|
textMsg:'',
|
186
|
scrollAnimation:false,
|
131
|
scrollAnimation:false,
|
187
|
scrollTop:0,
|
132
|
scrollTop:0,
|
188
|
scrollToView:'',
|
133
|
scrollToView:'',
|
189
|
-
|
|
|
190
|
- msgImgList:[],
|
|
|
191
|
- myuid:0,
|
|
|
192
|
-
|
|
|
193
|
- //录音相关参数
|
|
|
194
|
- // #ifndef H5
|
|
|
195
|
- //H5不能录音
|
|
|
196
|
- RECORDER:uni.getRecorderManager(),
|
|
|
197
|
- // #endif
|
|
|
198
|
- isVoice:false,
|
|
|
199
|
- voiceTis:'按住 说话',
|
|
|
200
|
- recordTis:"手指上滑 取消发送",
|
|
|
201
|
- recording:false,
|
|
|
202
|
- willStop:false,
|
|
|
203
|
- initPoint:{identifier:0,Y:0},
|
|
|
204
|
- recordTimer:null,
|
|
|
205
|
- recordLength:0,
|
|
|
206
|
-
|
|
|
207
|
- //播放语音相关参数
|
|
|
208
|
- AUDIO:uni.createInnerAudioContext(),
|
|
|
209
|
- playMsgid:null,
|
|
|
210
|
- VoiceTimer:null,
|
|
|
211
|
// 抽屉参数
|
134
|
// 抽屉参数
|
212
|
popupLayerClass:'',
|
135
|
popupLayerClass:'',
|
213
|
// more参数
|
136
|
// more参数
|
|
@@ -215,15 +138,6 @@ |
|
@@ -215,15 +138,6 @@ |
215
|
//表情定义
|
138
|
//表情定义
|
216
|
hideEmoji:true,
|
139
|
hideEmoji:true,
|
217
|
emojiList:this.$commen.emojiList,
|
140
|
emojiList:this.$commen.emojiList,
|
218
|
- //红包相关参数
|
|
|
219
|
- windowsState:'',
|
|
|
220
|
- redenvelopeData:{
|
|
|
221
|
- rid:null, //红包ID
|
|
|
222
|
- from:null,
|
|
|
223
|
- face:null,
|
|
|
224
|
- blessing:null,
|
|
|
225
|
- money:null
|
|
|
226
|
- },
|
|
|
227
|
switchTab:'1',
|
141
|
switchTab:'1',
|
228
|
plat:'android'
|
142
|
plat:'android'
|
229
|
};
|
143
|
};
|
|
@@ -273,9 +187,10 @@ |
|
@@ -273,9 +187,10 @@ |
273
|
}
|
187
|
}
|
274
|
})
|
188
|
})
|
275
|
},
|
189
|
},
|
276
|
- onShow(){
|
190
|
+ /* onShow(){
|
|
|
191
|
+ console.log('onShow方法执行了')
|
277
|
this.scrollTop = 9999999;
|
192
|
this.scrollTop = 9999999;
|
278
|
- },
|
193
|
+ }, */
|
279
|
onUnload(){
|
194
|
onUnload(){
|
280
|
//退出页面 将所有的会话内的消息设置为已读
|
195
|
//退出页面 将所有的会话内的消息设置为已读
|
281
|
if(this.isSDKReady){
|
196
|
if(this.isSDKReady){
|
|
@@ -318,6 +233,13 @@ |
|
@@ -318,6 +233,13 @@ |
318
|
}
|
233
|
}
|
319
|
}
|
234
|
}
|
320
|
},
|
235
|
},
|
|
|
236
|
+ closeSendGift(e){
|
|
|
237
|
+ if(e){
|
|
|
238
|
+ let msg = {text: this.userinfo.nickname+"给您送了"+e}
|
|
|
239
|
+ this.sendMsg(msg,'custom');
|
|
|
240
|
+ }
|
|
|
241
|
+ this.showSendGift = false
|
|
|
242
|
+ },
|
321
|
longtap(item){
|
243
|
longtap(item){
|
322
|
uni.showModal({
|
244
|
uni.showModal({
|
323
|
title:'提示',
|
245
|
title:'提示',
|
|
@@ -397,8 +319,10 @@ |
|
@@ -397,8 +319,10 @@ |
397
|
if(newVal[0].ID != oldVal[0].ID && newVal.length>=this.count ){
|
319
|
if(newVal[0].ID != oldVal[0].ID && newVal.length>=this.count ){
|
398
|
this.$nextTick(()=> {this.scrollToView =oldVal[0].ID});
|
320
|
this.$nextTick(()=> {this.scrollToView =oldVal[0].ID});
|
399
|
}else{
|
321
|
}else{
|
|
|
322
|
+ if(newVal.length > oldVal.length){
|
400
|
this.$nextTick(()=> {this.scrollToView =newVal[newVal.length-1].ID});
|
323
|
this.$nextTick(()=> {this.scrollToView =newVal[newVal.length-1].ID});
|
401
|
}
|
324
|
}
|
|
|
325
|
+ }
|
402
|
}else{
|
326
|
}else{
|
403
|
if(newVal.length > 0){
|
327
|
if(newVal.length > 0){
|
404
|
this.$nextTick(()=> {this.scrollToView =newVal[newVal.length-1].ID});
|
328
|
this.$nextTick(()=> {this.scrollToView =newVal[newVal.length-1].ID});
|
|
@@ -407,6 +331,10 @@ |
|
@@ -407,6 +331,10 @@ |
407
|
},
|
331
|
},
|
408
|
//触发滑动到顶部(加载历史信息记录)
|
332
|
//触发滑动到顶部(加载历史信息记录)
|
409
|
loadHistory(e){
|
333
|
loadHistory(e){
|
|
|
334
|
+ uni.showLoading({
|
|
|
335
|
+ title:'加载中...'
|
|
|
336
|
+ })
|
|
|
337
|
+ this.scrollAnimation = false;//恢复滚动动画
|
410
|
// 更多消息列表
|
338
|
// 更多消息列表
|
411
|
let conversationID = this.conversationActive.conversationID
|
339
|
let conversationID = this.conversationActive.conversationID
|
412
|
let promise = this.tim.getMessageList({conversationID: conversationID,nextReqMessageID:this.nextReqMessageID,count: this.count});
|
340
|
let promise = this.tim.getMessageList({conversationID: conversationID,nextReqMessageID:this.nextReqMessageID,count: this.count});
|
|
@@ -414,16 +342,15 @@ |
|
@@ -414,16 +342,15 @@ |
414
|
this.$store.commit('unshiftCurrentMessageList', res.data.messageList)
|
342
|
this.$store.commit('unshiftCurrentMessageList', res.data.messageList)
|
415
|
this.nextReqMessageID = res.data.nextReqMessageID // 用于续拉,分页续拉时需传入该字段。
|
343
|
this.nextReqMessageID = res.data.nextReqMessageID // 用于续拉,分页续拉时需传入该字段。
|
416
|
this.isCompleted = res.data.isCompleted
|
344
|
this.isCompleted = res.data.isCompleted
|
417
|
-
|
|
|
418
|
- });
|
|
|
419
|
//这段代码很重要,不然每次加载历史数据都会跳到顶部
|
345
|
//这段代码很重要,不然每次加载历史数据都会跳到顶部
|
420
|
- /* this.$nextTick(function() {
|
346
|
+ this.$nextTick(() => {
|
421
|
this.scrollToView = this.nextReqMessageID;//跳转上次的第一行信息位置
|
347
|
this.scrollToView = this.nextReqMessageID;//跳转上次的第一行信息位置
|
422
|
- this.$nextTick(function() {
|
348
|
+ this.$nextTick(() => {
|
423
|
this.scrollAnimation = true;//恢复滚动动画
|
349
|
this.scrollAnimation = true;//恢复滚动动画
|
424
|
});
|
350
|
});
|
425
|
-
|
|
|
426
|
- }); */
|
351
|
+ });
|
|
|
352
|
+ uni.hideLoading()
|
|
|
353
|
+ });
|
427
|
},
|
354
|
},
|
428
|
// 加载初始页面消息
|
355
|
// 加载初始页面消息
|
429
|
getMsgList(){
|
356
|
getMsgList(){
|
|
@@ -437,41 +364,17 @@ |
|
@@ -437,41 +364,17 @@ |
437
|
this.$store.commit('pushCurrentMessageList', res.data.messageList)
|
364
|
this.$store.commit('pushCurrentMessageList', res.data.messageList)
|
438
|
this.nextReqMessageID = res.data.nextReqMessageID // 用于续拉,分页续拉时需传入该字段。
|
365
|
this.nextReqMessageID = res.data.nextReqMessageID // 用于续拉,分页续拉时需传入该字段。
|
439
|
this.isCompleted = res.data.isCompleted
|
366
|
this.isCompleted = res.data.isCompleted
|
440
|
- this.scrollToView = res.data.messageList[res.data.messageList.length-1].ID
|
|
|
441
|
- })
|
|
|
442
|
// 滚动到底部
|
367
|
// 滚动到底部
|
443
|
- this.$nextTick(function() {
|
368
|
+ this.$nextTick(() => {
|
444
|
//进入页面滚动到底部
|
369
|
//进入页面滚动到底部
|
445
|
- this.scrollTop = 9999;
|
|
|
446
|
- this.$nextTick(function() {
|
370
|
+ this.scrollToView = res.data.messageList[res.data.messageList.length-1].ID
|
|
|
371
|
+ this.$nextTick(() => {
|
447
|
this.scrollAnimation = true;
|
372
|
this.scrollAnimation = true;
|
448
|
- uni.hideLoading()
|
|
|
449
|
- this.showRoom = true
|
|
|
450
|
});
|
373
|
});
|
451
|
});
|
374
|
});
|
452
|
- },
|
|
|
453
|
- //处理图片尺寸,如果不处理宽高,新进入页面加载图片时候会闪
|
|
|
454
|
- setPicSize(content){
|
|
|
455
|
- // 让图片最长边等于设置的最大长度,短边等比例缩小,图片控件真实改变,区别于aspectFit方式。
|
|
|
456
|
- let maxW = uni.upx2px(350);//350是定义消息图片最大宽度
|
|
|
457
|
- let maxH = uni.upx2px(350);//350是定义消息图片最大高度
|
|
|
458
|
- if(content.w>maxW||content.h>maxH){
|
|
|
459
|
- let scale = content.w/content.h;
|
|
|
460
|
- content.w = scale>1?maxW:maxH*scale;
|
|
|
461
|
- content.h = scale>1?maxW/scale:maxH;
|
|
|
462
|
- }
|
|
|
463
|
- return content;
|
|
|
464
|
- },
|
|
|
465
|
- //更多功能(点击+弹出)
|
|
|
466
|
- showMore(){
|
|
|
467
|
- this.isVoice = false;
|
|
|
468
|
- this.hideEmoji = true;
|
|
|
469
|
- if(this.hideMore){
|
|
|
470
|
- this.hideMore = false;
|
|
|
471
|
- this.openDrawer();
|
|
|
472
|
- }else{
|
|
|
473
|
- this.hideDrawer();
|
|
|
474
|
- }
|
375
|
+ this.showRoom = true
|
|
|
376
|
+ uni.hideLoading()
|
|
|
377
|
+ })
|
475
|
},
|
378
|
},
|
476
|
// 打开抽屉
|
379
|
// 打开抽屉
|
477
|
openDrawer(){
|
380
|
openDrawer(){
|
|
@@ -485,40 +388,6 @@ |
|
@@ -485,40 +388,6 @@ |
485
|
this.hideEmoji = true;
|
388
|
this.hideEmoji = true;
|
486
|
},150);
|
389
|
},150);
|
487
|
},
|
390
|
},
|
488
|
- // 选择图片发送
|
|
|
489
|
- chooseImage(){
|
|
|
490
|
- this.getImage('album');
|
|
|
491
|
- },
|
|
|
492
|
- //拍照发送
|
|
|
493
|
- camera(){
|
|
|
494
|
- this.getImage('camera');
|
|
|
495
|
- },
|
|
|
496
|
- //发红包
|
|
|
497
|
- handRedEnvelopes(){
|
|
|
498
|
- uni.navigateTo({
|
|
|
499
|
- url:'HM-hand/HM-hand'
|
|
|
500
|
- });
|
|
|
501
|
- this.hideDrawer();
|
|
|
502
|
- },
|
|
|
503
|
- //选照片 or 拍照
|
|
|
504
|
- getImage(type){
|
|
|
505
|
- this.hideDrawer();
|
|
|
506
|
- uni.chooseImage({
|
|
|
507
|
- sourceType:[type],
|
|
|
508
|
- sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
|
|
|
509
|
- success: (res)=>{
|
|
|
510
|
- for(let i=0;i<res.tempFilePaths.length;i++){
|
|
|
511
|
- uni.getImageInfo({
|
|
|
512
|
- src: res.tempFilePaths[i],
|
|
|
513
|
- success: (image)=>{
|
|
|
514
|
- let msg = {url:res.tempFilePaths[i],w:image.width,h:image.height};
|
|
|
515
|
- this.sendMsg(msg,'img');
|
|
|
516
|
- }
|
|
|
517
|
- });
|
|
|
518
|
- }
|
|
|
519
|
- }
|
|
|
520
|
- });
|
|
|
521
|
- },
|
|
|
522
|
// 选择表情
|
391
|
// 选择表情
|
523
|
chooseEmoji(){
|
392
|
chooseEmoji(){
|
524
|
this.hideMore = true;
|
393
|
this.hideMore = true;
|
|
@@ -533,7 +402,6 @@ |
|
@@ -533,7 +402,6 @@ |
533
|
addEmoji(em){
|
402
|
addEmoji(em){
|
534
|
this.textMsg+=em.alt;
|
403
|
this.textMsg+=em.alt;
|
535
|
},
|
404
|
},
|
536
|
-
|
|
|
537
|
//获取焦点,如果不是选表情ing,则关闭抽屉
|
405
|
//获取焦点,如果不是选表情ing,则关闭抽屉
|
538
|
textareaFocus(){
|
406
|
textareaFocus(){
|
539
|
if(this.popupLayerClass=='showLayer' && this.hideMore == false){
|
407
|
if(this.popupLayerClass=='showLayer' && this.hideMore == false){
|
|
@@ -574,13 +442,31 @@ |
|
@@ -574,13 +442,31 @@ |
574
|
|
442
|
|
575
|
// 发送消息
|
443
|
// 发送消息
|
576
|
sendMsg(content,type){
|
444
|
sendMsg(content,type){
|
577
|
- let message = this.tim.createTextMessage({
|
|
|
578
|
- to: this.toUserId.toString(),
|
445
|
+ let message
|
|
|
446
|
+ let toUserId = this.toUserId.toString()
|
|
|
447
|
+ if(type == 'text'){
|
|
|
448
|
+ message = this.tim.createTextMessage({
|
|
|
449
|
+ to: toUserId,
|
579
|
conversationType: 'C2C',
|
450
|
conversationType: 'C2C',
|
580
|
payload: {
|
451
|
payload: {
|
581
|
text: content.text
|
452
|
text: content.text
|
582
|
}
|
453
|
}
|
583
|
});
|
454
|
});
|
|
|
455
|
+ }
|
|
|
456
|
+ if(type == 'custom'){
|
|
|
457
|
+ message = this.tim.createCustomMessage({
|
|
|
458
|
+ to: toUserId,
|
|
|
459
|
+ conversationType: 'C2C',
|
|
|
460
|
+ // 消息优先级,用于群聊(v2.4.2起支持)。如果某个群的消息超过了频率限制,后台会优先下发高优先级的消息,详细请参考:https://cloud.tencent.com/document/product/269/3663#.E6.B6.88.E6.81.AF.E4.BC.98.E5.85.88.E7.BA.A7.E4.B8.8E.E9.A2.91.E7.8E.87.E6.8E.A7.E5.88.B6)
|
|
|
461
|
+ // 支持的枚举值:TIM.TYPES.MSG_PRIORITY_HIGH, TIM.TYPES.MSG_PRIORITY_NORMAL(默认), TIM.TYPES.MSG_PRIORITY_LOW, TIM.TYPES.MSG_PRIORITY_LOWEST
|
|
|
462
|
+ // priority: TIM.TYPES.MSG_PRIORITY_HIGH,
|
|
|
463
|
+ payload: {
|
|
|
464
|
+ data: content.text, // 用于标识该消息是骰子类型消息
|
|
|
465
|
+ description: String(this.random(1,6)), // 获取骰子点数
|
|
|
466
|
+ extension: ''
|
|
|
467
|
+ }
|
|
|
468
|
+ });
|
|
|
469
|
+ }
|
584
|
this.$store.commit('pushCurrentMessageList', message)
|
470
|
this.$store.commit('pushCurrentMessageList', message)
|
585
|
let pomise = this.tim.sendMessage(message)
|
471
|
let pomise = this.tim.sendMessage(message)
|
586
|
pomise.then(res=>{
|
472
|
pomise.then(res=>{
|
|
@@ -589,177 +475,10 @@ |
|
@@ -589,177 +475,10 @@ |
589
|
this.scrollToView = res.data.message.ID
|
475
|
this.scrollToView = res.data.message.ID
|
590
|
});
|
476
|
});
|
591
|
})
|
477
|
})
|
592
|
- },
|
|
|
593
|
|
478
|
|
594
|
- // 添加文字消息到列表
|
|
|
595
|
- addTextMsg(msg){
|
|
|
596
|
- this.msgList.push(msg);
|
|
|
597
|
},
|
479
|
},
|
598
|
- // 添加语音消息到列表
|
|
|
599
|
- addVoiceMsg(msg){
|
|
|
600
|
- this.msgList.push(msg);
|
|
|
601
|
- },
|
|
|
602
|
- // 添加图片消息到列表
|
|
|
603
|
- addImgMsg(msg){
|
|
|
604
|
- msg.msg.content = this.setPicSize(msg.msg.content);
|
|
|
605
|
- this.msgImgList.push(msg.msg.content.url);
|
|
|
606
|
- this.msgList.push(msg);
|
|
|
607
|
- },
|
|
|
608
|
- addRedEnvelopeMsg(msg){
|
|
|
609
|
- this.msgList.push(msg);
|
|
|
610
|
- },
|
|
|
611
|
- // 添加系统文字消息到列表
|
|
|
612
|
- addSystemTextMsg(msg){
|
|
|
613
|
- this.msgList.push(msg);
|
|
|
614
|
- },
|
|
|
615
|
- // 添加系统红包消息到列表
|
|
|
616
|
- addSystemRedEnvelopeMsg(msg){
|
|
|
617
|
- this.msgList.push(msg);
|
|
|
618
|
- },
|
|
|
619
|
- // 打开红包
|
|
|
620
|
- openRedEnvelope(msg,index){
|
|
|
621
|
- let rid = msg.content.rid;
|
|
|
622
|
- uni.showLoading({
|
|
|
623
|
- title:'加载中...'
|
|
|
624
|
- });
|
|
|
625
|
- //模拟请求服务器效果
|
|
|
626
|
- setTimeout(()=>{
|
|
|
627
|
- //加载数据
|
|
|
628
|
- if(rid==0){
|
|
|
629
|
- this.redenvelopeData={
|
|
|
630
|
- rid:0, //红包ID
|
|
|
631
|
- from:"大黑哥",
|
|
|
632
|
- face:"/static/img/im/face/face.jpg",
|
|
|
633
|
- blessing:"恭喜发财,大吉大利",
|
|
|
634
|
- money:"已领完"
|
|
|
635
|
- }
|
|
|
636
|
- }else{
|
|
|
637
|
- this.redenvelopeData={
|
|
|
638
|
- rid:1, //红包ID
|
|
|
639
|
- from:"售后客服008",
|
|
|
640
|
- face:"/static/img/im/face/face_2.jpg",
|
|
|
641
|
- blessing:"恭喜发财",
|
|
|
642
|
- money:"0.01"
|
|
|
643
|
- }
|
|
|
644
|
- if(!msg.content.isReceived){
|
|
|
645
|
- // {type:"system",msg:{id:8,type:"redEnvelope",content:{text:"你领取了售后客服008的红包"}}},
|
|
|
646
|
- this.sendSystemMsg({text:"你领取了"+(msg.userinfo.uid==this.myuid?"自己":msg.userinfo.username)+"的红包"},'redEnvelope');
|
|
|
647
|
- this.msgList[index].msg.content.isReceived = true;
|
|
|
648
|
- }
|
|
|
649
|
- }
|
|
|
650
|
- uni.hideLoading();
|
|
|
651
|
- this.windowsState = 'show';
|
|
|
652
|
-
|
|
|
653
|
- },200)
|
|
|
654
|
- },
|
|
|
655
|
-
|
|
|
656
|
- // 关闭红包弹窗
|
|
|
657
|
- closeRedEnvelope(){
|
|
|
658
|
- this.windowsState = 'hide';
|
|
|
659
|
- setTimeout(()=>{
|
|
|
660
|
- this.windowsState = '';
|
|
|
661
|
- },200)
|
|
|
662
|
- },
|
|
|
663
|
- sendSystemMsg(content,type){
|
|
|
664
|
- let lastid = this.msgList[this.msgList.length-1].msg.id;
|
|
|
665
|
- lastid++;
|
|
|
666
|
- let row = {type:"system",msg:{id:lastid,type:type,content:content}};
|
|
|
667
|
- this.screenMsg(row)
|
|
|
668
|
- },
|
|
|
669
|
- //领取详情
|
|
|
670
|
- toDetails(rid){
|
|
|
671
|
- uni.navigateTo({
|
|
|
672
|
- url:'HM-details/HM-details?rid='+rid
|
|
|
673
|
- })
|
|
|
674
|
- },
|
|
|
675
|
- // 预览图片
|
|
|
676
|
- showPic(msg){
|
|
|
677
|
- uni.previewImage({
|
|
|
678
|
- indicator:"none",
|
|
|
679
|
- current:msg.content.url,
|
|
|
680
|
- urls: this.msgImgList
|
|
|
681
|
- });
|
|
|
682
|
- },
|
|
|
683
|
- // 播放语音
|
|
|
684
|
- playVoice(msg){
|
|
|
685
|
- this.playMsgid=msg.id;
|
|
|
686
|
- this.AUDIO.src = msg.content.url;
|
|
|
687
|
- this.$nextTick(function() {
|
|
|
688
|
- this.AUDIO.play();
|
|
|
689
|
- });
|
|
|
690
|
- },
|
|
|
691
|
- // 录音开始
|
|
|
692
|
- voiceBegin(e){
|
|
|
693
|
- if(e.touches.length>1){
|
|
|
694
|
- return ;
|
|
|
695
|
- }
|
|
|
696
|
- this.initPoint.Y = e.touches[0].clientY;
|
|
|
697
|
- this.initPoint.identifier = e.touches[0].identifier;
|
|
|
698
|
- this.RECORDER.start({format:"mp3"});//录音开始,
|
|
|
699
|
- },
|
|
|
700
|
- //录音开始UI效果
|
|
|
701
|
- recordBegin(e){
|
|
|
702
|
- this.recording = true;
|
|
|
703
|
- this.voiceTis='松开 结束';
|
|
|
704
|
- this.recordLength = 0;
|
|
|
705
|
- this.recordTimer = setInterval(()=>{
|
|
|
706
|
- this.recordLength++;
|
|
|
707
|
- },1000)
|
|
|
708
|
- },
|
|
|
709
|
- // 录音被打断
|
|
|
710
|
- voiceCancel(){
|
|
|
711
|
- this.recording = false;
|
|
|
712
|
- this.voiceTis='按住 说话';
|
|
|
713
|
- this.recordTis = '手指上滑 取消发送'
|
|
|
714
|
- this.willStop = true;//不发送录音
|
|
|
715
|
- this.RECORDER.stop();//录音结束
|
|
|
716
|
- },
|
|
|
717
|
- // 录音中(判断是否触发上滑取消发送)
|
|
|
718
|
- voiceIng(e){
|
|
|
719
|
- if(!this.recording){
|
|
|
720
|
- return;
|
|
|
721
|
- }
|
|
|
722
|
- let touche = e.touches[0];
|
|
|
723
|
- //上滑一个导航栏的高度触发上滑取消发送
|
|
|
724
|
- if(this.initPoint.Y - touche.clientY>=uni.upx2px(100)){
|
|
|
725
|
- this.willStop = true;
|
|
|
726
|
- this.recordTis = '松开手指 取消发送'
|
|
|
727
|
- }else{
|
|
|
728
|
- this.willStop = false;
|
|
|
729
|
- this.recordTis = '手指上滑 取消发送'
|
|
|
730
|
- }
|
|
|
731
|
- },
|
|
|
732
|
- // 结束录音
|
|
|
733
|
- voiceEnd(e){
|
|
|
734
|
- if(!this.recording){
|
|
|
735
|
- return;
|
|
|
736
|
- }
|
|
|
737
|
- this.recording = false;
|
|
|
738
|
- this.voiceTis='按住 说话';
|
|
|
739
|
- this.recordTis = '手指上滑 取消发送'
|
|
|
740
|
- this.RECORDER.stop();//录音结束
|
|
|
741
|
- },
|
|
|
742
|
- //录音结束(回调文件)
|
|
|
743
|
- recordEnd(e){
|
|
|
744
|
- clearInterval(this.recordTimer);
|
|
|
745
|
- if(!this.willStop){
|
|
|
746
|
- let msg = {
|
|
|
747
|
- length:0,
|
|
|
748
|
- url:e.tempFilePath
|
|
|
749
|
- }
|
|
|
750
|
- let min = parseInt(this.recordLength/60);
|
|
|
751
|
- let sec = this.recordLength%60;
|
|
|
752
|
- min = min<10?'0'+min:min;
|
|
|
753
|
- sec = sec<10?'0'+sec:sec;
|
|
|
754
|
- msg.length = min+':'+sec;
|
|
|
755
|
- this.sendMsg(msg,'voice');
|
|
|
756
|
- }
|
|
|
757
|
- this.willStop = false;
|
|
|
758
|
- },
|
|
|
759
|
- // 切换语音/文字输入
|
|
|
760
|
- switchVoice(){
|
|
|
761
|
- this.hideDrawer();
|
|
|
762
|
- this.isVoice = this.isVoice?false:true;
|
480
|
+ random(min, max) {
|
|
|
481
|
+ return Math.floor(Math.random() * (max - min + 1) + min);
|
763
|
},
|
482
|
},
|
764
|
discard(){
|
483
|
discard(){
|
765
|
return;
|
484
|
return;
|