Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx
/
scrm-wx-merchant-activity
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit d5413610
authored
Nov 02, 2022
by
chenwq
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
IM
1 parent
9bc52d4c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
59 deletions
src/assets/images/send.png
src/components/LiveBox.vue
src/components/TIM/Im.vue
src/components/TIM/im.js
src/assets/images/send.png
View file @
d541361
446 Bytes
|
W:
|
H:
952 Bytes
|
W:
|
H:
2-up
Swipe
Onion skin
src/components/LiveBox.vue
View file @
d541361
...
...
@@ -123,50 +123,6 @@ export default {
this
.
createPlayerCover
()
this
.
createPlayer
()
this
.
play
()
// console.log('2222222222', this.liveDetail);
// const _this = this
// if (!this.IsIOS) {
// this.changeGifStatus()
// }
// wxConfig.ready(() => {
// if (Hls.isSupported()) {
// _this.video = document.getElementById('player-container-id')
// _this.hls = new Hls()
// // bind them together
// _this.hls.attachMedia(_this.video)
// }
// const playParams = {
// autoplay: true, // 自动播放
// loop: true, // 循环播放
// // muted: false, // 是否静音
// controlBar: { // 控制条配置
// fullscreenToggle: false // 隐藏全屏按钮
// },
// webrtcConfig: { // webrtcConfig 参数列表
// showLog: true // 打印webrtc日志
// }
// }
// _this.player = TCPlayer('player-container-id', playParams)
// wx.getNetworkType({
// success: (result) => {
// _this.player.ready(function() { // 设置播放器初始化完成后的回调
// const src = _this.LiveStatus[_this.liveDetail.status] == 'live' ? _this.liveDetail.playPath : (_this.liveDetail.liveBroadcastRecordingFileList.length ? _this.liveDetail.liveBroadcastRecordingFileList[0].videoUrl : '')
// _this.player.src(src)
// _this.player.poster()
// _this.player.play() // 播放视频
// _this.draggable(document.getElementById('live-box'), _this.openFullscreen)
// })
// }
// })
// _this.player.on('play', () => {
// this.changeGifStatus()
// })
// _this.player.on('pause', () => {
// this.changeGifStatus()
// })
// _this.dealTcPlayerErr14(_this)
// })
},
methods
:
{
createPlayerCover
()
{
...
...
@@ -186,6 +142,10 @@ export default {
this
.
player
.
src
(
src
)
this
.
player
.
poster
()
this
.
player
.
play
()
// 播放视频
// this.player.on('error', function (event) {
// // 从回调参数 event 中获取事件状态码及相关数据
// console.log(event, 'error-----------')
// })
this
.
draggable
(
document
.
getElementById
(
'live-box'
),
this
.
openFullscreen
,
'icon-live-close'
)
})
}
...
...
src/components/TIM/Im.vue
View file @
d541361
...
...
@@ -6,11 +6,9 @@
<div
class=
"chatUser-box"
>
<div
class=
"chatUser-info"
>
<span
class=
"chatUser-info-text notice"
>
<p>
<img
class=
"icon-notice"
src=
"@/assets/images/icon-notice.png"
/>
欢迎来到直播间!
<span>
{{
notifyTxt
}}
</span>
</p>
<img
class=
"icon-notice"
src=
"@/assets/images/icon-notice.png"
/>
欢迎来到直播间!
<p>
{{
notifyTxt
}}
</p>
</span>
</div>
</div>
...
...
@@ -25,10 +23,10 @@
</div>
</div>
<div
class=
"chatBox-infoDesk"
action=
"javascript:return true"
>
<van-field
class=
"chatBox-input"
v-model=
"messageContent"
center
placeholder=
"聊一聊..."
use-button-slot
type=
"search"
@
blur=
"sendTextMessage"
@
click=
"fixInputBeCovered($event)
"
>
<
!--
<van-button
slot=
"button"
size=
"small"
type=
"info"
@
click=
"sendTextMessage"
>
发送
</van-button>
--
>
<van-field
:class=
"['chatBox-input', isFocus ? 'focus-input' : '']"
v-model=
"messageContent"
maxlength=
"200"
center
placeholder=
"聊一聊..."
use-button-slot
@
click=
"fixInputBeCovered($event)"
@
focus=
"handleInputFocus"
@
blur=
"handleInputFocus
"
>
<
img
class=
"icon-send"
slot=
"button"
@
click=
"sendTextMessage"
src=
"@/assets/images/send.png"
/
>
</van-field>
<action
:bgBlack=
"true"
class=
"action"
v-show=
"isAction"
:isImAction=
"true"
></action>
<action
:bgBlack=
"true"
class=
"action"
v-show=
"isAction
&& !isFocus
"
:isImAction=
"true"
></action>
</div>
</div>
</div>
...
...
@@ -39,13 +37,15 @@ import { util } from 'utils'
import
{
shopmallApi
}
from
'@/api'
import
IM
from
'./im.js'
let
timObj
=
null
const
msgMaxNum
=
100
export
default
{
name
:
'Im'
,
data
()
{
return
{
messageContent
:
''
,
isFocus
:
false
,
notifyTxt
:
'直播间内严禁出现违法违规、低俗、涉黄、吸烟酗酒等内容,直播期间请勿相信私下交易,诱导购买等信息,以防人身或财产损失。请大家注意财产安全,谨防网络诈骗,文明观看直播。'
,
messageContent
:
''
,
messageList
:
[]
}
},
...
...
@@ -82,6 +82,12 @@ export default {
target
.
scrollIntoView
(
true
)
},
100
)
},
handleInputFocus
()
{
clearTimeout
(
this
.
timer
)
this
.
timer
=
setTimeout
(()
=>
{
this
.
isFocus
=
!
this
.
isFocus
},
300
)
},
getUserSig
()
{
const
userInfo
=
util
.
getUserInfo
()
// userId = this.userInfo.openid || this.userInfo.uuid
...
...
@@ -103,12 +109,12 @@ export default {
}
timObj
=
new
IM
(
imOptions
)
timObj
.
join
(
imOptions
).
then
(
res
=>
{
console
.
log
(
'login-------'
)
//
console.log('login-------')
})
},
// 收到消息触发
onMessageReceived
(
data
)
{
console
.
log
(
'收到消息:'
,
data
)
//
console.log('收到消息:', data)
data
.
forEach
(
item
=>
{
// 根据消息类型判断,执行不同操作
...
...
@@ -131,6 +137,10 @@ export default {
// 更新数据push进消息列表
updateMessageList
(
data
)
{
this
.
messageList
=
[...
this
.
messageList
,
data
]
let
msgLen
=
this
.
messageList
.
length
if
(
msgLen
>
msgMaxNum
)
{
this
.
messageList
=
this
.
messageList
.
slice
(
msgLen
-
msgMaxNum
)
}
this
.
scrollToBottom
()
},
// changeChatHeight(height = '230px') {
...
...
@@ -185,10 +195,24 @@ body {
margin
:
0
10px
10px
;
.chatBox-input
{
width
:
148px
;
background-color
:
transparent
;
//
background-color
:
transparent
;
background-color
:
rgba
(
255
,
255
,
255
,
0.4
)
!important
;
border-radius
:
2rem
!important
;
margin-right
:
8px
;
padding
:
0
0
;
color
:
#ffffff
;
.icon-send
{
width
:
20px
;
height
:
20px
;
margin-right
:
10px
;
}
}
.chatBox-input.focus-input
{
width
:
100%
;
transition
:
width
0.5s
;
.icon-send
{
border-radius
:
50%
;
}
}
.action
{
width
:
calc
(
100%
-
156px
);
...
...
@@ -247,8 +271,8 @@ body {
</
style
>
<
style
>
#chat
.chatBox-infoDesk
.chatBox-input
.van-field__control
{
background-color
:
rgba
(
255
,
255
,
255
,
0.4
)
!important
;
border-radius
:
2rem
!important
;
/*
background-color: rgba(255, 255, 255, 0.4) !important;
border-radius: 2rem !important;
*/
color
:
#ffffff
;
height
:
40px
;
padding
:
0
10px
;
...
...
src/components/TIM/im.js
View file @
d541361
...
...
@@ -26,7 +26,7 @@ export default class IM {
// 创建 SDK 实例,`TIM.create()`方法对于同一个 `SDKAppID` 只会返回同一份实例
this
.
tim
=
TIM
.
create
({
SDKAppID
:
this
.
options
.
SDKAppID
})
// SDK 实例通常用 tim 表示
// 设置 SDK 日志输出级别,详细分级请参见 <a href="https://web.sdk.qcloud.com/im/doc/en/SDK.html#setLogLevel">setLogLevel 接口的说明</a>
this
.
tim
.
setLogLevel
(
0
)
// 普通级别,日志量较多,接入时建议使用
this
.
tim
.
setLogLevel
(
1
)
// 普通级别,日志量较多,接入时建议使用
// tim.setLogLevel(1); // release 级别,SDK 输出关键信息,生产环境时建议使用
// 注册腾讯云即时通信 IM 上传插件
this
.
tim
.
registerPlugin
({
'tim-upload-plugin'
:
TIMUploadPlugin
})
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment