123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- <template>
- <view class="video-player-container">
- <view>
- <video class="video-player" controls @play.prevent id="myVideo"
- src="@/static/videos/86e914d805fe8578f8258d21eeac7ddc.mp4"></video>
- </view>
- <view class="icon-area">
- <uni-icons type="download-filled" size="30" color="#BD3124" @click="downloadVideo"></uni-icons>
- <uni-icons type="redo-filled" size="30" color="#BD3124" @click="shareToggle"></uni-icons>
- </view>
- <uni-popup ref="share" type="share" safeArea backgroundColor="#fff">
- <view class="popup-content">
- <text class="text">分享到</text>
- <view class="app-icon">
- <view class="app-icon-item" @click="shareWeibo">
- <image class="app-icon-img" src="@/static/images/xijiao/weibo.png"></image>
- <view class="app-icon-text">
- 新浪微博
- </view>
- </view>
- <view class="app-icon-item" @click="shareWechat">
- <image class="app-icon-img" src="@/static/images/xijiao/WeChat.png"></image>
- <view class="app-icon-text">
- 微信
- </view>
- </view>
- <view class="app-icon-item" @click="shareTimeline">
- <image class="app-icon-img" src="@/static/images/xijiao/timeline.png"></image>
- <view class="app-icon-text">
- 朋友圈
- </view>
- </view>
- </view>
- </view>
- </uni-popup>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- isLoading:false,
- }
- },
- methods: {
- downloadVideo() {
- uni.showToast({
- title: "下载中",
- icon: "loading",
- duration:100000
- })
- uni.downloadFile({
- url: 'https://samplelib.com/lib/preview/mp4/sample-5s.mp4',
- success: (res) => {
- if (res.statusCode === 200) {
- console.log('下载成功');
- uni.hideToast()
- uni.saveVideoToPhotosAlbum({
- filePath: res.tempFilePath
- })
- uni.showToast({
- title: "下载成功",
- icon: "success"
- })
- }else{
- uni.showToast({
- title: "下载失败",
- icon: "error"
- })
- }
- }
- });
- },
- shareToggle() {
- this.$refs.share.open()
- },
- shareWeibo() {
- uni.share({
- provider: "sinaweibo",
- type: 4,
- mediaUrl: "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/2minute-demo.mp4",
- success: function(res) {
- console.log("success:" + JSON.stringify(res));
- },
- fail: function(err) {
- console.log("fail:" + JSON.stringify(err));
- }
- });
- },
- shareWechat() {
- uni.share({
- provider: "weixin",
- scene: "WXSceneSession",
- type: 4,
- mediaUrl: "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/2minute-demo.mp4",
- success: function(res) {
- console.log("success:" + JSON.stringify(res));
- },
- fail: function(err) {
- console.log("fail:" + JSON.stringify(err));
- }
- });
- },
- shareTimeline() {
- uni.share({
- provider: "weixin",
- scene: "WXSceneTimeline",
- type: 4,
- mediaUrl: "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/2minute-demo.mp4",
- success: function(res) {
- console.log("success:" + JSON.stringify(res));
- },
- fail: function(err) {
- console.log("fail:" + JSON.stringify(err));
- }
- });
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .video-player-container {
- .video-player {
- width: 100%;
- height: 300px;
- }
- .icon-area {
- display: flex;
- justify-content: space-evenly;
- margin-top: 50px;
- }
- .popup-content {
- width: 100%;
- height: 150px;
- display: flex;
- flex-direction: column;
- align-items: center;
- .text {
- margin: 10px 0;
- font-size: 20px;
- }
- .app-icon {
- display: flex;
- justify-content: space-between;
- margin: 10px 0;
- .app-icon-item {
- width: 100px;
- display: flex;
- flex-direction: column;
- align-items: center;
- .app-icon-img {
- width: 30px;
- height: 30px;
- }
- .app-icon-text {
- margin-top: 10px;
- text-align: center;
- }
- }
- }
- }
- }
- </style>
|