index.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. const cf = require("../../utils/checkFile")
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. properties: {
  7. butType: {
  8. type: String,
  9. value: "下载"
  10. },
  11. list: {
  12. type: Array,
  13. value: []
  14. },
  15. callBack: {
  16. type: Function
  17. },
  18. deleteFile: {
  19. type: Function
  20. }
  21. },
  22. options: {
  23. addGlobalClass: true
  24. },
  25. /**
  26. * 组件的初始数据
  27. */
  28. data: {
  29. },
  30. /**
  31. * 组件的方法列表
  32. */
  33. methods: {
  34. butClick(e) {
  35. const {
  36. item
  37. } = e.currentTarget.dataset;
  38. const that = this;
  39. if (this.data.butType == '播放') {
  40. this.triggerEvent("callBack", item);
  41. } else if (this.data.butType == '删除') {
  42. wx.showModal({
  43. title: "通知",
  44. content: "是否确认删除该附件?",
  45. success: res => {
  46. if (res.confirm) that.triggerEvent("deleteFile", item);
  47. }
  48. })
  49. }
  50. },
  51. callback(e) {
  52. const {
  53. item
  54. } = e.currentTarget.dataset;
  55. this.triggerEvent("callBack", item);
  56. },
  57. checkFile(e) {
  58. const {
  59. item
  60. } = e.currentTarget.dataset;
  61. if (item.fileType == 'video' && this.data.butType == '商学院' || this.data.butType == '播放') return this.triggerEvent("callBack", item);
  62. cf.checkFile(item);
  63. }
  64. }
  65. })