123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <template>
- <view class="videoDetail">
- <uni-menubar :title="videoDetail.name" />
- <tm-sheet >
- <video id="myVideo" :src="videoDetail.path" controls show-play-btn show-center-play-btn
- :poster-for-crawler="videoDetail.thumb"></video>
- <view class="mt-20">
- <tm-button theme="blue" block @click="downVideo">下载视频</tm-button>
- </view>
- </tm-sheet>
-
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- videoDetail:{},
- card_id:""
- }
- },
- onLoad(option) {
- if(option){
- this.card_id = option.card_id
- this.$tm.vx.commit('card/cardId', option.card_id)
- this.videoDetail = JSON.parse(option.detail)
- this.$point.point(11, this.videoDetail.id, this.card_id)
- }
- },
- onShareAppMessage(res) {
- return {
- title: this.videoDetail.name,
- path: '/pages/list/videoDetail?detail='+JSON.stringify(this.videoDetail)+'&card_id='+this.card_id,
- success: () => {
- this.$point.point(12, this.videoDetail.id, this.card_id)
- }
- }
- },
- methods:{
- downVideo() {
- let that = this
- const downloadTask = uni.downloadFile({
- url: that.videoDetail.path,
- success: (data) => {
- if (data.statusCode === 200) {
- wx.saveVideoToPhotosAlbum({
- filePath: data.tempFilePath,
- success: (res) => {
- uni.showToast({
- icon: 'none',
- mask: true,
- title: '视频已保存!',
- duration: 3000,
- });
- that.$point.point(13, that.videoDetail.id, that.card_id)
- }
- })
- }
- },
- fail: (err) => {
- uni.showToast({
- icon: 'none',
- mask: true,
- title: '失败请重新下载',
- });
- },
- });
- downloadTask.onProgressUpdate((res) => {
- if (res.progress < 101) {
- uni.showToast({
- icon: 'none',
- mask: true,
- title: '正在下载视频' + res.progress + '%',
- });
- } else {
- downloadTask.abort() // 取消下载任务
- }
- })
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .videoDetail {}
- </style>
|