123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311 |
- <template>
- <view>
- <u-navbar title="我的课表">
- <view class="slot-wrap" @click="getToday()">
- 今天
- </view>
- </u-navbar>
- <!-- 日期 -->
- <view class="date-picker">
- <view class="check" @click="beforeWeek">
- <u-icon name="arrow-left" size="32"></u-icon>前一周
- </view>
- <view class="date">
- {{date}}
- </view>
- <view class="check" @click="afterWeek">
- 后一周<u-icon name="arrow-right" size="32"></u-icon>
- </view>
- </view>
- <view class="date-item">
- <view class="item" v-for="(item,index) in weekDate" :key="index"
- :class="activeClass == index ? 'checked' : ''" @click="activeClassClick(item,index)">
- <view :class="item.isDotShow ? 'dot' : ''"
- :style="activeClass == index ? 'background-color: #fff;' : ''">
- </view>
- <view class="week ">
- {{item.week}}
- </view>
- <view class="day ">
- {{parseInt(item.day.slice(8))}}
- </view>
- </view>
- </view>
- <!-- 课表信息 -->
- <view class="class-infos">
- <view class="info-box" v-for="(item,index) in courseList" :key="index"
- @click="gotoUrl('pages/teacher/myCourse/CourseDetails?id=' + item.sheetId)">
- <view class="infos">
- <view class="time">
- <img src="../../../assets/img/riLine-time-line@1x.png" alt="">
- {{item.coursePeriods!=null ? item.coursePeriods : '线下约时间'}}
- </view>
- <view class="class-name">
- {{item.className}}
- </view>
- <view class="location">
- {{item.classroomName}}
- </view>
- </view>
- <view class="icon">
- <u-icon name="arrow-right" size="32" color="#cccccc"></u-icon>
- </view>
- </view>
- </view>
- <!-- <u-divider>没有更多数据了</u-divider> -->
- </view>
- </template>
- <script>
- import * as myCourseApi from '@/apis/teacher/myCourse.js'
- export default {
- data() {
- return {
- date: '',
- weekDate: [],
- weekN: ["一", "二", "三", "四", "五", "六", "日"],
- activeClass: 0,
- weekDate1: '',
- courseList: [],
- teacherId: ''
- }
- },
- onReady() {
- this.getToday();
- },
- methods: {
- getCourseList() {
- this.courseList = [];
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- myCourseApi.loadMySchedule({
- startDate: this.weekDate[0].day,
- endDate: this.weekDate[6].day
- }).then((response) => {
- uni.hideLoading();
- var list = response.data;
- for (var i = 0; i < list.length; i++) {
- if (this.date == list[i].courseDate) {
- this.courseList.push(list[i]);
- }
- for (var j = 0; j < this.weekDate.length; j++) {
- if (this.weekDate[j].day == list[i].courseDate) {
- this.weekDate[j].isDotShow = true;
- }
- }
- }
- }).catch(error => {
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- },
- getToday() {
- this.weekDate = [];
- let date = new Date(); //当前日期
- let year = date.getFullYear(); //当前年
- let month = date.getMonth() + 1; //当前月
- let day = date.getDate(); //当天
- let mydate = new Date(year, month - 1, day);
- let weekday = mydate.getDay();
- this.weekDate1 = new Date(year, month - 1, day + 1 - weekday);
- this.getWeekDate(true);
- },
- getWeekDate(bl) {
- let weekDate2 = new Date(this.weekDate1.getTime());
- for (var i = 0; i < 7; i++) {
- for (var j = 0; j < this.weekN.length; j++) {
- if (i == j) {
- this.weekDate.push({
- week: this.weekN[j],
- day: this.getFormatDate(new Date(weekDate2.setDate(this.weekDate1.getDate() + i))),
- isDotShow: false
- })
- }
- }
- }
- if (bl) {
- let date = new Date(); //当前日期
- date = this.getFormatDate(date);
- for (var m = 0; m < this.weekDate.length; m++) {
- if (date == this.weekDate[m].day) {
- this.activeClass = m;
- this.date = this.weekDate[m].day;
- }
- }
- this.getCourseList();
- }
- },
- getFormatDate(date) {
- let myyear = date.getFullYear();
- let mymonth = date.getMonth() + 1;
- let myweekday = date.getDate();
- if (mymonth < 10) {
- mymonth = "0" + mymonth;
- }
- if (myweekday < 10) {
- myweekday = "0" + myweekday;
- }
- return (myyear + "-" + mymonth + "-" + myweekday);
- },
- beforeWeek() {
- this.weekDate = [];
- this.weekDate1 = new Date(this.weekDate1.setDate(this.weekDate1.getDate() - 7));
- this.getWeekDate();
- for (var m = 0; m < this.weekDate.length; m++) {
- if (this.activeClass == m) {
- this.date = this.weekDate[m].day;
- }
- }
- this.getCourseList();
- },
- afterWeek() {
- this.weekDate = [];
- this.weekDate1 = new Date(this.weekDate1.setDate(this.weekDate1.getDate() + 7));
- this.getWeekDate();
- for (var m = 0; m < this.weekDate.length; m++) {
- if (this.activeClass == m) {
- this.date = this.weekDate[m].day;
- }
- }
- this.getCourseList();
- },
- activeClassClick(item, index) {
- this.activeClass = index;
- for (var m = 0; m < this.weekDate.length; m++) {
- if (index == m) {
- this.date = this.weekDate[m].day;
- }
- }
- this.getCourseList();
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- // 日期
- .date-picker {
- background-color: #fff;
- display: flex;
- justify-content: space-between;
- padding: 10px 12px 17px 12px;
- color: rgba(13, 186, 199, 1);
- .date {
- font-size: 16px
- }
- }
- .date-item {
- background-color: #fff;
- display: flex;
- justify-content: space-around;
- padding: 0 12px 16px 12px;
- border-radius: 0px 0px 9px 9px;
- box-shadow: 0px 4px 4px 0px #CFD2D5;
- .item {
- line-height: 20px;
- border-radius: 8px;
- background-color: rgba(238, 238, 238, 1);
- color: #1C222A;
- text-align: center;
- width: 12%;
- padding: 12rpx 0;
- position: relative;
- .week {
- font-size: 12px;
- }
- .day {
- font-size: 16px;
- font-weight: bold;
- }
- }
- .checked {
- background-color: rgba(13, 186, 199, 1);
- color: #fff;
- }
- .dot {
- width: 6px;
- height: 6px;
- background-color: rgba(13, 186, 199, 1);
- border-radius: 999px;
- position: absolute;
- top: 8rpx;
- right: 8rpx;
- }
- .dot-checked {
- background-color: #fff;
- }
- }
- // 课表信息
- .class-infos {
- padding: 0 15px;
- margin-bottom: 24rpx;
- .info-box {
- border-radius: 12px;
- background-color: rgba(255, 255, 255, 1);
- margin-top: 12px;
- padding: 16px 20px;
- display: flex;
- justify-content: space-between;
- align-items: center;
- .infos {
- .time {
- line-height: 20px;
- color: rgba(16, 16, 16, 1);
- display: flex;
- align-items: center;
- img {
- width: 16px;
- height: 16px;
- margin-right: 4px;
- }
- }
- .class-name {
- margin-top: 4px;
- line-height: 28px;
- color: rgba(51, 51, 51, 1);
- font-size: 20px;
- font-weight: bold;
- }
- .location {
- line-height: 16px;
- color: rgba(119, 119, 119, 1);
- font-size: 14px;
- margin-top: 4px;
- }
- }
- }
- }
- /deep/.u-slot-content {
- display: block;
- text-align: right !important;
- margin-right: 16px;
- color: #333333;
- }
- </style>
|