123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- import {
- setVideoStatus,
- likeVideo
- } from '~/api/video'
- Component({
- /**
- * 组件的属性列表
- */
- properties: {
- item: {
- type: Object,
- value: {}
- },
- index: {
- type: Number,
- },
- currentId: {
- type: Number,
- }
- },
- /**
- * 组件的初始数据
- */
- data: {
- },
- /**
- * 组件的方法列表
- */
- methods: {
- // 设置视频公开还是隐私
- async setVideoPublic() {
- let info = this.properties.item.userRead
- let data = {
- id: info.id,
- status: info.status === 'NORMAL' ? 'DISABLE' : 'NORMAL'
- }
- let res = await setVideoStatus(data)
- if (res.status == 'DISABLE') {
- wx.showToast({
- title: '该作品仅自己可见',
- icon: 'none',
- duration: 2000
- })
- }
- let index = this.properties.index
- let status = `list[${index}].userRead.status`;
- let val = info.status === 'NORMAL' ? 'DISABLE' : 'NORMAL'
- let options = {
- [status]: val
- }
- this.triggerEvent('changStatus', options)
- },
- // 点赞
- async likeVideo() {
- let {
- id
- } = this.properties.item.userRead
- if (this.properties.item.isLike) {
- return
- }
- await likeVideo(id)
- let index = this.properties.index
- let likeStr = `list[${index}].isLike`;
- let likeNumStr = `list[${index}].userRead.likeAmount`;
- let options = {
- [likeStr]: true,
- [likeNumStr]: this.properties.item.userRead.likeAmount + 1
- }
- this.triggerEvent('changStatus', options)
- },
- // 下载视频
- download() {
- wx.showLoading({
- title: '保存到本地',
- mask: true
- })
- const url = this.properties.item.userRead.markPath || ''
- wx.downloadFile({
- url,
- success(res) {
- if (res.statusCode === 200) {
- wx.saveVideoToPhotosAlbum({
- filePath: res.tempFilePath,
- success(res) {
- wx.hideLoading()
- wx.showToast({
- title: '成功保存到相册!',
- duration: 3000,
- icon: 'success',
- mask: true
- })
- },
- fail() {
- wx.hideLoading()
- wx.showToast({
- title: '网络不给力',
- icon: 'error',
- duration: 3000,
- mask: true
- })
- }
- })
- }
- },
- fail() {
- wx.hideLoading()
- wx.showToast({
- title: '网络不给力',
- icon: 'error',
- duration: 3000,
- mask: true
- })
- }
- })
- },
- //评论
- openComment() {},
- // 删除
- delete() {
- let {
- id
- } = this.properties.item.userRead
- wx.showModal({
- title: '确认删除吗?',
- content: '作品将被永久删除,无法找回。',
- confirmText: '确认',
- cancelText: '取消',
- success: async (res) => {
- if (res.confirm) {
- let data = {
- id,
- status: 'DEL'
- }
- await setVideoStatus(data)
- wx.showToast({
- title: '删除成功!',
- icon: "none"
- })
- this.triggerEvent('getList')
- }
- }
- })
- },
- }
- })
|