Commit d90d5d90 by chenwq

直播

1 parent 3af62674
...@@ -55,5 +55,16 @@ export default { ...@@ -55,5 +55,16 @@ export default {
url, url,
data 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 \ No newline at end of file
}
<template> <template>
<div <div
:class="['action isFullSucreen flex']" :class="['action isFullSucreen flex', { bgBlack: bgBlack }]"
v-if="show" v-if="show"
> >
<div class="btn-box flex"> <div class="btn-box flex" v-show="!bgBlack">
<div <div
class="item" class="item"
@click="getPoster" @click="getPoster"
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
@touchstart="touchstart" @touchstart="touchstart"
@touchend="touchend" @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-if="detail.activityStatus == 3">活动已结束</template>
<template v-else> <template v-else>
<template v-if="detail.buyFlag == 3">继续参团</template> <template v-if="detail.buyFlag == 3">继续参团</template>
...@@ -145,6 +145,12 @@ export default { ...@@ -145,6 +145,12 @@ export default {
iSMiniprogram: true iSMiniprogram: true
} }
}, },
props: {
bgBlack: {
type: Boolean,
default: false
}
},
mounted () { mounted () {
this.iSMiniprogram = window.__wxjs_environment === 'miniprogram' this.iSMiniprogram = window.__wxjs_environment === 'miniprogram'
}, },
...@@ -330,6 +336,10 @@ export default { ...@@ -330,6 +336,10 @@ export default {
width: 150px; width: 150px;
} }
} }
.bgBlack {
background: rgba(#000000, 0.6);
z-index: 9;
}
@keyframes show-goods-action { @keyframes show-goods-action {
0% { 0% {
bottom: -100%; bottom: -100%;
...@@ -353,4 +363,4 @@ export default { ...@@ -353,4 +363,4 @@ export default {
box-shadow: 0px 2px 8px 0px rgba(201, 202, 204, 0.5); box-shadow: 0px 2px 8px 0px rgba(201, 202, 204, 0.5);
border-radius: 4px; border-radius: 4px;
} }
</style>
\ No newline at end of file \ No newline at end of file
</style>
<template> <template>
<van-overlay :show="show"> <van-overlay :show="show">
<div <div class="wrapper">
class="wrapper" <div :class="['kf-box flex']">
@click.self="cancel" <template>
>
<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">
<div class="qr-box"> <div class="qr-box">
<div class="sprite-icon icon-qr"></div> <img src="@/assets/images/qr-bg.png"/>
<img <img :src="detail.groupQrCode" class="qr xy-center" />
: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>
</div> </div>
<div class="btn" @click="save">长按识别二维码加群</div>
</template> </template>
</div> </div>
<div class="sprite-icon icon-close" @click.self="cancel"></div>
</div> </div>
</van-overlay> </van-overlay>
</template> </template>
...@@ -46,24 +19,24 @@ ...@@ -46,24 +19,24 @@
export default { export default {
name: 'KfModal', name: 'KfModal',
props: ['value', 'detail'], props: ['value', 'detail'],
data () { data() {
return { return {
show: false, show: false,
img: null img: null
} }
}, },
mounted () { }, mounted() { },
watch: { watch: {
value (n) { value(n) {
this.show = n this.show = n
} }
}, },
methods: { methods: {
cancel () { cancel() {
this.show = false this.show = false
this.$parent.showKf = false this.$parent.showKf = false
}, },
save () { save() {
this.showToast('请长按二维码保存') this.showToast('请长按二维码保存')
} }
} }
...@@ -81,67 +54,34 @@ export default { ...@@ -81,67 +54,34 @@ export default {
height: 100%; height: 100%;
flex-direction: column; flex-direction: column;
.kf-box { .kf-box {
width: 300px; width: 273px;
height: 350px; height: 298px;
position: relative; position: relative;
flex-direction: column; flex-direction: column;
font-size: 18px; font-size: 18px;
font-weight: 500; font-weight: 500;
color: #282829; background: rgba(#000000, 0.3);
.icon-kf-box { border-radius: 8px;
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;
}
}
.qr-box { .qr-box {
position: relative; position: relative;
width: 143px; margin: 29px 0 19px;
height: 142px; width: 180px;
margin: 10px 0 16px; height: 180px;
.qr { .qr {
width: calc(100% - 32px); width: calc(100% - 38px);
height: calc(100% - 32px); height: calc(100% - 38px);
} }
} }
.bottom { .btn {
position: absolute; font-size: 17px;
left: 0; font-family: PingFangSC-Semibold, PingFang SC;
bottom: 0; font-weight: 600;
z-index: 2; color: #ffffff;
width: 100%; line-height: 24px;
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;
}
}
} }
} }
.short { .icon-close {
height: 140px; margin-top: 16px;
.icon-kf-box {
height: 100%;
border-radius: 12px;
}
} }
} }
</style>
\ No newline at end of file \ No newline at end of file
</style>
<template> <template>
<div :class="['live-box', { videoFullscreen: videoFullscreen }]" :style="videoStyle" id="live-box"> <div :class="['live-box', { videoFullscreen: videoFullscreen }]" :style="videoStyle" id="live-box">
<div class="mask" @click="openFullscreen"> <div :class="{ videoShort: detail.activityStatus != 3 && detail.buyFlag != 2 }">
<div class="sprite-icon icon-live-close"></div> <div class="mask" @click="openFullscreen">
<div class="status flex"> <div class="sprite-icon icon-live-close" @click="handleClose"></div>
<div class="live-line"> <div class="status flex">
<div class="side"></div> <div class="live-line">
<div class="center side"></div> <div class="side"></div>
<div class="side"></div> <div class="center side"></div>
<div class="side"></div>
</div>
<div class="text">正在直播</div>
</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> </div>
<template v-if="!IsIOS"> <div class="fullscreen-btn" @click="openFullscreen(false)">
<img src="https://wimg.588ku.com/gif620/20/04/23/79a7882dfb0c59497976fd8b3bfe60ef.gif" alt="" /> <img src="https://img02.glsx.com.cn/weapp/resource/scrm-mobile/crowdfunding/fullscreen.png" />
</template> </div>
</div> <div class="poster-btn" @click="showKf = true">
<div class="fullscreen-btn" @click="openFullscreen(false)"> <img src="https://img02.glsx.com.cn/weapp/resource/scrm-mobile/crowdfunding/gift.gif" />
<img src="https://img02.glsx.com.cn/weapp/resource/scrm-mobile/crowdfunding/fullscreen.png" /> </div>
</div> <video id="player-container-id" preload="auto" playsinline webkit-playsinline></video>
<div class="poster-btn" @click="showKf = true"> <kf-modal v-model="showKf" :detail="detail" />
<img src="https://img02.glsx.com.cn/weapp/resource/scrm-mobile/crowdfunding/gift.gif" />
</div> </div>
<video id="player-container-id" preload="auto" playsinline webkit-playsinline></video> <action :bgBlack="true" v-show="videoFullscreen && detail.activityStatus != 3 && detail.buyFlag != 2"></action>
<kf-modal v-model="showKf" :detail="detail" />
</div> </div>
</template> </template>
<script type="text/ecmascript-6"> <script type="text/ecmascript-6">
import { wxConfig } from '@/api' import { wxConfig } from '@/api'
export default { export default {
name: 'LiveBox', name: 'LiveBox',
data () { data() {
return { return {
player: null, player: null,
videoFullscreen: false, videoFullscreen: false,
showKf: false, showKf: false,
detail: { isShowGif: false,
customerServiceQrImg: 'https://img02.glsx.com.cn/weapp/resource/h5/images/123.png' // detail: {
}, // customerServiceQrImg: 'https://img02.glsx.com.cn/weapp/resource/h5/images/123.png'
// },
videoStyle: '' 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 let _this = this
if (!this.IsIOS) {
this.changeGifStatus()
}
wxConfig.ready(() => { wxConfig.ready(() => {
if (Hls.isSupported()) { if (Hls.isSupported()) {
_this.video = document.getElementById('player-container-id'); _this.video = document.getElementById('player-container-id')
_this.hls = new Hls(); _this.hls = new Hls()
// bind them together // bind them together
_this.hls.attachMedia(_this.video); _this.hls.attachMedia(_this.video)
} }
_this.player = TCPlayer('player-container-id', { _this.player = TCPlayer('player-container-id', {
// fileID: '387702305074716718', //点播ID // fileID: '387702305074716718', // 点播ID
// appID: '1311227058', //点播APPID // appID: '1311227058', // 点播APPID
// src: 'webrtc://play.glsx.com.cn/crowdFunding/7f65f8f80989b46',
autoplay: true, // 自动播放 autoplay: true, // 自动播放
loop: true, // 循环播放 loop: true, // 循环播放
muted: true, //是否静音 volume: 1,
controlBar: { //控制条配置 muted: false, // 是否静音
fullscreenToggle: 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日志 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') _this.player.src('webrtc://play.glsx.com.cn/live/live_normal')
wx.getNetworkType({ wx.getNetworkType({
success: (result) => { success: (result) => {
_this.player.ready(function () { //设置播放器初始化完成后的回调 _this.player.ready(function () { // 设置播放器初始化完成后的回调
console.log('-------------------------', _this.player.poster()) _this.player.poster()
_this.player.play() //播放视频 _this.player.play() // 播放视频
_this.draggable(document.getElementById('live-box'), _this.openFullscreen) _this.draggable(document.getElementById('live-box'), _this.openFullscreen)
}) })
} }
}) })
_this.player.on('webrtcevent', function (event) { //监听webrtc _this.player.on('play', () => {
console.log(event) 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) { _this.hls.on(Hls.Events.ERROR, function (event, data) {
if (data.fatal) { if (data.fatal) {
switch (data.type) { switch (data.type) {
case Hls.ErrorTypes.NETWORK_ERROR: case Hls.ErrorTypes.NETWORK_ERROR:
// try to recover 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() _this.hls.startLoad()
break break
case Hls.ErrorTypes.MEDIA_ERROR: case Hls.ErrorTypes.MEDIA_ERROR:
console.log('fatal media error encountered, try to recover'); // console.log('fatal media error encountered, try to recover')
_this.hls.recoverMediaError(); _this.hls.recoverMediaError()
break; break
default: default:
// cannot recover // cannot recover
_this.hls.destroy(); _this.hls.destroy()
break; break
} }
} }
}); })
}) },
}, changeGifStatus() {
methods: { this.isShowGif = !this.isShowGif
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'
}, },
handleClose() {
this.$emit.liveClose()
}
} }
} }
</script> </script>
...@@ -193,6 +245,10 @@ export default { ...@@ -193,6 +245,10 @@ export default {
right: 0 !important; right: 0 !important;
bottom: 0 !important; bottom: 0 !important;
border: none !important; border: none !important;
background: #000000;
.videoShort {
height: calc(100vh - 13.333vh) !important;
}
.mask { .mask {
display: none; display: none;
} }
...@@ -204,4 +260,4 @@ export default { ...@@ -204,4 +260,4 @@ export default {
opacity: 1 !important; opacity: 1 !important;
} }
} }
</style>
\ No newline at end of file \ 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!