智慧教务系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

279 lines
5.4 KiB

<!--家长端教学资料页面-->
<template>
<view class="main_box">
<!-- 选中孩子信息 -->
<view class="child_info_bar" v-if="selectedChild">
<view class="child_avatar">
<image :src="selectedChild.avatar" mode="aspectFill"></image>
</view>
<view class="child_details">
<view class="child_name">{{ selectedChild.name }}</view>
<view class="child_class">{{ selectedChild.class_name || '未分配班级' }}</view>
</view>
</view>
<!-- 教学资料列表 -->
<view class="materials_list">
<view class="section_title">教学资料</view>
<view class="materials_items">
<view
v-for="material in materialsList"
:key="material.id"
class="material_item"
@click="viewMaterialDetail(material)"
>
<view class="material_main">
<view class="material_header">
<view class="material_title">{{ material.title }}</view>
<view class="material_type">{{ material.type }}</view>
</view>
<view class="material_details">
<view class="detail_row">
<text class="detail_label">发布时间:</text>
<text class="detail_value">{{ material.created_at }}</text>
</view>
<view class="detail_row">
<text class="detail_label">资料类型:</text>
<text class="detail_value">{{ material.type }}</text>
</view>
</view>
</view>
<view class="material_arrow">
<image :src="$util.img('/uniapp_src/static/images/index/right_arrow.png')" class="arrow-icon"></image>
</view>
</view>
</view>
</view>
<!-- 空状态 -->
<view class="empty_state" v-if="!loading && materialsList.length === 0">
<image :src="$util.img('/uniapp_src/static/images/common/empty.png')" class="empty_icon"></image>
<view class="empty_text">暂无教学资料</view>
</view>
<!-- 加载状态 -->
<view class="loading_state" v-if="loading">
<view class="loading_text">加载中...</view>
</view>
</view>
</template>
<script>
import { mapState } from 'vuex'
import apiRoute from '@/api/apiRoute.js'
export default {
data() {
return {
materialsList: [],
loading: false,
childId: null
}
},
computed: {
...mapState(['selectedChild'])
},
onLoad(options) {
this.childId = options.childId
this.loadMaterialsList()
},
methods: {
async loadMaterialsList() {
if (!this.childId) {
uni.showToast({
title: '缺少孩子ID参数',
icon: 'none'
})
return
}
this.loading = true
try {
const response = await apiRoute.parent_getChildMaterials({
child_id: this.childId
})
if (response.code === 1) {
this.materialsList = response.data.data || []
} else {
uni.showToast({
title: response.msg || '获取教学资料失败',
icon: 'none'
})
}
} catch (error) {
console.error('获取教学资料失败:', error)
uni.showToast({
title: '获取教学资料失败',
icon: 'none'
})
} finally {
this.loading = false
}
},
viewMaterialDetail(material) {
this.$navigateTo({
url: `/pages/parent/materials/material-detail?materialId=${material.id}&childId=${this.childId}`
})
}
}
}
</script>
<style lang="less" scoped>
.main_box {
background: #f8f9fa;
min-height: 100vh;
padding: 20rpx;
}
.child_info_bar {
background: #fff;
border-radius: 16rpx;
padding: 24rpx;
margin-bottom: 20rpx;
display: flex;
align-items: center;
gap: 20rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
.child_avatar {
width: 80rpx;
height: 80rpx;
border-radius: 50%;
overflow: hidden;
image {
width: 100%;
height: 100%;
}
}
.child_details {
flex: 1;
.child_name {
font-size: 28rpx;
font-weight: 600;
color: #333;
margin-bottom: 8rpx;
}
.child_class {
font-size: 24rpx;
color: #666;
}
}
}
.materials_list {
.section_title {
font-size: 32rpx;
font-weight: 600;
color: #333;
margin-bottom: 24rpx;
padding-left: 8rpx;
}
.materials_items {
display: flex;
flex-direction: column;
gap: 16rpx;
}
}
.material_item {
background: #fff;
border-radius: 16rpx;
padding: 28rpx;
display: flex;
align-items: center;
gap: 20rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
.material_main {
flex: 1;
.material_header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16rpx;
.material_title {
font-size: 30rpx;
font-weight: 600;
color: #333;
}
.material_type {
font-size: 22rpx;
padding: 4rpx 12rpx;
border-radius: 12rpx;
background: rgba(41, 211, 180, 0.1);
color: #29d3b4;
}
}
.material_details {
.detail_row {
display: flex;
margin-bottom: 8rpx;
.detail_label {
font-size: 24rpx;
color: #666;
min-width: 160rpx;
}
.detail_value {
font-size: 24rpx;
color: #333;
flex: 1;
}
}
}
}
.material_arrow {
.arrow-icon {
width: 24rpx;
height: 24rpx;
opacity: 0.4;
}
}
}
.empty_state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 120rpx 0;
.empty_icon {
width: 160rpx;
height: 160rpx;
margin-bottom: 32rpx;
opacity: 0.3;
}
.empty_text {
font-size: 28rpx;
color: #999;
}
}
.loading_state {
display: flex;
justify-content: center;
align-items: center;
padding: 60rpx 0;
.loading_text {
font-size: 28rpx;
color: #666;
}
}
</style>