提交 c7c9ddc9 编写于 作者: glod-money-money's avatar glod-money-money

update:更新

上级 574403eb
.app-rawitem-carousel{
width: 100%;
height: 200px;
.carsouel-container{
width: 100%;
height: 100%;
}
}
\ No newline at end of file
<template> <template>
<div class="app-carouse"> <div class="app-rawitem-carousel">
<Carousel :autoplay="swipeConfig.isAuto" :autoplay-speed="swipeConfig.timeSpan" radius-dot> <Carousel class="carsouel-container" :autoplay="swipeConfig.isAuto" :autoplay-speed="swipeConfig.timeSpan" radius-dot>
<CarouselItem v-for="(item, index) in swipeData" :key="index"> <CarouselItem v-for="(item, index) in swipeData" :key="index">
<div class="carousel-img-item"> <div class="carousel-img-item">
<a v-if="item.linkPath" :href="item.linkPath"> <a v-if="item.linkPath" :href="item.linkPath">
...@@ -26,11 +26,11 @@ export default class AppCarousel extends Vue { ...@@ -26,11 +26,11 @@ export default class AppCarousel extends Vue {
@Prop() public data?: any; @Prop() public data?: any;
/** /**
* @description 轮播图数据 * @description 轮播图样式
* @param {*} * @param {*}
* @memberof AppCarousel * @memberof AppCarousel
*/ */
@Prop() public rawstyle?: any; @Prop() public rawstyle?: any;
/** /**
* @description 轮播图图片所有项数据 * @description 轮播图图片所有项数据
...@@ -52,11 +52,10 @@ export default class AppCarousel extends Vue { ...@@ -52,11 +52,10 @@ export default class AppCarousel extends Vue {
* @param {*} oldVal * @param {*} oldVal
* @memberof AppCarousel * @memberof AppCarousel
*/ */
@Watch('data', { immediate: true }) @Watch('data', { immediate: true, deep: true })
public onDataChange(newVal: any, oldVal: any) { public onDataChange(newVal: any, oldVal: any) {
if (!Object.is(newVal, oldVal)) { if (newVal) {
this.swipeData = newVal.swipeData; this.handleSwipData(newVal);
this.swipeConfig = newVal.swipeConfig;
} }
} }
...@@ -65,8 +64,51 @@ export default class AppCarousel extends Vue { ...@@ -65,8 +64,51 @@ export default class AppCarousel extends Vue {
* @memberof AppCarousel * @memberof AppCarousel
*/ */
created() { created() {
this.swipeData = this.data.swipeData; this.handleSwipData(this.data);
this.swipeConfig = this.data.swipeConfig; }
/**
* @description 处理轮播图数据
* @memberof AppCarousel
*/
private handleSwipData(data: any) {
if (data && data.length > 0) {
const configItem = data.findIndex((item: any) =>
Object.is(item.key, "autoplay")
);
if (configItem > -1) {
// 有配置参数就截掉配置参数
this.swipeData = data.slice(0, -2);
this.swipeConfig = this.setSwipeConfig(data.slice(-2));
} else {
this.swipeData = this.data;
this.swipeConfig = this.setSwipeConfig(data);
}
}
}
/**
* @description 设置轮播图配置
* @param {*}
* @memberof AppRawItem
*/
private setSwipeConfig(data: any) {
const autoPlay: any =
data.find((item: any) => Object.is(item.key, "autoplay")) || {};
const timeSpan: any =
data.find((item: any) => Object.is(item.key, "timespan")) || {};
let isauto = false;
let timespan = 0;
if (autoPlay.value && Object.is(autoPlay.value, "1")) {
isauto = true;
}
if (timeSpan.value) {
timespan = Number(timeSpan.value);
}
return {
isAuto: isauto,
timeSpan: timespan,
};
} }
/** /**
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
>img{ >img{
width: auto; width: auto;
height: 100%; height: 100%;
object-fit: contain; max-width: 100%;
height: 360px;
object-fit: contain;
} }
} }
\ No newline at end of file
.app-rawitem-video{
width: 600px;
height: auto;
max-width: 100%;
min-height: 300px;
border: 1px solid gray;
>video{
width: 100%;
height: 100%;
}
}
\ No newline at end of file
<template> <template>
<div :id="uuid" class="render-video"></div> <div class="app-rawitem-video">
<video
:src="playerParams.url"
:autoplay="playerParams.autoplay"
:controls="playerParams.controls"
:loop="playerParams.loop"
:muted="playerParams.volume">
</video>
</div>
</template> </template>
<script lang="ts"> <script lang="ts">
// import Player from 'xgplayer';
import { Util } from '@/utils'; import { Util } from '@/utils';
import { Component, Vue, Prop } from 'vue-property-decorator'; import { Component, Vue, Prop } from 'vue-property-decorator';
@Component({}) @Component({})
...@@ -18,35 +25,29 @@ export default class AppVideo extends Vue { ...@@ -18,35 +25,29 @@ export default class AppVideo extends Vue {
*/ */
@Prop() public videoParmas?: any; @Prop() public videoParmas?: any;
get Params() { //视频播放参数
return this.videoParmas ? this.videoParmas : {}; public playerParams = {
} id: this.uuid,
height: '100%',
width: '100%',
url:"https://kvideo01.youju.sohu.com/16403c4c-378c-4415-b3ef-908e87efb0082_0_0.mp4",
volume:0.8,
autoplay:false,
loop:false,
controls:false
};
/** /**
* 生命周期 * 生命周期
*/ */
public mounted() { public mounted() {
let defaultHeight = 337.5; if (this.videoParmas) {
let defaultwidth = 600; this.playerParams.url = this.videoParmas.path;
if (this.$el) { this.playerParams.volume = this.videoParmas.mute ? 0 : 0.8;
defaultHeight = this.$el.clientHeight; this.playerParams.autoplay = this.videoParmas.autoplay ? true : false;
defaultwidth = this.$el.clientWidth; this.playerParams.loop = this.videoParmas.replay ? true : false;
this.playerParams.controls = this.videoParmas.showcontrols ? true : false
} }
// let player = new Player({
// id: this.uuid,
// fluid: true,
// height: defaultHeight,
// width: defaultwidth,
// });
// if (this.videoParmas) {
// player.trl = this.videoParmas.path;
// }
// if (this.Params) {
// player.volume = this.Params.mute ? 0 : 0.8;
// player.autoplay = this.Params.autoplay ? true : false;
// player.loop = this.Params.replay ? true : false;
// player.controls = this.Params.showcontrols ? true : false
// }
} }
} }
</script> </script>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册