index.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import behavior from '~/mixins/video'
  2. let _observer
  3. Component({
  4. behaviors: [behavior],
  5. properties: {
  6. worksList: {
  7. type: Array,
  8. value: [],
  9. observer(newVal) {
  10. this.setData({
  11. worksListCopy: newVal
  12. })
  13. this._observer = this.createIntersectionObserver({
  14. observeAll: true
  15. })
  16. this._observer.relativeTo('.playLine')
  17. .observe('.videoPreview', (res) => {
  18. let intersectionRatio = res.intersectionRatio
  19. if (intersectionRatio > 0) {
  20. this.setData({
  21. currentId: res.dataset.id
  22. })
  23. }
  24. })
  25. }
  26. },
  27. videoType: {
  28. type: String,
  29. // value 为public时是默认公共样式,为my时为“我的”样式,展示下载删除是否公开,pk为pk的样式文案,collection为收藏时的样式,excellent优秀作品展播
  30. value: 'public'
  31. },
  32. // 是否在tabbar页面使用
  33. tabBarPadding: {
  34. type: Boolean,
  35. value: false
  36. }
  37. },
  38. data: {
  39. worksListCopy: {}
  40. },
  41. methods: {
  42. setListFans({
  43. detail
  44. }) {
  45. let worksListCopy = JSON.parse(JSON.stringify(this.data.worksListCopy))
  46. worksListCopy.forEach(item => {
  47. if (item.user.uid == detail) {
  48. item.isFans = true
  49. }
  50. })
  51. this.setData({
  52. worksListCopy
  53. })
  54. },
  55. addCommentNum({
  56. detail
  57. }) {
  58. let worksListCopy = JSON.parse(JSON.stringify(this.data.worksListCopy))
  59. worksListCopy.forEach(item => {
  60. if (item.userRead.id == detail) {
  61. item.userRead.commentAmount = ++item.userRead.commentAmount
  62. }
  63. })
  64. this.setData({
  65. worksListCopy
  66. })
  67. }
  68. },
  69. })