Commit 5c4aaf03 by 李伟康

提交代码

1 parent ff9fe87c
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
.icon-kf-box { width: 300px; height: 350px; background-position: 0px 0px;} .icon-kf-box { width: 300px; height: 350px; background-position: 0px 0px;}
.icon-kf-logo { width: 56px; height: 70px; background-position: -310px -152px;} .icon-kf-logo { width: 56px; height: 70px; background-position: -310px -152px;}
.icon-kf { width: 20px; height: 20px; background-position: -376px -202px;} .icon-kf { width: 20px; height: 20px; background-position: -376px -202px;}
.icon-live-close { width: 18px; height: 18px; background-position: -420px -316px;}
.icon-music-off { width: 34px; height: 34px; background-position: -354px -232px;} .icon-music-off { width: 34px; height: 34px; background-position: -354px -232px;}
.icon-music { width: 32px; height: 32px; background-position: -398px -232px;} .icon-music { width: 32px; height: 32px; background-position: -398px -232px;}
.icon-order { width: 20px; height: 20px; background-position: -406px -202px;} .icon-order { width: 20px; height: 20px; background-position: -406px -202px;}
...@@ -21,4 +22,3 @@ ...@@ -21,4 +22,3 @@
.icon-time { width: 12px; height: 11px; background-position: -20px -374px;} .icon-time { width: 12px; height: 11px; background-position: -20px -374px;}
.icon-title { width: 170px; height: 4px; background-position: 0px -360px;} .icon-title { width: 170px; height: 4px; background-position: 0px -360px;}
.icon-top { width: 30px; height: 30px; background-position: -350px -316px;} .icon-top { width: 30px; height: 30px; background-position: -350px -316px;}
\ No newline at end of file \ No newline at end of file
.icon-live-close { width: 18px; height: 18px; background-position: -420px -316px;}
\ No newline at end of file \ No newline at end of file
...@@ -256,7 +256,71 @@ const date_format = num => { ...@@ -256,7 +256,71 @@ const date_format = num => {
} }
return `${days}天${hours}:${minutes}:${second}` return `${days}天${hours}:${minutes}:${second}`
} }
const draggable = (drag, fun) => {
var startEvt, moveEvt, endEvt
// 判断是否支持触摸事件
if ('ontouchstart' in window) {
startEvt = 'touchstart'
moveEvt = 'touchmove'
endEvt = 'touchend'
} else {
startEvt = 'mousedown'
moveEvt = 'mousemove'
endEvt = 'mouseup'
}
drag.style.cursor = 'grab'
var disX, disY, left, top, starX, starY, oLeft, oTop
drag.addEventListener(startEvt, startFun)
function startFun (event) {
// 阻止页面的滚动,缩放
event.preventDefault()
// 兼容IE浏览器
drag.style.cursor = 'grabbing'
var e = event || window.event
oLeft = drag.offsetLeft
oTop = drag.offsetTop
// 手指按下时的坐标
starX = e.touches ? e.touches[0].clientX : e.clientX
starY = e.touches ? e.touches[0].clientY : e.clientY
// 手指相对于拖动元素左上角的位置
disX = starX - drag.offsetLeft
disY = starY - drag.offsetTop
// 按下之后才监听后续事件
document.addEventListener(moveEvt, moveFun)
document.addEventListener(endEvt, endFun)
}
function moveFun (event) {
// 兼容IE浏览器
var e = event || window.event
left = (e.touches ? e.touches[0].clientX : e.clientX) - disX
top = (e.touches ? e.touches[0].clientY : e.clientY) - disY
// 限制拖拽的X范围,不能拖出屏幕
if (left < 0) {
left = 0
} else if (left > document.documentElement.clientWidth - drag.offsetWidth) {
left = document.documentElement.clientWidth - drag.offsetWidth
}
// 限制拖拽的Y范围,不能拖出屏幕
if (top < 0) {
top = 0
} else if (top > window.innerHeight - drag.offsetHeight) {
top = window.innerHeight - drag.offsetHeight
}
drag.style.left = left + 'px'
drag.style.top = top + 'px'
}
function endFun (event) {
drag.style.cursor = ''
document.removeEventListener(moveEvt, moveFun)
document.removeEventListener(endEvt, endFun)
if (oLeft == drag.offsetLeft && oTop == drag.offsetTop && fun) { // 点击
fun()
}
}
}
const utils = { const utils = {
removeLocalStorage, removeLocalStorage,
...@@ -286,6 +350,7 @@ const utils = { ...@@ -286,6 +350,7 @@ const utils = {
toUnicode, toUnicode,
setCookie, setCookie,
getCookie, getCookie,
draggable,
setAppId, setAppId,
getAppId, getAppId,
debounce, debounce,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div <div
:class="['live-box',{'videoFullscreen':videoFullscreen}]" :class="['live-box',{'videoFullscreen':videoFullscreen}]"
:style="videoStyle" :style="videoStyle"
@touchmove="move" id="live-box"
> >
<div <div
class="mask" class="mask"
...@@ -53,7 +53,6 @@ ...@@ -53,7 +53,6 @@
<script type='text/ecmascript-6'> <script type='text/ecmascript-6'>
import { KfModal } from './index' import { KfModal } from './index'
import { wxConfig } from '@/api' import { wxConfig } from '@/api'
export default { export default {
components: { KfModal }, components: { KfModal },
name: 'LiveBox', name: 'LiveBox',
...@@ -71,9 +70,9 @@ export default { ...@@ -71,9 +70,9 @@ export default {
mounted () { mounted () {
let _this = this let _this = this
wxConfig.ready(() => { wxConfig.ready(() => {
_this.player = TCPlayer("player-container-id", { _this.player = TCPlayer('player-container-id', {
fileID: "387702305074716718", //点播ID fileID: '387702305074716718', //点播ID
appID: "1311227058", //点播APPID appID: '1311227058', //点播APPID
autoplay: true, //自动播放 autoplay: true, //自动播放
loop: true, // 循环播放 loop: true, // 循环播放
muted: true, //是否静音 muted: true, //是否静音
...@@ -91,6 +90,7 @@ export default { ...@@ -91,6 +90,7 @@ export default {
_this.player.ready(function () { //设置播放器初始化完成后的回调 _this.player.ready(function () { //设置播放器初始化完成后的回调
console.log('-------------------------', _this.player.poster()) console.log('-------------------------', _this.player.poster())
_this.player.play() //播放视频 _this.player.play() //播放视频
_this.draggable(document.getElementById('live-box'))
}) })
} }
}) })
...@@ -112,11 +112,6 @@ export default { ...@@ -112,11 +112,6 @@ export default {
this.videoFullscreen = status this.videoFullscreen = status
}, },
move (e) {
let { srcElement } = e,
[data] = e.changedTouches
this.videoStyle = `left:${data.pageX- srcElement.clientWidth / 2};top:${data.pageY - srcElement.clientHeight / 2};`
}
} }
} }
</script> </script>
...@@ -131,6 +126,7 @@ export default { ...@@ -131,6 +126,7 @@ export default {
height: 148px; height: 148px;
border-radius: 4px; border-radius: 4px;
overflow: hidden; overflow: hidden;
-webkit-user-select: auto;
.mask { .mask {
width: 100%; width: 100%;
height: 100%; height: 100%;
...@@ -141,7 +137,7 @@ export default { ...@@ -141,7 +137,7 @@ export default {
border: 2px solid #f95d35; border: 2px solid #f95d35;
border-radius: 4px; border-radius: 4px;
box-sizing: border-box; box-sizing: border-box;
.icon-live-close{ .icon-live-close {
position: absolute; position: absolute;
top: 0; top: 0;
right: 0; right: 0;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!