index.vue 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <view class="material-page">
  3. <view class="section-card">
  4. <text class="section-title">课前资料包</text>
  5. <text class="card-desc">进班后可见本班次专属资料与通用资料</text>
  6. <view v-if="loading" class="empty-text">加载中…</view>
  7. <view v-else-if="list.length === 0" class="empty-text">暂无课前资料,请留意后续更新</view>
  8. <view class="material-list">
  9. <view class="material-item" v-for="(m, idx) in list" :key="idx">
  10. <text class="material-icon">📄</text>
  11. <view class="material-info">
  12. <text class="material-title">{{ m.title }}</text>
  13. <text class="material-badge" v-if="m.classId">班次专属</text>
  14. <text class="material-badge general" v-else>通用</text>
  15. </view>
  16. <text class="material-preview" @click="preview(m)">预览</text>
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import { getClassMaterials } from '@/utils/api.js'
  24. export default {
  25. data() {
  26. return {
  27. list: [],
  28. loading: true
  29. }
  30. },
  31. onShow() {
  32. this.loadMaterials()
  33. },
  34. methods: {
  35. loadMaterials() {
  36. var self = this
  37. self.loading = true
  38. getClassMaterials().then(function(resp) {
  39. self.list = resp.data || []
  40. }).catch(function(err) {
  41. uni.showToast({ title: (err && err.message) || '获取资料失败', icon: 'none' })
  42. }).finally(function() {
  43. self.loading = false
  44. })
  45. },
  46. // 预览占位:test-mode 未接入文件服务,提示跳转后台配置的附件地址
  47. preview(m) {
  48. if (m.fileUrl) {
  49. uni.showToast({ title: '预览功能待接入,请用文件地址访问', icon: 'none' })
  50. } else {
  51. uni.showToast({ title: '该资料暂无附件', icon: 'none' })
  52. }
  53. }
  54. }
  55. }
  56. </script>
  57. <style scoped>
  58. .material-page { min-height: 100vh; background: #F5F5F5; padding: 24rpx 32rpx; }
  59. .section-card { background: #FFF; border-radius: 16rpx; padding: 32rpx; margin-bottom: 24rpx; }
  60. .section-title { display: block; font-size: 32rpx; font-weight: 700; color: #1E293B; margin-bottom: 8rpx; border-left: 8rpx solid #F97316; padding-left: 16rpx; }
  61. .card-desc { display: block; font-size: 26rpx; color: #64748B; margin-bottom: 28rpx; }
  62. .material-list { margin-top: 8rpx; }
  63. .material-item { display: flex; align-items: center; padding: 24rpx 0; border-bottom: 1rpx solid #F1F5F9; }
  64. .material-icon { font-size: 40rpx; margin-right: 16rpx; }
  65. .material-info { flex: 1; display: flex; flex-direction: column; }
  66. .material-title { font-size: 28rpx; font-weight: 500; color: #1E293B; }
  67. .material-badge { display: inline-block; align-self: flex-start; font-size: 20rpx; color: #F97316; background: #FFF7ED; padding: 2rpx 12rpx; border-radius: 6rpx; margin-top: 8rpx; }
  68. .material-badge.general { color: #64748B; background: #F1F5F9; }
  69. .material-preview { font-size: 26rpx; color: #F97316; margin-left: 16rpx; }
  70. .empty-text { font-size: 26rpx; color: #94A3B8; text-align: center; padding: 40rpx 0; }
  71. </style>