Browse Source

feat(member): 添加获取课程头日期功能并优化课表页面

- 在 member.js 中新增 getDate 方法,用于获取课程头日期
- 修改 config.js,更新 API 地址和图片域名
- 重构 timetable 页面,优化课程列表展示和签到功能
- 移除日期列表相关代码,改为使用新的课程头日期数据
master
liutong 1 year ago
parent
commit
a1bae61e34
  1. 8
      api/member.js
  2. 8
      common/config.js
  3. 112
      pages/student/timetable/index.vue

8
api/member.js

@ -50,4 +50,12 @@ export default {
return res; return res;
}) })
}, },
//获取课程头日期
getDate(data) {
let url = '/member/get_date'
return http.get(url, data).then(res => {
return res;
})
},
} }

8
common/config.js

@ -1,10 +1,10 @@
// 线上地址 // 线上地址
// const Api_url='http://146.56.228.75:20021/api' const Api_url='http://146.56.228.75:20021/api'
// const img_domian = 'http://146.56.228.75:20021/' const img_domian = 'http://146.56.228.75:20021/'
//本地测试地址 //本地测试地址
const Api_url='http://zhjw.cc/api' // const Api_url='http://zhjw.cc/api'
const img_domian = 'http://zhjw.cc/' // const img_domian = 'http://zhjw.cc/'
const IsDemo = false const IsDemo = false

112
pages/student/timetable/index.vue

