| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <template>
- <view class="material-page">
- <view class="section-card">
- <text class="section-title">课前资料包</text>
- <text class="card-desc">进班后可见本班次专属资料与通用资料</text>
- <LoadingSkeleton v-if="loading" :rows="2" />
- <ErrorState v-else-if="error" message="资料加载失败" @retry="loadMaterials" />
- <EmptyState v-else-if="list.length === 0" icon="📄" title="暂无课前资料" desc="请留意后续更新" />
- <view v-else class="material-list">
- <view class="material-item" v-for="(m, idx) in list" :key="idx">
- <text class="material-icon">📄</text>
- <view class="material-info">
- <text class="material-title">{{ m.title }}</text>
- <text class="material-badge" v-if="m.classId">班次专属</text>
- <text class="material-badge general" v-else>通用</text>
- </view>
- <text class="material-preview" @click="preview(m)">预览</text>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import { getClassMaterials } from '@/utils/api.js'
- import { guardPage } from '@/utils/guard.js'
- import LoadingSkeleton from '@/components/loading-skeleton.vue'
- import ErrorState from '@/components/error-state.vue'
- import EmptyState from '@/components/empty-state.vue'
- export default {
- components: { LoadingSkeleton, ErrorState, EmptyState },
- data() {
- return {
- list: [],
- loading: true,
- error: false
- }
- },
- onShow() {
- if (!guardPage()) return
- this.loadMaterials()
- },
- methods: {
- loadMaterials() {
- var self = this
- self.loading = true
- self.error = false
- getClassMaterials().then(function(resp) {
- self.list = resp.data || []
- }).catch(function() {
- self.error = true
- }).finally(function() {
- self.loading = false
- })
- },
- // 预览占位:test-mode 未接入文件服务,提示跳转后台配置的附件地址
- preview(m) {
- if (m.fileUrl) {
- uni.showToast({ title: '预览功能待接入,请用文件地址访问', icon: 'none' })
- } else {
- uni.showToast({ title: '该资料暂无附件', icon: 'none' })
- }
- }
- }
- }
- </script>
- <style scoped>
- .material-page { min-height: 100vh; background: #F5FAFE; padding: 24rpx 32rpx; }
- .section-card { background: #FFF; border-radius: 16rpx; padding: 32rpx; margin-bottom: 24rpx; }
- .section-title { display: block; font-size: 32rpx; font-weight: 700; color: #1E3A5F; margin-bottom: 8rpx; border-left: 8rpx solid #2E6FA8; padding-left: 16rpx; }
- .card-desc { display: block; font-size: 26rpx; color: #3B5A78; margin-bottom: 28rpx; }
- .material-list { margin-top: 8rpx; }
- .material-item { display: flex; align-items: center; padding: 24rpx 0; border-bottom: 1rpx solid #E3ECF4; }
- .material-icon { font-size: 40rpx; margin-right: 16rpx; }
- .material-info { flex: 1; display: flex; flex-direction: column; }
- .material-title { font-size: 28rpx; font-weight: 500; color: #1E3A5F; }
- .material-badge { display: inline-block; align-self: flex-start; font-size: 20rpx; color: #2E6FA8; background: #E8F3FC; padding: 2rpx 12rpx; border-radius: 6rpx; margin-top: 8rpx; }
- .material-badge.general { color: #3B5A78; background: #E3ECF4; }
- .material-preview { font-size: 26rpx; color: #2E6FA8; margin-left: 16rpx; }
- .empty-text { font-size: 26rpx; color: #6B7B8C; text-align: center; padding: 40rpx 0; }
- </style>
|