1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- import behavior from '~/mixins/video'
- let _observer
- Component({
- behaviors: [behavior],
- properties: {
- worksList: {
- type: Array,
- value: [],
- observer(newVal) {
- this.setData({
- worksListCopy: newVal
- })
- if (this.properties.autoPlay) {
- // 自动播放
- this._observer = this.createIntersectionObserver({
- observeAll: true
- })
- this._observer.relativeTo('.playLine')
- .observe('.videoPreview', (res) => {
- let intersectionRatio = res.intersectionRatio
- if (intersectionRatio > 0) {
- if (res.dataset.type == 0) {
- this.resetAudio();
- this.setData({
- currentId: res.dataset.id
- })
- } else {
- this.playAudio({
- currentTarget: {
- dataset: res.dataset
- }
- })
- }
- }
- })
- }
- }
- },
- // 是否自动播放
- autoPlay: {
- type: Boolean,
- value: true
- },
- videoType: {
- type: String,
- // value 为public时是默认公共样式,为my时为“我的”样式,展示下载删除是否公开,pk为pk的样式文案,collection为收藏时的样式,excellent优秀作品展播
- value: 'public'
- },
- // 是否在tabbar页面使用
- tabBarPadding: {
- type: Boolean,
- value: false
- }
- },
- data: {
- worksListCopy: {}
- },
- lifetimes: {
- detached: function () {
- // 在组件实例被从页面节点树移除时执行
- this.resetAudio()
- },
- },
- methods: {
- setListFans({
- detail
- }) {
- let worksListCopy = JSON.parse(JSON.stringify(this.data.worksListCopy))
- worksListCopy.forEach(item => {
- if (item.user.uid == detail) {
- item.isFans = true
- }
- })
- this.setData({
- worksListCopy
- })
- },
- addCommentNum({
- detail
- }) {
- let worksListCopy = JSON.parse(JSON.stringify(this.data.worksListCopy))
- worksListCopy.forEach(item => {
- if (item.userRead.id == detail) {
- item.userRead.commentAmount = ++item.userRead.commentAmount
- }
- })
- this.setData({
- worksListCopy
- })
- }
- },
- })
|