| | |
| | | fullUrl |
| | | fullThumbUrl |
| | | fileExt |
| | | fileSize |
| | | mediaType |
| | | } |
| | | } |
| | |
| | | loading: false, |
| | | submitting: false, |
| | | activityPlayerId: null, |
| | | detail: null, |
| | | feedback: '' |
| | | detail: { |
| | | playerInfo: {}, |
| | | submissionFiles: [] |
| | | }, |
| | | feedback: '', |
| | | mediaList: [] |
| | | }, |
| | | |
| | | onLoad(options) { |
| | |
| | | return |
| | | } |
| | | |
| | | const mediaList = (detail.submissionFiles || []).map(item => this.transformMediaFile(item)) |
| | | const playerInfo = detail.playerInfo || {} |
| | | |
| | | this.setData({ |
| | | detail: { |
| | | ...detail, |
| | | playerInfo, |
| | | stateText: this.getStateText(detail.state), |
| | | submissionFiles: (detail.submissionFiles || []).map(file => ({ |
| | | id: file.id, |
| | | name: file.name, |
| | | url: file.fullUrl || file.fullThumbUrl || '' |
| | | })) |
| | | submissionFiles: mediaList |
| | | }, |
| | | mediaList, |
| | | feedback: detail.feedback || '' |
| | | }) |
| | | } catch (error) { |
| | |
| | | wx.showToast({ title: '加载失败', icon: 'none' }) |
| | | } finally { |
| | | this.setData({ loading: false }) |
| | | } |
| | | }, |
| | | |
| | | transformMediaFile(file = {}) { |
| | | const url = file.fullUrl || file.fullThumbUrl || file.url || '' |
| | | const thumbUrl = file.fullThumbUrl || file.fullUrl || url |
| | | const ext = (file.fileExt || '').toLowerCase() |
| | | let mediaType = 'file' |
| | | |
| | | if (file.mediaType === 1 || ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'heic'].includes(ext)) { |
| | | mediaType = 'image' |
| | | } else if (file.mediaType === 2 || ['mp4', 'mov', 'avi', 'wmv', 'mkv', 'webm', 'flv'].includes(ext)) { |
| | | mediaType = 'video' |
| | | } else if (ext === 'pdf') { |
| | | mediaType = 'pdf' |
| | | } else if (['doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx', 'wps', 'txt', 'rtf'].includes(ext)) { |
| | | mediaType = 'word' |
| | | } |
| | | |
| | | return { |
| | | id: file.id, |
| | | name: file.name || '资料文件', |
| | | url, |
| | | thumbUrl, |
| | | mediaType, |
| | | size: Number(file.fileSize) || 0 |
| | | } |
| | | }, |
| | | |
| | |
| | | this.setData({ submitting: true }) |
| | | |
| | | try { |
| | | const trimmedFeedback = (this.data.feedback || '').trim() |
| | | const variables = { |
| | | id: Number(this.data.activityPlayerId), |
| | | feedback: this.data.feedback ? this.data.feedback.trim() : null |
| | | feedback: trimmedFeedback ? trimmedFeedback : null |
| | | } |
| | | const result = await graphqlRequest(mutation, variables) |
| | | const success = result && (action === 'APPROVE' ? result.approveActivityPlayer : result.rejectActivityPlayer) |
| | |
| | | } |
| | | }, |
| | | |
| | | previewFile(e) { |
| | | const url = e.currentTarget.dataset.url |
| | | if (url) { |
| | | wx.navigateTo({ url: `/pages/webview/webview?url=${encodeURIComponent(url)}` }) |
| | | onMediaTap(e) { |
| | | const index = Number(e.currentTarget.dataset.index) |
| | | const mediaList = this.data.mediaList || [] |
| | | const media = mediaList[index] |
| | | if (!media) return |
| | | |
| | | if (media.mediaType === 'image') { |
| | | const images = mediaList.filter(item => item.mediaType === 'image').map(item => item.url) |
| | | wx.previewImage({ |
| | | current: media.url, |
| | | urls: images |
| | | }) |
| | | } else if (media.mediaType === 'video') { |
| | | wx.navigateTo({ |
| | | url: `/pages/video/video?url=${encodeURIComponent(media.url)}&title=${encodeURIComponent(media.name)}` |
| | | }) |
| | | } else { |
| | | this.openDocumentMedia(media) |
| | | } |
| | | }, |
| | | |
| | | async openDocumentMedia(media) { |
| | | try { |
| | | wx.showLoading({ title: '打开中...' }) |
| | | const downloadRes = await new Promise((resolve, reject) => { |
| | | wx.downloadFile({ |
| | | url: media.url, |
| | | success: resolve, |
| | | fail: reject |
| | | }) |
| | | }) |
| | | |
| | | if (downloadRes.statusCode !== 200) { |
| | | throw new Error('文件下载失败') |
| | | } |
| | | |
| | | await new Promise((resolve, reject) => { |
| | | wx.openDocument({ |
| | | filePath: downloadRes.tempFilePath, |
| | | showMenu: true, |
| | | success: resolve, |
| | | fail: reject |
| | | }) |
| | | }) |
| | | } catch (error) { |
| | | console.error('打开文件失败:', error) |
| | | wx.showToast({ |
| | | title: '无法打开文件', |
| | | icon: 'error' |
| | | }) |
| | | } finally { |
| | | wx.hideLoading() |
| | | } |
| | | }, |
| | | |
| | | getFileSizeText(size) { |
| | | if (!size || size <= 0) { |
| | | return '未知大小' |
| | | } |
| | | if (size < 1024) { |
| | | return `${size}B` |
| | | } |
| | | if (size < 1024 * 1024) { |
| | | return `${(size / 1024).toFixed(1)}KB` |
| | | } |
| | | return `${(size / (1024 * 1024)).toFixed(1)}MB` |
| | | }, |
| | | |
| | | getStateText(state) { |
| | | switch (state) { |
| | | case 0: |