| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- const cf = require("../../utils/checkFile")
- Component({
- properties: {
- butType: {
- type: String,
- value: "下载"
- },
- list: {
- type: Array,
- value: []
- },
- callBack: Function,
- deleteFile: Function,
- downLoadRecord: Function
- },
- lifetimes: {
- attached() {
- getApp().globalData.Language.getLanguagePackage(this)
- }
- },
- methods: {
- butClick(e) {
- const {
- item,
- type
- } = e.currentTarget.dataset;
- const that = this;
- if (type == '播放') {
- this.triggerEvent("callBack", item);
- } else if (type == '删除') {
- wx.showModal({
- title: getApp().globalData.Language.getMapText('提示'),
- content: getApp().globalData.Language.getMapText('是否确认删除该附件') + "?",
- cancelText: getApp().globalData.Language.getMapText('取消'),
- confirmText: getApp().globalData.Language.getMapText('确定'),
- success: res => {
- if (res.confirm) that.triggerEvent("deleteFile", item);
- }
- })
- } else if (type == '下载') {
- wx.downloadFile({
- url: item.url,
- success(res) {
- if (res.statusCode === 200) {
- wx.shareFileMessage({
- filePath: res.tempFilePath,
- fileName: item.document,
- success(res) {
- console.log("转发", res)
- },
- fail: console.error,
- })
- } else {
- getApp().globalData.Language.showToast('微信下载保存失败')
- }
- },
- fail() {
- getApp().globalData.Language.showToast('文件下载失败')
- }
- });
- this.triggerEvent("downLoadRecord");
- };
- },
- callback(e) {
- const {
- item
- } = e.currentTarget.dataset;
- this.triggerEvent("callBack", item);
- },
- checkFile(e) {
- const {
- item
- } = e.currentTarget.dataset;
- if (item.fileType == 'video' && this.data.butType == '商学院' || this.data.butType == '播放') return this.triggerEvent("callBack", item);
- cf.checkFile(item);
- }
- }
- })
|