123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358 |
- <template>
- <view>
- <u-navbar back-text="课程表">
- <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="dot" :class="activeClass == index ? 'dot-checked' : ''">
- </view>
- <view class="week ">
- {{item.week}}
- </view>
- <view class="day ">
- {{item.day}}
- </view>
- </view>
- </view>
- <!-- 课表信息 -->
- <view class="class-box">
- <view class="picture">
- <img src="../../../assets/img/classschedule.png" alt="">
- </view>
- <view class="infos">
- <view class="title">
- 中国舞十级班
- </view>
- <view class="tag">
- <view class="item">
- 二楼舞蹈一教室
- </view>
- <view class="item">
- 08:30-10:00
- </view>
- </view>
- <view class="else">
- <view class="teacher">
- <view class="photo">
- <img src="../../../assets/img/teachercard.png" alt="">
- </view>
- <view class="name">
- 陈老师
- </view>
- </view>
- <view class="class-times">
- <view class="text">
- 课次
- </view>
- <view class="num">
- 22
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- date: '',
- weekDate: [],
- weekN: ["一", "二", "三", "四", "五", "六", "日"],
- activeClass: 0,
- weekDate1: '',
- }
- },
- onReady() {
- this.getToday();
- },
- methods: {
- 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)))
- })
- }
- }
- }
- 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;
- }
- }
- }
- },
- 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() {
- console.log(this.activeClass)
- 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;
- }
- }
- },
- 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;
- }
- }
- },
- activeClassClick(item, index) {
- this.activeClass = index;
- for (var m = 0; m < this.weekDate.length; m++) {
- if (index == m) {
- this.date = this.weekDate[m].day;
- }
- }
- },
- }
- }
- </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;
- color: #333333;
- }
- }
- .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-box {
- margin: 12px 16px;
- padding: 24rpx 0 24rpx 24rpx;
- border-radius: 24rpx;
- background-color: rgba(255, 255, 255, 1);
- display: flex;
- .picture {
- width: 200rpx;
- height: 200rpx;
- border-radius: 4px;
- overflow: hidden;
- img {
- width: 100%;
- height: 100%;
- }
- }
- .infos {
- margin-left: 24rpx;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- flex: 1;
- .title {
- color: rgba(51, 51, 51, 1);
- font-size: 16px;
- font-weight: bold;
- }
- .tag {
- display: flex;
- .item {
- line-height: 40rpx;
- border-radius: 8rpx;
- background-color: rgba(241, 243, 244, 1);
- color: rgba(16, 16, 16, 1);
- text-align: center;
- margin-right: 12rpx;
- font-size: 24rpx;
- padding: 0 8rpx;
- }
- @media screen and (max-width: 310px) {
- .item {
- padding: 0 4rpx;
- margin-right: 8rpx;
- }
- }
- }
- .else {
- display: flex;
- justify-content: space-between;
- padding-right: 24rpx;
- .teacher {
- display: flex;
- align-items: center;
- .photo {
- width: 64rpx;
- height: 64rpx;
- border-radius: 50px;
- overflow: hidden;
- img {
- width: 100%;
- height: 100%;
- }
- }
- .name {
- color: rgba(16, 16, 16, 1);
- margin-left: 12px;
- }
- }
- .class-times {
- display: flex;
- align-items: center;
- .text {
- color: rgba(119, 119, 119, 1);
- font-size: 16px;
- }
- .num {
- line-height: 20px;
- border-radius: 4px;
- background-color: rgba(13, 186, 199, 1);
- color: rgba(255, 255, 255, 1);
- text-align: center;
- margin-left: 8rpx;
- padding: 0 4px;
- }
- }
- }
- }
- }
- /deep/.u-slot-content {
- display: block;
- text-align: right !important;
- margin-right: 16px;
- color: #333333;
- }
- </style>
|