分享完成

This commit is contained in:
theluyuan 2020-12-02 16:55:34 +08:00
parent 5cafb95ee0
commit e1c2e3170d
3 changed files with 172 additions and 13 deletions

View File

@ -2,7 +2,9 @@
<div class="video"> <div class="video">
<video v-if="isvideo" :id=" 'a' + time" style="width:100%;height:100%"></video> <video v-if="isvideo" :id=" 'a' + time" style="width:100%;height:100%"></video>
<img v-else :src="info.img" style="width:100%;height:100%" alt=""> <img v-else :src="info.img" style="width:100%;height:100%" alt="">
<div class="title fenxiang" @click="show"> <img src="@/static/images/fenxiang.png" alt=""> 立即分享</div>
<div class="liveinfo"> <div class="liveinfo">
<div class="left"> <div class="left">
<div> <div>
<img src="@/static/images/livelesson.png" alt="" class="icon"> <img src="@/static/images/livelesson.png" alt="" class="icon">
@ -31,6 +33,35 @@
</div> </div>
</div> </div>
<div class="modal-container">
<!-- @cancel="hideNoticeModal" -->
<a-modal
centered
:footer="null"
dialogClass="modal-dialog"
v-model:visible="fxtc"
title="请选择分享途径"
:getContainer="modalNode"
width="4rem"
>
<template v-slot:closeIcon>
<img src="@/static/images/delete.png" class="close" />
</template>
<div class="notice-container report">
<div @click="fx(1)">
<img src="@/static/images/weibo.png" alt="" srcset="">
新浪微博
</div>
<div @click="fx(2)">
<img src="@/static/images/facebook.png" alt="" srcset="">
Facebook
</div>
</div>
</a-modal>
</div>
</div> </div>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
@ -41,9 +72,29 @@
overflow: hidden; overflow: hidden;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
position: relative;
> video { > video {
width: 100%; width: 100%;
height: 505px; height: 505px;
}
.title{
position: absolute;
top: 23px;
left: 51px;
font-size: 13px;
color: #fff;
z-index: 999;
}
.fenxiang{
left: unset;
right: 51px;
display: flex;
align-items: center;
>img{
width: 11px;
height: 11px;
margin-right: 11px;
}
} }
.liveinfo{ .liveinfo{
flex-shrink: 0; flex-shrink: 0;
@ -52,6 +103,7 @@
height: 58px; height: 58px;
align-items: center; align-items: center;
background-color: #fff; background-color: #fff;
position: relative;
.left{ .left{
display: flex; display: flex;
color: #121212; color: #121212;
@ -85,10 +137,67 @@
text-align: center; text-align: center;
} }
} }
.modal-container {
::v-deep(.ant-modal-header){
padding: 0;
}
::v-deep(.ant-modal-title){
font-size: 12px;
margin-top: -0.09rem;
padding-bottom: 20px;
}
::v-deep(.ant-modal-close){
top: 8px;
}
::v-deep(.ant-modal-body){
padding: 0;
}
::v-deep(.modal-dialog) {
border-radius: 36px;
overflow: hidden;
.close {
width: 14px;
height: 14px;
}
.ant-modal-content {
box-sizing: border-box;
padding: 35px 30px;
// width: 569px;
background: #ffffff;
box-shadow: 0px 4px 6px 0px rgba(102, 102, 102, 0.07);
border-radius: 26px;
overflow: hidden;
.notice-container {
display: flex;
align-items: center;
padding-top: 30px;
>div{
width: auto;
display: flex;
align-items: center;
font-size: 12px;
>img{
width: 35px;
margin-right: 5px;
}
}
>div:first-child{
margin-right: 80px;
}
}
.report {
.sub-title {
margin-bottom: 50px;
}
}
}
}
}
} }
</style> </style>
<script lang="ts"> <script lang="ts">
import { livestart } from '@/api'; import { livestart, share } from '@/api';
import router from '@/router'; import router from '@/router';
import { useI18n } from '@/utils/i18n'; import { useI18n } from '@/utils/i18n';
import { defineComponent, onUpdated, ref, watch } from "vue"; import { defineComponent, onUpdated, ref, watch } from "vue";
@ -118,7 +227,7 @@ export default defineComponent({
const time = ref(new Date().getTime()) const time = ref(new Date().getTime())
let play: any; let play: any;
const isvideo = ref(true); const isvideo = ref(true);
const fxtc = ref(false)
watch(()=> props.info,()=>{ watch(()=> props.info,()=>{
if(props.info){ if(props.info){
console.log(props.info) console.log(props.info)
@ -141,13 +250,33 @@ export default defineComponent({
} }
next() next()
}) })
function fx(index: number){
console.log(index)
share().then((res: any)=>{
console.log(res)
let url = "";
if(index == 1){
url = `https://service.weibo.com/share/share.php?url=${res.shareUrl}&appkey=2754574056&language=zh_cn&pic=${res.shareImg}&searchPic=true&title=${res.shareTitle}`
}else {
url = `https://www.facebook.com/sharer/sharer.php?%20u=${res.shareUrl}&t=${res.shareTitle}`
}
window.open(url, "_blank")
})
}
function show(){
fxtc.value = true
}
// const liveinfo = ref(props.liveinfo) // const liveinfo = ref(props.liveinfo)
return { return {
bianji, bianji,
kaishi, kaishi,
lan, lan,
time, time,
isvideo isvideo,
fx,
fxtc,
show,
modalNode: () => document.getElementsByClassName("modal-container")[0],
} }
} }
}); });

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="video"> <div class="video">
<div class="title">{{title}}</div> <div class="title">{{title}}</div>
<div class="title fenxiang"> <img src="@/static/images/fenxiang.png" alt=""> 立即分享</div> <div class="title fenxiang" @click="show"> <img src="@/static/images/fenxiang.png" alt=""> 立即分享</div>
<video style="width:100%; height:100%;" :id="'a' + url" ></video> <video style="width:100%; height:100%;" :id="'a' + url" ></video>
<div class="modal-container"> <div class="modal-container">
<!-- @cancel="hideNoticeModal" --> <!-- @cancel="hideNoticeModal" -->
@ -10,7 +10,7 @@
centered centered
:footer="null" :footer="null"
dialogClass="modal-dialog" dialogClass="modal-dialog"
:visible="true" v-model:visible="fxtc"
title="请选择分享途径" title="请选择分享途径"
:getContainer="modalNode" :getContainer="modalNode"
width="4rem" width="4rem"
@ -129,7 +129,7 @@
import { share } from '@/api'; import { share } from '@/api';
import router from '@/router'; import router from '@/router';
import { useI18n } from '@/utils/i18n'; import { useI18n } from '@/utils/i18n';
import { defineComponent, onMounted, onUpdated } from 'vue'; import { defineComponent, onMounted, onUpdated, ref, watch } from 'vue';
import { onBeforeRouteLeave, useRouter } from 'vue-router'; import { onBeforeRouteLeave, useRouter } from 'vue-router';
export default defineComponent({ export default defineComponent({
@ -145,13 +145,37 @@ export default defineComponent({
console.log(1) console.log(1)
let play: any; let play: any;
const lan = useI18n() const lan = useI18n()
onUpdated(()=>{ const fxtc = ref(false)
// onMounted(()=>{
// console.log(props.url)
// play = window.TCPlayer('a' + props.url, {
// fileID: props.url,
// appID: '1303872925'
// });
// })
onMounted(()=>{
console.log(props.url)
if(props.url){
console.log(props.url) console.log(props.url)
play = window.TCPlayer('a' + props.url, { play = window.TCPlayer('a' + props.url, {
fileID: props.url, fileID: props.url,
appID: '1303872925' appID: '1303872925'
}); });
}else{
watch(()=> props.url,()=>{
console.log(props.url)
setTimeout(()=>{
play = window.TCPlayer('a' + props.url, {
fileID: props.url,
appID: '1303872925'
});
}, 500)
}) })
}
})
onBeforeRouteLeave((to, from, next) => { onBeforeRouteLeave((to, from, next) => {
console.log(121) console.log(121)
play.dispose() play.dispose()
@ -170,11 +194,16 @@ export default defineComponent({
window.open(url, "_blank") window.open(url, "_blank")
}) })
} }
function show(){
fxtc.value = true
}
return{ return{
lan, lan,
modalNode: () => modalNode: () =>
document.getElementsByClassName("modal-container")[0], document.getElementsByClassName("modal-container")[0],
fx fx,
fxtc,
show
} }
} }

View File

@ -35,8 +35,9 @@ import liveplay from "@/components/LivePlay.vue";
import LiveCount from "@/components/LiveCount.vue"; import LiveCount from "@/components/LiveCount.vue";
import VideoReview from "@/components/VideoReview.vue"; import VideoReview from "@/components/VideoReview.vue";
import { useRoute } from "vue-router"; import { useRoute } from "vue-router";
import { getliveinfo } from "@/api"; import { getliveinfo, share } from "@/api";
import router from '@/router'; import router from '@/router';
import { useI18n } from "@/utils/i18n";
export default defineComponent({ export default defineComponent({
components: { components: {
LiveCount, LiveCount,