@ -10,11 +10,11 @@
<view class="section_1"> <view class="section_1">
<view class="ul"> <view class="ul">
<view class="li" v-for="(v,k) in dateList" :key="k" @click="selectDate(v.date)"> <view class="li" v-for="(v,k) in dateList" :key="k" @click="selectDate(v.date)">
<text>{{v.name}}</text> <text>{{v.week}}</text>
<text :class="[filteredData.schedule_date == v.date ? 'today':'']">{{today == v.date ? '今':v.today}}</text> <text :class="[filteredData.schedule_date == v.date ? 'today':'']">{{today == v.date ? '今':v.today}}</text>
<text :class="[today == v.date ?'select_plan':'']"></text> <text :class="[v.status == 2 ?'select_plan':'']"></text>
</view> </view>
</view> </view>
</view> </view>
@ -40,15 +40,14 @@
<view v-for="(v,k) in tableList" :key="k" class="li" @click="openViewCourseInfo({id:v.id})"> <view v-for="(v,k) in tableList" :key="k" class="li" @click="openViewCourseInfo({id:v.id})">
<view class="top_box"> <view class="top_box">
<view class="center_box"> <view class="center_box">
<view>班级{{v.name}}</view> <view>班级{{v.classes_name}}</view>
<view>时间{{v.start_date}} - {{$util.formatToDateTime(v.end_date,'H:i')}}</view> <view>时间{{v.date}}</view>
<view>课室{{v.address}} <view>课室{{v.address}}</view>
</view> <view>课程{{v.courses_name}}</view>
<view>课程{{v.courses_name}}
</view>
</view> </view>
<view class="right_box"> <view class="right_box">
<view class="tag" :style="{background: v.status === 1 ? '#1cd188' : v.status === 2 ? '#fad24e' : '#ff4d4f'}"> <!-- v.status|1=未开始,2=进行中,3=已结束-->
<view class="tag" :style="{background: v.status == 1 ? '#1cd188' : v.status == 2 ? '#fad24e' : '#ff4d4f'}">
{{ v.status === 1 ? '未开始' : v.status === 2 ? '上课中' : '已结束' }} {{ v.status === 1 ? '未开始' : v.status === 2 ? '上课中' : '已结束' }}
</view> </view>
<!-- <view class="tag" style="background:#1cd188;">待上课</view>--> <!-- <view class="tag" style="background:#1cd188;">待上课</view>-->
@ -56,12 +55,12 @@
</view> </view>
<view class="bottom_box"> <view class="bottom_box">
<view class="hint"> <view class="hint">
已签到学生 ({{v.has_sign_count }}/{{v.max_students }}) 已签到学生 ({{v.sign_list.length }}/{{v.max_students.split(',').length }})
</view> </view>
<view class="list_box"> <view class="list_box">
<view class="list"> <view class="list">
<view class="itme" v-for="index in parseInt(v.has_sign_count) || 0" :key="index"> <view class="itme" v-for="(item,index) in v.sign_list || 0" :key="index">
<image src="http://www.firstui.cn:4000/vipdoc/img/img_logo.png"></image> <image :src="$util.img(item.header)"></image>
</view> </view>
</view> </view>
<view class="btn" @click="openViewTimetableInfo(v)"> <view class="btn" @click="openViewTimetableInfo(v)">
@ -114,7 +113,10 @@ export default {
dateList:[]// dateList:[]//
} }
}, },
onLoad() { onLoad(options) {
if(options.venue_id){
this.filteredData.venue_id = options.venue_id
}
}, },
onShow() { onShow() {
this.init()// this.init()//
@ -123,7 +125,6 @@ export default {
async onPullDownRefresh() { async onPullDownRefresh() {
// //
let schedule_date = this.filteredData.schedule_date let schedule_date = this.filteredData.schedule_date
console.log('eee',schedule_date)
await this.loadData() await this.loadData()
this.filteredData.schedule_date = schedule_date this.filteredData.schedule_date = schedule_date
await this.getList() await this.getList()
@ -132,14 +133,42 @@ export default {
methods: { methods: {
// //
async init(){ async init(){
await this.getDate() await this.getThisDate()
await this.getHeadDate()
await this.getList() await this.getList()
await this.getDateList(); // // await this.getDateList(); //
console.log(1111,this.dateList) },
//
async getHeadDate() {
let res = await memberApi.getDate()
if (res.code != 1){
//
uni.showToast({
title: res.msg,
icon: 'none',
})
return
}
this.dateList = []
res.data.forEach((v,k)=>{
let today = v.date.split("-")[2]; // "09"
this.dateList.push({
date: v.date,
status: v.status,//1 2
week: v.week,
today: today,
})
})
console.log('xxx',res)
}, },
// //
async getDate() { async getThisDate() {
let date = new Date(); let date = new Date();
let year = date.getFullYear(); let year = date.getFullYear();
let month = String(date.getMonth() + 1).padStart(2, '0'); // let month = String(date.getMonth() + 1).padStart(2, '0'); //
@ -152,39 +181,6 @@ export default {
this.today = res; this.today = res;
this.filteredData.schedule_date = res; this.filteredData.schedule_date = res;
}, },
//
async getDateList() {
const days = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
const dateList = [];
const today = new Date(); //
// 24
for (let i = -2; i <= 4; i++) {
const date = new Date(today);
date.setDate(today.getDate() + i); //
let dayOfWeek = days[date.getDay()]; //
let formattedDateArr = this.formatDate(date); //
let formattedDate = `${formattedDateArr[0]}-${formattedDateArr[1]}-${formattedDateArr[2]}`; //
dateList.push({
name: dayOfWeek,
date: formattedDate,
today: formattedDateArr[2],//
});
}
this.dateList = dateList
},
// YYYY-MM-DD
formatDate(date) {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
return [
year, month, day
]
},
//() //()
loadMoreData() { loadMoreData() {
@ -197,13 +193,10 @@ export default {
// //
async loadData() { async loadData() {
this.isReachedBottom = false; // 便 this.isReachedBottom = false; // 便
this.filteredData = {
page:1,// this.filteredData.page = 1//
limit:10,// this.filteredData.limit = 10//
total:10,// this.filteredData.total = 10//
schedule_date:'',//
venue_id:'',//id
}
}, },
// //
async getList(){ async getList(){
@ -251,8 +244,9 @@ export default {
// //
openViewTimetableInfo(item){ openViewTimetableInfo(item){
// courses_id=id
uni.navigateTo({ uni.navigateTo({
url: `/pages/student/timetable/info?id=${item.id}` url: `/pages/student/timetable/info?id=${item.courses_id}`
}) })
}, },
// //

Loading…
Cancel
Save