index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. import { guardPage } from '@/utils/guard.js'
  25. export default {
  26. data() {
  27. return {
  28. list: [],
  29. loading: true
  30. }
  31. },
  32. onShow() {
  33. if (!guardPage()) return
  34. this.loadMaterials()
  35. },
  36. methods: {
  37. loadMaterials() {
  38. var self = this
  39. self.loading = true
  40. getClassMaterials().then(function(resp) {
  41. self.list = resp.data || []
  42. }).catch(function(err) {
  43. uni.showToast({ title: (err && err.message) || '获取资料失败', icon: 'none' })
  44. }).finally(function() {
  45. self.loading = false
  46. })
  47. },
  48. // 预览占位:test-mode 未接入文件服务,提示跳转后台配置的附件地址
  49. preview(m) {
  50. if (m.fileUrl) {
  51. uni.showToast({ title: '预览功能待接入,请用文件地址访问', icon: 'none' })
  52. } else {
  53. uni.showToast({ title: '该资料暂无附件', icon: 'none' })
  54. }
  55. }
  56. }
  57. }
  58. </script>
  59. <style scoped>
  60. .material-page { min-height: 100vh; background: #F5F5F5; padding: 24rpx 32rpx; }
  61. .section-card { background: #FFF; border-radius: 16rpx; padding: 32rpx; margin-bottom: 24rpx; }
  62. .section-title { display: block; font-size: 32rpx; font-weight: 700; color: #1E293B; margin-bottom: 8rpx; border-left: 8rpx solid #F97316; padding-left: 16rpx; }
  63. .card-desc { display: block; font-size: 26rpx; color: #64748B; margin-bottom: 28rpx; }
  64. .material-list { margin-top: 8rpx; }
  65. .material-item { display: flex; align-items: center; padding: 24rpx 0; border-bottom: 1rpx solid #F1F5F9; }
  66. .material-icon { font-size: 40rpx; margin-right: 16rpx; }
  67. .material-info { flex: 1; display: flex; flex-direction: column; }
  68. .material-title { font-size: 28rpx; font-weight: 500; color: #1E293B; }
  69. .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; }
  70. .material-badge.general { color: #64748B; background: #F1F5F9; }
  71. .material-preview { font-size: 26rpx; color: #F97316; margin-left: 16rpx; }
  72. .empty-text { font-size: 26rpx; color: #94A3B8; text-align: center; padding: 40rpx 0; }
  73. </style>