From a1bae61e3479d094d598d6732017c1f55d3b4161 Mon Sep 17 00:00:00 2001
From: liutong <836164388@qq.com>
Date: Tue, 25 Mar 2025 11:02:06 +0800
Subject: [PATCH] =?UTF-8?q?feat(member):=20=E6=B7=BB=E5=8A=A0=E8=8E=B7?=
=?UTF-8?q?=E5=8F=96=E8=AF=BE=E7=A8=8B=E5=A4=B4=E6=97=A5=E6=9C=9F=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E5=B9=B6=E4=BC=98=E5=8C=96=E8=AF=BE=E8=A1=A8=E9=A1=B5?=
=?UTF-8?q?=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 在 member.js 中新增 getDate 方法,用于获取课程头日期
- 修改 config.js,更新 API 地址和图片域名
- 重构 timetable 页面,优化课程列表展示和签到功能
- 移除日期列表相关代码,改为使用新的课程头日期数据
---
api/member.js | 8 +++
common/config.js | 8 +--
pages/student/timetable/index.vue | 112 ++++++++++++++----------------
3 files changed, 65 insertions(+), 63 deletions(-)
diff --git a/api/member.js b/api/member.js
index 7789b79..e3c3718 100644
--- a/api/member.js
+++ b/api/member.js
@@ -50,4 +50,12 @@ export default {
return res;
})
},
+
+ //获取课程头日期
+ getDate(data) {
+ let url = '/member/get_date'
+ return http.get(url, data).then(res => {
+ return res;
+ })
+ },
}
\ No newline at end of file
diff --git a/common/config.js b/common/config.js
index 059450c..949925a 100644
--- a/common/config.js
+++ b/common/config.js
@@ -1,10 +1,10 @@
// 线上地址
-// const Api_url='http://146.56.228.75:20021/api'
-// const img_domian = 'http://146.56.228.75:20021/'
+const Api_url='http://146.56.228.75:20021/api'
+const img_domian = 'http://146.56.228.75:20021/'
//本地测试地址
-const Api_url='http://zhjw.cc/api'
-const img_domian = 'http://zhjw.cc/'
+// const Api_url='http://zhjw.cc/api'
+// const img_domian = 'http://zhjw.cc/'
const IsDemo = false
diff --git a/pages/student/timetable/index.vue b/pages/student/timetable/index.vue
index d195d4d..bc43c5a 100644
--- a/pages/student/timetable/index.vue
+++ b/pages/student/timetable/index.vue
@@ -10,11 +10,11 @@
- {{v.name}}
+ {{v.week}}
{{today == v.date ? '今':v.today}}
-
+
@@ -40,15 +40,14 @@
- 班级:{{v.name}}
- 时间:{{v.start_date}} - {{$util.formatToDateTime(v.end_date,'H:i')}}
- 课室:{{v.address}}
-
- 课程:{{v.courses_name}}
-
+ 班级:{{v.classes_name}}
+ 时间:{{v.date}}
+ 课室:{{v.address}}
+ 课程:{{v.courses_name}}
-
+
+
{{ v.status === 1 ? '未开始' : v.status === 2 ? '上课中' : '已结束' }}
@@ -56,12 +55,12 @@
- 已签到学生 ({{v.has_sign_count }}/{{v.max_students }})
+ 已签到学生 ({{v.sign_list.length }}/{{v.max_students.split(',').length }})
-
-
+
+
@@ -114,7 +113,10 @@ export default {
dateList:[]//日期列表
}
},
- onLoad() {
+ onLoad(options) {
+ if(options.venue_id){
+ this.filteredData.venue_id = options.venue_id
+ }
},
onShow() {
this.init()//初始化
@@ -123,7 +125,6 @@ export default {
async onPullDownRefresh() {
//重置为第一页
let schedule_date = this.filteredData.schedule_date
- console.log('eee',schedule_date)
await this.loadData()
this.filteredData.schedule_date = schedule_date
await this.getList()
@@ -132,14 +133,42 @@ export default {
methods: {
//初始化
async init(){
- await this.getDate()
+ await this.getThisDate()
+ await this.getHeadDate()
await this.getList()
- await this.getDateList(); // 获取日期列表
- console.log(1111,this.dateList)
+ // await this.getDateList(); // 获取日期列表
+ },
+
+ //获取课程头日期
+ 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 year = date.getFullYear();
let month = String(date.getMonth() + 1).padStart(2, '0'); // 月份前补零
@@ -152,39 +181,6 @@ export default {
this.today = res;
this.filteredData.schedule_date = res;
},
- // 获取日期列表
- async getDateList() {
- const days = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
- const dateList = [];
- const today = new Date(); // 获取当前日期
-
- // 获取前2天和后4天的日期
- 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() {
@@ -197,13 +193,10 @@ export default {
//重置为第一页
async loadData() {
this.isReachedBottom = false; // 重置状态,以便下次触发加载更多
- this.filteredData = {
- page:1,//当前页码
- limit:10,//每页返回数据条数
- total:10,//数据总条数
- schedule_date:'',//日期
- venue_id:'',//场地id
- }
+
+ this.filteredData.page = 1//当前页码
+ this.filteredData.limit = 10//每页返回数据条数
+ this.filteredData.total = 10//数据总条数
},
//获取列表
async getList(){
@@ -251,8 +244,9 @@ export default {
//打开课表详情页
openViewTimetableInfo(item){
+ // courses_id=课程id
uni.navigateTo({
- url: `/pages/student/timetable/info?id=${item.id}`
+ url: `/pages/student/timetable/info?id=${item.courses_id}`
})
},
//体育馆列表