123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <template>
- <div class="simple-video-player">
- <van-popup v-model="show" position="center" :closeable="true">
- <div class="pupup-content">
- <video
- :src="videoSrc"
- controls
- ref="video"
- class="video"
- :style="{ height: videoHeight }"
- ></video>
- <div class="desc" v-if="description">{{ description }}</div>
- </div>
- </van-popup>
- </div>
- </template>
- <script>
- export default {
- props: {
- videoSrc: {
- type: String,
- default: '',
- },
- description: {
- type: String,
- default: '',
- },
- },
- data() {
- return {
- show: false,
- }
- },
- computed: {
- videoHeight() {
- return this.description ? '92vh' : '100vh'
- },
- },
- watch: {
- show(nVal) {
- this.$nextTick(() => {
- nVal ? this.$refs.video.play() : this.$refs.video.pause()
- })
- },
- },
- methods: {
- open() {
- this.show = true
- },
- },
- }
- </script>
- <style scoped lang="scss">
- .simple-video-player {
- .pupup-content {
- position: relative;
- width: 100vw;
- height: 100vh;
- background: #000;
- }
- .video {
- margin: 0 auto;
- height: 92vh;
- }
- @media screen and (min-width: 768px) {
- .desc {
- position: absolute;
- height: 48px;
- left: 0;
- bottom: 16px;
- padding: 0 32px;
- line-height: 24px;
- font-size: 14px;
- color: #fff;
- box-sizing: border-box;
- background: rgba(0, 0, 0, 0.5);
- text-align: justify;
- @include ellipsis(2);
- }
- }
- @media screen and (max-width: 768px) {
- .desc {
- position: absolute;
- height: 10.4vw;
- left: 0;
- bottom: 4vw;
- padding: 0 4vw;
- line-height: 5.2vw;
- font-size: 3.2vw;
- color: #fff;
- box-sizing: border-box;
- background: rgba(0, 0, 0, 0.5);
- text-align: justify;
- @include ellipsis(2);
- }
- }
- }
- </style>
|