Commit d90d5d90 by chenwq

直播

1 parent 3af62674
......@@ -55,5 +55,16 @@ export default {
url,
data
})
},
// 根据众筹id获取直播详情
getLiveDetail(id) {
let data = {
id,
method: 'scrm.api.shopmall.weapp.activity.live.broadcast.detail'
}
return window.$HTTP({
url,
data
})
}
}
\ No newline at end of file
}
<template>
<div
:class="['action isFullSucreen flex']"
:class="['action isFullSucreen flex', { bgBlack: bgBlack }]"
v-if="show"
>
<div class="btn-box flex">
<div class="btn-box flex" v-show="!bgBlack">
<div
class="item"
@click="getPoster"
......@@ -21,7 +21,7 @@
@touchstart="touchstart"
@touchend="touchend"
>
<template v-if="detail.activityStatus == 1">敬请期待</template>
<template v-if="detail.activityStatus == 1">预热下单</template>
<template v-else-if="detail.activityStatus == 3">活动已结束</template>
<template v-else>
<template v-if="detail.buyFlag == 3">继续参团</template>
......@@ -145,6 +145,12 @@ export default {
iSMiniprogram: true
}
},
props: {
bgBlack: {
type: Boolean,
default: false
}
},
mounted () {
this.iSMiniprogram = window.__wxjs_environment === 'miniprogram'
},
......@@ -330,6 +336,10 @@ export default {
width: 150px;
}
}
.bgBlack {
background: rgba(#000000, 0.6);
z-index: 9;
}
@keyframes show-goods-action {
0% {
bottom: -100%;
......@@ -353,4 +363,4 @@ export default {
box-shadow: 0px 2px 8px 0px rgba(201, 202, 204, 0.5);
border-radius: 4px;
}
</style>
\ No newline at end of file
</style>
<template>
<van-overlay :show="show">
<div
class="wrapper"
@click.self="cancel"
>
<div :class="['kf-box flex',{short:!detail.customerServiceQrImg}]">
<div class="sprite-icon icon-kf-box"></div>
<div class="sprite-icon icon-kf-logo x-center"></div>
<div class="info">
<div class="name">{{detail.customerServiceName}}</div>
<template v-if="detail.customerServicePhone">
<div
class="phone flex"
@click="makePhoneCall(detail.customerServicePhone)"
>
<div class="sprite-icon icon-phone"></div>{{detail.customerServicePhone}}
</div>
</template>
</div>
<template v-if="detail.customerServiceQrImg">
<van-overlay :show="show">
<div class="wrapper">
<div :class="['kf-box flex']">
<template>
<div class="qr-box">
<div class="sprite-icon icon-qr"></div>
<img
:src="detail.customerServiceQrImg"
class="qr xy-center"
/>
</div>
<div class="bottom flex">
<div class="item flex">
<div class="sprite-icon icon-download"></div>
<div>保存图片<br>到相册</div>
</div>
<div class="item flex">
<div class="sprite-icon icon-scan"></div>
<div>打开微信扫一扫<br>添加客服企微</div>
</div>
<img src="@/assets/images/qr-bg.png"/>
<img :src="detail.groupQrCode" class="qr xy-center" />
</div>
<div class="btn" @click="save">长按识别二维码加群</div>
</template>
</div>
<div class="sprite-icon icon-close" @click.self="cancel"></div>
</div>
</van-overlay>
</template>
......@@ -46,24 +19,24 @@
export default {
name: 'KfModal',
props: ['value', 'detail'],
data () {
data() {
return {
show: false,
img: null
}
},
mounted () { },
mounted() { },
watch: {
value (n) {
value(n) {
this.show = n
}
},
methods: {
cancel () {
cancel() {
this.show = false
this.$parent.showKf = false
},
save () {
save() {
this.showToast('请长按二维码保存')
}
}
......@@ -81,67 +54,34 @@ export default {
height: 100%;
flex-direction: column;
.kf-box {
width: 300px;
height: 350px;
width: 273px;
height: 298px;
position: relative;
flex-direction: column;
font-size: 18px;
font-weight: 500;
color: #282829;
.icon-kf-box {
position: absolute;
}
.icon-kf-logo {
top: -15px;
}
.info {
position: relative;
z-index: 2;
text-align: center;
padding-top: 64px;
.phone {
letter-spacing: 2px;
margin-top: 1px;
}
}
background: rgba(#000000, 0.3);
border-radius: 8px;
.qr-box {
position: relative;
width: 143px;
height: 142px;
margin: 10px 0 16px;
margin: 29px 0 19px;
width: 180px;
height: 180px;
.qr {
width: calc(100% - 32px);
height: calc(100% - 32px);
width: calc(100% - 38px);
height: calc(100% - 38px);
}
}
.bottom {
position: absolute;
left: 0;
bottom: 0;
z-index: 2;
width: 100%;
height: 70px;
background: #f7f8fa;
border-radius: 0px 0px 10px 10px;
box-sizing: border-box;
padding: 0 20px;
justify-content: space-between;
.item {
padding-left: 7px;
font-size: 12px;
color: #b1b1b3;
.sprite-icon {
margin-right: 6px;
}
}
.btn {
font-size: 17px;
font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600;
color: #ffffff;
line-height: 24px;
}
}
.short {
height: 140px;
.icon-kf-box {
height: 100%;
border-radius: 12px;
}
.icon-close {
margin-top: 16px;
}
}
</style>
\ No newline at end of file
</style>
<template>
<div :class="['live-box', { videoFullscreen: videoFullscreen }]" :style="videoStyle" id="live-box">
<div class="mask" @click="openFullscreen">
<div class="sprite-icon icon-live-close"></div>
<div class="status flex">
<div class="live-line">
<div class="side"></div>
<div class="center side"></div>
<div class="side"></div>
<div :class="{ videoShort: detail.activityStatus != 3 && detail.buyFlag != 2 }">
<div class="mask" @click="openFullscreen">
<div class="sprite-icon icon-live-close" @click="handleClose"></div>
<div class="status flex">
<div class="live-line">
<div class="side"></div>
<div class="center side"></div>
<div class="side"></div>
</div>
<div class="text">正在直播</div>
</div>
<div class="text">正在直播</div>
<template v-if="isShowGif">
<img src="https://wimg.588ku.com/gif620/20/04/23/79a7882dfb0c59497976fd8b3bfe60ef.gif" alt="" />
</template>
</div>
<template v-if="!IsIOS">
<img src="https://wimg.588ku.com/gif620/20/04/23/79a7882dfb0c59497976fd8b3bfe60ef.gif" alt="" />
</template>
</div>
<div class="fullscreen-btn" @click="openFullscreen(false)">
<img src="https://img02.glsx.com.cn/weapp/resource/scrm-mobile/crowdfunding/fullscreen.png" />
</div>
<div class="poster-btn" @click="showKf = true">
<img src="https://img02.glsx.com.cn/weapp/resource/scrm-mobile/crowdfunding/gift.gif" />
<div class="fullscreen-btn" @click="openFullscreen(false)">
<img src="https://img02.glsx.com.cn/weapp/resource/scrm-mobile/crowdfunding/fullscreen.png" />
</div>
<div class="poster-btn" @click="showKf = true">
<img src="https://img02.glsx.com.cn/weapp/resource/scrm-mobile/crowdfunding/gift.gif" />
</div>
<video id="player-container-id" preload="auto" playsinline webkit-playsinline></video>
<kf-modal v-model="showKf" :detail="detail" />
</div>
<video id="player-container-id" preload="auto" playsinline webkit-playsinline></video>
<kf-modal v-model="showKf" :detail="detail" />
<action :bgBlack="true" v-show="videoFullscreen && detail.activityStatus != 3 && detail.buyFlag != 2"></action>
</div>
</template>
<script type="text/ecmascript-6">
import { wxConfig } from '@/api'
export default {
name: 'LiveBox',
data () {
data() {
return {
player: null,
videoFullscreen: false,
showKf: false,
detail: {
customerServiceQrImg: 'https://img02.glsx.com.cn/weapp/resource/h5/images/123.png'
},
isShowGif: false,
// detail: {
// customerServiceQrImg: 'https://img02.glsx.com.cn/weapp/resource/h5/images/123.png'
// },
videoStyle: ''
}
},
mounted () {
props: {
detail: {
type: Object,
default: () => { }
},
liveDetail: {
type: Object,
default: () => {
return {
// 直播状态 0:未开始;1:直播中;2:已结束;
status: 1,
// 直播播放地址(status=1生效)
playPath: '',
// 回放列表
liveBroadcastRecordingFileList: []
}
}
}
},
mounted() {
console.log(this.liveDetail, '============')
let _this = this
if (!this.IsIOS) {
this.changeGifStatus()
}
wxConfig.ready(() => {
if (Hls.isSupported()) {
_this.video = document.getElementById('player-container-id');
_this.hls = new Hls();
_this.video = document.getElementById('player-container-id')
_this.hls = new Hls()
// bind them together
_this.hls.attachMedia(_this.video);
_this.hls.attachMedia(_this.video)
}
_this.player = TCPlayer('player-container-id', {
// fileID: '387702305074716718', //点播ID
// appID: '1311227058', //点播APPID
// fileID: '387702305074716718', // 点播ID
// appID: '1311227058', // 点播APPID
// src: 'webrtc://play.glsx.com.cn/crowdFunding/7f65f8f80989b46',
autoplay: true, // 自动播放
loop: true, // 循环播放
muted: true, //是否静音
controlBar: { //控制条配置
fullscreenToggle: false //隐藏全屏按钮
volume: 1,
muted: false, // 是否静音
controlBar: { // 控制条配置
// fullscreenToggle: false // 隐藏全屏按钮
playToggle: false,
progressControl: false,
// volumePanel: false,
currentTimeDisplay: false,
durationDisplay: false,
timeDivider: false,
playbackRateMenuButton: false,
fullscreenToggle: false,
QualitySwitcherMenuButton: false
},
webrtcConfig: { //webrtcConfig 参数列表
webrtcConfig: { // webrtcConfig 参数列表
showLog: true // 打印webrtc日志
}
})
// _this.player.src('http://play.glsx.com.cn/live/live.m3u8') //直播地址
_this.player.src('webrtc://play.glsx.com.cn/live/live_normal')
wx.getNetworkType({
success: (result) => {
_this.player.ready(function () { //设置播放器初始化完成后的回调
console.log('-------------------------', _this.player.poster())
_this.player.play() //播放视频
_this.player.ready(function () { // 设置播放器初始化完成后的回调
_this.player.poster()
_this.player.play() // 播放视频
_this.draggable(document.getElementById('live-box'), _this.openFullscreen)
})
}
})
_this.player.on('webrtcevent', function (event) { //监听webrtc
console.log(event)
_this.player.on('play', () => {
this.changeGifStatus()
})
_this.player.on('pause', () => {
this.changeGifStatus()
})
_this.dealTcPlayerErr14()
})
},
methods: {
// 打开关闭全屏
openFullscreen(status = true) {
let [live] = document.getElementsByClassName('live-box')
let [volumePanel] = document.getElementsByClassName('vjs-volume-panel ')
let [volume] = volumePanel.getElementsByClassName('vjs-mute-control')
volume.click()
this.player.play()
this.videoFullscreen = status
live.id = status ? '' : 'live-box'
this.$emit('handleLiveFull', { isFull: this.videoFullscreen })
},
// 处理tcplayer错误码14
dealTcPlayerErr14(_this) {
_this.hls.on(Hls.Events.ERROR, function (event, data) {
if (data.fatal) {
switch (data.type) {
case Hls.ErrorTypes.NETWORK_ERROR:
// try to recover network error
console.log('fatal network error encountered, try to recover');
// console.log('fatal network error encountered, try to recover')
_this.hls.startLoad()
break
case Hls.ErrorTypes.MEDIA_ERROR:
console.log('fatal media error encountered, try to recover');
_this.hls.recoverMediaError();
break;
// console.log('fatal media error encountered, try to recover')
_this.hls.recoverMediaError()
break
default:
// cannot recover
_this.hls.destroy();
break;
_this.hls.destroy()
break
}
}
});
})
},
methods: {
openFullscreen (status = true) { //打开关闭全屏
let [live] = document.getElementsByClassName('live-box')
let [volumePanel] = document.getElementsByClassName('vjs-volume-panel ')
let [volume] = volumePanel.getElementsByClassName('vjs-mute-control')
volume.click()
this.player.play()
this.videoFullscreen = status
live.id = status ? '' : 'live-box'
})
},
changeGifStatus() {
this.isShowGif = !this.isShowGif
},
handleClose() {
this.$emit.liveClose()
}
}
}
</script>
......@@ -193,6 +245,10 @@ export default {
right: 0 !important;
bottom: 0 !important;
border: none !important;
background: #000000;
.videoShort {
height: calc(100vh - 13.333vh) !important;
}
.mask {
display: none;
}
......@@ -204,4 +260,4 @@ export default {
opacity: 1 !important;
}
}
</style>
\ No newline at end of file
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!