Commit d5413610 by chenwq

IM

1 parent 9bc52d4c

446 Bytes | W: | H:

952 Bytes | W: | H:

src/assets/images/send.png
src/assets/images/send.png
src/assets/images/send.png
src/assets/images/send.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -123,50 +123,6 @@ export default { ...@@ -123,50 +123,6 @@ export default {
this.createPlayerCover() this.createPlayerCover()
this.createPlayer() this.createPlayer()
this.play() 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: { methods: {
createPlayerCover() { createPlayerCover() {
...@@ -186,6 +142,10 @@ export default { ...@@ -186,6 +142,10 @@ export default {
this.player.src(src) this.player.src(src)
this.player.poster() this.player.poster()
this.player.play() // 播放视频 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') this.draggable(document.getElementById('live-box'), this.openFullscreen, 'icon-live-close')
}) })
} }
......
...@@ -6,11 +6,9 @@ ...@@ -6,11 +6,9 @@
<div class="chatUser-box"> <div class="chatUser-box">
<div class="chatUser-info"> <div class="chatUser-info">
<span class="chatUser-info-text notice"> <span class="chatUser-info-text notice">
<p>
<img class="icon-notice" src="@/assets/images/icon-notice.png" /> <img class="icon-notice" src="@/assets/images/icon-notice.png" />
欢迎来到直播间! 欢迎来到直播间!
<span>{{ notifyTxt }}</span> <p>{{ notifyTxt }}</p>
</p>
</span> </span>
</div> </div>
</div> </div>
...@@ -25,10 +23,10 @@ ...@@ -25,10 +23,10 @@
</div> </div>
</div> </div>
<div class="chatBox-infoDesk" action="javascript:return true"> <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-field :class="['chatBox-input', isFocus ? 'focus-input' : '']" v-model="messageContent" maxlength="200" center placeholder="聊一聊..." use-button-slot @click="fixInputBeCovered($event)" @focus="handleInputFocus" @blur="handleInputFocus">
<!-- <van-button slot="button" size="small" type="info" @click="sendTextMessage">发送</van-button> --> <img class="icon-send" slot="button" @click="sendTextMessage" src="@/assets/images/send.png" />
</van-field> </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> </div>
</div> </div>
...@@ -39,13 +37,15 @@ import { util } from 'utils' ...@@ -39,13 +37,15 @@ import { util } from 'utils'
import { shopmallApi } from '@/api' import { shopmallApi } from '@/api'
import IM from './im.js' import IM from './im.js'
let timObj = null let timObj = null
const msgMaxNum = 100
export default { export default {
name: 'Im', name: 'Im',
data() { data() {
return { return {
messageContent: '', isFocus: false,
notifyTxt: '直播间内严禁出现违法违规、低俗、涉黄、吸烟酗酒等内容,直播期间请勿相信私下交易,诱导购买等信息,以防人身或财产损失。请大家注意财产安全,谨防网络诈骗,文明观看直播。', notifyTxt: '直播间内严禁出现违法违规、低俗、涉黄、吸烟酗酒等内容,直播期间请勿相信私下交易,诱导购买等信息,以防人身或财产损失。请大家注意财产安全,谨防网络诈骗,文明观看直播。',
messageContent: '',
messageList: [] messageList: []
} }
}, },
...@@ -82,6 +82,12 @@ export default { ...@@ -82,6 +82,12 @@ export default {
target.scrollIntoView(true) target.scrollIntoView(true)
}, 100) }, 100)
}, },
handleInputFocus() {
clearTimeout(this.timer)
this.timer = setTimeout(() => {
this.isFocus = !this.isFocus
}, 300)
},
getUserSig() { getUserSig() {
const userInfo = util.getUserInfo() const userInfo = util.getUserInfo()
// userId = this.userInfo.openid || this.userInfo.uuid // userId = this.userInfo.openid || this.userInfo.uuid
...@@ -103,12 +109,12 @@ export default { ...@@ -103,12 +109,12 @@ export default {
} }
timObj = new IM(imOptions) timObj = new IM(imOptions)
timObj.join(imOptions).then(res => { timObj.join(imOptions).then(res => {
console.log('login-------') // console.log('login-------')
}) })
}, },
// 收到消息触发 // 收到消息触发
onMessageReceived(data) { onMessageReceived(data) {
console.log('收到消息:', data) // console.log('收到消息:', data)
data.forEach(item => { data.forEach(item => {
// 根据消息类型判断,执行不同操作 // 根据消息类型判断,执行不同操作
...@@ -131,6 +137,10 @@ export default { ...@@ -131,6 +137,10 @@ export default {
// 更新数据push进消息列表 // 更新数据push进消息列表
updateMessageList(data) { updateMessageList(data) {
this.messageList = [...this.messageList, data] this.messageList = [...this.messageList, data]
let msgLen = this.messageList.length
if (msgLen > msgMaxNum) {
this.messageList = this.messageList.slice(msgLen - msgMaxNum)
}
this.scrollToBottom() this.scrollToBottom()
}, },
// changeChatHeight(height = '230px') { // changeChatHeight(height = '230px') {
...@@ -185,10 +195,24 @@ body { ...@@ -185,10 +195,24 @@ body {
margin: 0 10px 10px; margin: 0 10px 10px;
.chatBox-input { .chatBox-input {
width: 148px; width: 148px;
background-color: transparent; // background-color: transparent;
background-color: rgba(255, 255, 255, 0.4) !important;
border-radius: 2rem !important;
margin-right: 8px; margin-right: 8px;
padding: 0 0; padding: 0 0;
color: #ffffff; 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 { .action {
width: calc(100% - 156px); width: calc(100% - 156px);
...@@ -247,8 +271,8 @@ body { ...@@ -247,8 +271,8 @@ body {
</style> </style>
<style> <style>
#chat .chatBox-infoDesk .chatBox-input .van-field__control { #chat .chatBox-infoDesk .chatBox-input .van-field__control {
background-color: rgba(255, 255, 255, 0.4) !important; /* background-color: rgba(255, 255, 255, 0.4) !important;
border-radius: 2rem !important; border-radius: 2rem !important; */
color: #ffffff; color: #ffffff;
height: 40px; height: 40px;
padding: 0 10px; padding: 0 10px;
......
...@@ -26,7 +26,7 @@ export default class IM { ...@@ -26,7 +26,7 @@ export default class IM {
// 创建 SDK 实例,`TIM.create()`方法对于同一个 `SDKAppID` 只会返回同一份实例 // 创建 SDK 实例,`TIM.create()`方法对于同一个 `SDKAppID` 只会返回同一份实例
this.tim = TIM.create({ SDKAppID: this.options.SDKAppID }) // SDK 实例通常用 tim 表示 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> // 设置 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 输出关键信息,生产环境时建议使用 // tim.setLogLevel(1); // release 级别,SDK 输出关键信息,生产环境时建议使用
// 注册腾讯云即时通信 IM 上传插件 // 注册腾讯云即时通信 IM 上传插件
this.tim.registerPlugin({ 'tim-upload-plugin': TIMUploadPlugin }) this.tim.registerPlugin({ 'tim-upload-plugin': TIMUploadPlugin })
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!