Browse Source

refactor(coach): 重构教练端到课统计页面

-优化课程列表渲染逻辑,使用 v-for 指令
- 添加课程列表数据请求和分页加载功能
- 修复到课率计算公式
- 优化页面样式,调整布局和字体颜色
- 修复导航栏标题文字错误
master
liutong 12 months ago
parent
commit
055725ec5c
  1. 2
      pages.json
  2. 2
      pages/coach/class/info.vue
  3. 208
      pages/coach/my/arrival_statistics.vue

2
pages.json

@ -307,7 +307,7 @@
{ {
"path": "pages/coach/my/arrival_statistics", "path": "pages/coach/my/arrival_statistics",
"style": { "style": {
"navigationBarTitleText": "到统计", "navigationBarTitleText": "到统计",
"navigationStyle": "default", "navigationStyle": "default",
"navigationBarBackgroundColor": "#292929", "navigationBarBackgroundColor": "#292929",
"navigationBarTextStyle": "white" "navigationBarTextStyle": "white"

2
pages/coach/class/info.vue

@ -119,7 +119,7 @@
<view <view
class="li" class="li"
v-for="(v,k) in courseList" v-for="(v,k) in courseList"
:key="l" :key="k"
@click="openViewCourseInfo(v)" @click="openViewCourseInfo(v)"
> >
<view class="top_box"> <view class="top_box">

208
pages/coach/my/arrival_statistics.vue

@ -3,64 +3,51 @@
<view class="main_box"> <view class="main_box">
<view class="main_section"> <view class="main_section">
<view class="section_3">
<scroll-view
class="section_3"
scroll-y="true"
:lower-threshold="lowerThreshold"
@scrolltolower="loadMoreData"
style="height: 90vh;"
>
<view class="ul"> <view class="ul">
<view class="li"> <view class="li"
v-for="(v,k) in courseList"
:key="k"
@click="openViewCourseInfo(v)"
>
<view class="left_box"> <view class="left_box">
<view class="date_box"> <view class="date_box">
<text>12</text> <text>{{v.has_sign_count}}</text>
<text>/</text> <text>/</text>
<text>24</text> <text>{{v.students_count}}</text>
</view> </view>
<view class="ratio"> <view class="ratio">
到课率80% 到课率{{v.attendance_rate}}%
</view> </view>
</view> </view>
<view class="center_box"> <view class="center_box">
<view>班级少年班</view> <view>班级{{v.classes_name}}</view>
<view>时间2020-05-25 15:30 - 17:30</view> <view>时间{{v.date_time}} {{v.time_slot ? v.time_slot.replace(",", " - ") : ""}}</view>
<view>课室302 <view>课室{{v.address}}
</view> </view>
<view>课程篮球少儿课 <view>课程{{v.courses_name}}
</view> </view>
</view> </view>
<view class="right_box"> <view class="right_box">
<view class="tag" style="background:#fad24e;">上课中</view> <view v-if="v.status == 1" class="tag" style="background:#fad24e;">上课中</view>
<!-- <view class="tag" style="background:#1cd188;">待上课</view>--> <view v-else class="tag" style="background:#e2e2e2;">已结束</view>
</view>
</view>
<view class="li">
<view class="left_box">
<view class="date_box">
<text>12</text>
<text>/</text>
<text>24</text>
</view>
<view class="ratio">
到课率80%
</view>
</view>
<view class="center_box">
<view>班级少年班</view>
<view>时间2020-05-25 15:30 - 17:30</view>
<view>课室302
</view>
<view>课程篮球少儿课
</view>
</view>
<view class="right_box">
<!-- <view class="tag" style="background:#fad24e;">上课中</view>-->
<view class="tag" style="background:#1cd188;">待上课</view>
</view> </view>
</view> </view>
</view> </view>
</view> </scroll-view>
</view> </view>
</view> </view>
</template> </template>
<script> <script>
// import user from '@/api/user.js'; import memberApi from '@/api/member.js';
import AQTabber from "@/components/AQ/AQTabber.vue" import AQTabber from "@/components/AQ/AQTabber.vue"
@ -70,80 +57,105 @@ export default {
}, },
data() { data() {
return { return {
formData:{}, loading: false,//
lowerThreshold: 100,//
isReachedBottom: false,//|true=|false=
// //
show_course:false,// filteredData: {
// page: 1,//
course_name:'课程',// limit: 10,//
options_course: [ total: 10,//
{ class_id: '',//id
text: '请选择课程', },
value: '', courseList:[],//
checked: true
}, {
text: '羽毛球课程1',
value: '1'
}, {
text: '篮球课程2',
value: '2'
}
],
//
show_classroom:false,//
//
classroom_name:'课室',//
options_classroom: [
{
text: '请选择课室',
value: '',
checked: true
}, {
text: '羽毛球201',
value: '1'
}, {
text: '篮球室101',
value: '2'
}
],
} }
}, },
onLoad() { onLoad() {
}, },
onShow(){
this.init()
},
methods: { methods: {
// //
clickCourse(e){ async init(){
console.log(e) this.getCourseList()
this.course_name = e.text
this.show_course = true
}, },
//
filterTapCourse() { // .courseList
// //()
this.$refs.ref_course.show() loadMoreData() {
this.show_course = true; //
if (!this.isReachedBottom) {
this.isReachedBottom = true;//
this.getCourseList();
}
}, },
//
async loadData() {
this.isReachedBottom = false; // 便
this.filteredData.page = 1//
this.filteredData.limit = 10//
this.filteredData.total = 10//
},
//-
async getCourseList(){
let data = {...this.filteredData}
data.class_id = this.class_id
console.log(12123,this.courseList)
if(data.page == 1){
this.courseList = []
}
//
if (this.filteredData.page * this.filteredData.limit > this.filteredData.total || this.filteredData.limit > this.filteredData.total) {
this.loading = false
uni.showToast({
title: '暂无更多',
icon: 'none'
})
return
}
let res = await memberApi.courseList(data)
this.loading = false
this.isReachedBottom = false;
if (res.code != 1) {
uni.showToast({
title: res.msg,
icon: 'none'
})
return
}
let arr = []
res.data.list.data.forEach((v,k)=>{
let item = v
item.attendance_rate = (v.students_count && !isNaN(v.students_count) && v.students_count > 0) ?
parseFloat(((v.has_sign_count / v.students_count) * 100).toFixed(1)) : 0;
arr.push(item)
})
this.courseList = this.courseList.concat(res.data.list.data)// 使 concat
this.filteredData.total = res.data.list.total
console.log('获取课程列表',this.courseList)
this.filteredData.page++
//
clickClassroom(e){
console.log(e)
this.classroom_name = e.text
this.show_classroom = true
},
//
filterTapClassroom() {
//
this.$refs.ref_classroom.show()
this.show_classroom = true;
}, },
//
//
openViewCourseInfo(item){ openViewCourseInfo(item){
let id= item.id
uni.navigateTo({ uni.navigateTo({
url: '/pages/coach/course/info' url: `/pages/coach/course/info_list?id=${id}`
}) })
}, },
} }
@ -210,7 +222,7 @@ export default {
align-items: center; align-items: center;
.left_box{ .left_box{
margin-left: 28rpx; margin-left: 28rpx;
width: 146rpx; width: 175rpx;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 10rpx; gap: 10rpx;
@ -226,7 +238,7 @@ export default {
} }
} }
.center_box{ .center_box{
margin-left: 52rpx; margin-left: 22rpx;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 10rpx; gap: 10rpx;

Loading…
Cancel
Save