|
@@ -3,12 +3,12 @@
|
|
|
<nav-bar title="学习计划"></nav-bar>
|
|
|
<view v-if="havePlan">
|
|
|
<view class="card" v-if="havePlan">
|
|
|
- <swiper :style="{height:!isOpen?'550rpx':'260rpx'}" class="swiper" :current="swiperIndex" :duration="duration">
|
|
|
+ <swiper :style="{height:isOpen?'550rpx':'260rpx'}" class="swiper" :current="swiperIndex" :duration="300">
|
|
|
<swiper-item v-for="(swiperItem,swiperIndex) in swiperList" :key="swiperIndex">
|
|
|
<view class="date_t1">
|
|
|
- <!-- <u-icon name="arrow-left" size="28" v-if="havePreviousMonth" @click="swipeMonth(-1)"></u-icon> -->
|
|
|
+ <u-icon name="arrow-left" size="28" v-if="havePreviousMonth" @click="swipeMonth(-1)"></u-icon>
|
|
|
<text style="padding: 0 15rpx;">{{ swiperItem.year }}年 {{ swiperItem.month }}月</text>
|
|
|
- <!-- <u-icon name="arrow-right" size="28" v-if="haveNextMonth" @click="swipeMonth(1)"></u-icon> -->
|
|
|
+ <u-icon name="arrow-right" size="28" v-if="haveNextMonth" @click="swipeMonth(1)"></u-icon>
|
|
|
</view>
|
|
|
<view style="width: 100%;margin-top: 20rpx;">
|
|
|
<view v-for="(item, index) in date" :key="index" class="card_date">{{ item }}</view>
|
|
@@ -38,10 +38,10 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
<view style="width: 100%;display: flex;justify-content: center;" v-if="isOpen == false">
|
|
|
- <view @click="oepn_calendar" style="height: 20rpx;width: 40rpx;padding:20rpx 0;"><view class="date_line"></view></view>
|
|
|
+ <view @click="oepn_calendar(swiperItem)" style="height: 20rpx;width: 40rpx;padding:20rpx 0;"><view class="date_line"></view></view>
|
|
|
</view>
|
|
|
<view style="width: 100%;display: flex;justify-content: center;" v-else>
|
|
|
- <image class="date_line_close" @click="close_calendar" src="/static/close_card.png"></image>
|
|
|
+ <image class="date_line_close" @click="close_calendar(swiperItem)" src="/static/close_card.png"></image>
|
|
|
</view>
|
|
|
</swiper-item>
|
|
|
|
|
@@ -232,7 +232,7 @@ export default {
|
|
|
],
|
|
|
activeDate:'',
|
|
|
dayStudyList: [],
|
|
|
- listItem: {},
|
|
|
+ listItem: null,
|
|
|
currentMonth: 0,
|
|
|
havePlan: false,
|
|
|
goodsList: [] //用户拥有的商品
|
|
@@ -307,8 +307,8 @@ export default {
|
|
|
console.log(this.swiperIndex)
|
|
|
// console.log(index,198)
|
|
|
// this.isOpen = false;
|
|
|
- // this.haveNextMonth = false;
|
|
|
- // this.havePreviousMonth = false;
|
|
|
+ this.haveNextMonth = false;
|
|
|
+ this.havePreviousMonth = false;
|
|
|
// this.monthIndex = this.monthIndex + index;
|
|
|
// this.currentMonth = this.currentMonth + index;
|
|
|
// let item = this.listItem.calendarStudyVo[this.monthIndex];
|
|
@@ -316,54 +316,148 @@ export default {
|
|
|
// this.activeDate = '';
|
|
|
// // this.workList = this.calendarStudyVo.goodsVos;
|
|
|
// this.workList = this.getStudyCourseByDay();
|
|
|
- // if (this.monthIndex > 0) {
|
|
|
- // this.havePreviousMonth = true;
|
|
|
- // }
|
|
|
- // if (this.monthIndex < this.listItem.calendarStudyVo.length - 1) {
|
|
|
- // this.haveNextMonth = true;
|
|
|
- // }
|
|
|
+ if (this.swiperIndex > 0) {
|
|
|
+ this.havePreviousMonth = true;
|
|
|
+ }
|
|
|
+ if (this.swiperIndex < this.swiperList.length - 1) {
|
|
|
+ this.haveNextMonth = true;
|
|
|
+ }
|
|
|
// this.dealDayList();
|
|
|
},
|
|
|
- dealMonth() {
|
|
|
+ dealMonth(isFirst) {
|
|
|
|
|
|
this.swiperList = []
|
|
|
-
|
|
|
-
|
|
|
let date = new Date();
|
|
|
let currentMonth = date.getMonth() + 1;
|
|
|
- this.haveNextMonth = false;
|
|
|
- this.havePreviousMonth = false;
|
|
|
- this.calendarStudyVo = {}
|
|
|
- // this.workList = this.getStudyCourseByDay();
|
|
|
- // this.workList = this.listItem.goodsVos;
|
|
|
- if (this.listItem !== undefined) {
|
|
|
- for (let i = 0; i < this.listItem.calendarStudyVo.length; i++) {
|
|
|
- let item = this.listItem.calendarStudyVo[i];
|
|
|
- if (item.month == currentMonth) {
|
|
|
- this.monthIndex = i;
|
|
|
- this.calendarStudyVo = item;
|
|
|
- if (i > 0) {
|
|
|
- this.havePreviousMonth = true;
|
|
|
+ //初始化
|
|
|
+ if(isFirst) {
|
|
|
+ if (this.listItem != null) {
|
|
|
+ this.swiperList = [];
|
|
|
+ for (let i = 0; i < this.listItem.calendarStudyVo.length; i++) {
|
|
|
+ let item = this.listItem.calendarStudyVo[i];
|
|
|
+ let firstItem = item.dayStudyList[0]
|
|
|
+ for (let j = 0; j < firstItem.studyDay; j++) {
|
|
|
+ //补齐1号前的日数凑满一周
|
|
|
+ item.dayStudyList.unshift({ date: 0 });
|
|
|
+ }
|
|
|
+ if (item.month == currentMonth) {
|
|
|
+ this.swiperIndex = i;
|
|
|
+ if (i > 0) {
|
|
|
+ this.havePreviousMonth = true;
|
|
|
+ }
|
|
|
+ if (i < this.listItem.calendarStudyVo.length - 1) {
|
|
|
+ this.haveNextMonth = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for(let k = 0; k < item.dayStudyList.length; k += 7) {
|
|
|
+ this.swiperList.push({
|
|
|
+ dayStudyList:item.dayStudyList.slice(k,k+7),
|
|
|
+ year: item.year,
|
|
|
+ month: item.month
|
|
|
+ })
|
|
|
}
|
|
|
- if (i < this.listItem.calendarStudyVo.length - 1) {
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!this.calendarStudyVo.dayStudyList) { //计划没有当前月
|
|
|
+ this.swiperIndex = 0;
|
|
|
+ // this.calendarStudyVo = this.listItem.calendarStudyVo[0];
|
|
|
+
|
|
|
+ if(this.swiperList.length > 1) {
|
|
|
+ console.log('len')
|
|
|
this.haveNextMonth = true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- this.swiperList.push(this.listItem.calendarStudyVo[i])
|
|
|
+ this.dealDayList()
|
|
|
}
|
|
|
-
|
|
|
- if(!this.calendarStudyVo.dayStudyList) { //计划没有当前月
|
|
|
- this.monthIndex = 0;
|
|
|
- this.calendarStudyVo = this.listItem.calendarStudyVo[0];
|
|
|
+ } else { //非初始化
|
|
|
+ if(this.isOpen) { //点击展开日历
|
|
|
+
|
|
|
+ this.haveNextMonth = false;
|
|
|
+ this.havePreviousMonth = false;
|
|
|
+ this.swiperList = []
|
|
|
+ if (this.listItem != null) {
|
|
|
+ for (let i = 0; i < this.listItem.calendarStudyVo.length; i++) {
|
|
|
+ let item = this.listItem.calendarStudyVo[i];
|
|
|
+ let firstItem = item.dayStudyList[0]
|
|
|
+ for (let i = 0; i < firstItem.studyDay; i++) {
|
|
|
+ //补齐1号前的日数凑满一周
|
|
|
+ item.dayStudyList.unshift({ date: 0 });
|
|
|
+ }
|
|
|
+ if (item.month == currentMonth) {
|
|
|
+ this.swiperIndex = i;
|
|
|
+ if (i > 0) {
|
|
|
+ this.havePreviousMonth = true;
|
|
|
+ }
|
|
|
+ if (i < this.swiperList.length - 1) {
|
|
|
+ this.haveNextMonth = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ this.swiperList.push(this.listItem.calendarStudyVo[i])
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!this.calendarStudyVo.dayStudyList) { //计划没有当前月
|
|
|
+ this.monthIndex = 0;
|
|
|
+ // this.calendarStudyVo = this.listItem.calendarStudyVo[0];
|
|
|
+
|
|
|
+ if(this.swiperList.length > 1) {
|
|
|
+ console.log('len')
|
|
|
+ this.haveNextMonth = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log(this.swiperList)
|
|
|
+ this.dealDayList();
|
|
|
+ }
|
|
|
+ } else { //点击收起日历
|
|
|
+ this.swiperList = [];
|
|
|
+ for (let i = 0; i < this.listItem.calendarStudyVo.length; i++) {
|
|
|
+ let item = this.listItem.calendarStudyVo[i];
|
|
|
+ let firstItem = item.dayStudyList[0]
|
|
|
+ for (let j = 0; j < firstItem.studyDay; j++) {
|
|
|
+ //补齐1号前的日数凑满一周
|
|
|
+ item.dayStudyList.unshift({ date: 0 });
|
|
|
+ }
|
|
|
+ if (item.month == currentMonth) {
|
|
|
+ this.swiperIndex = i;
|
|
|
+ if (i > 0) {
|
|
|
+ this.havePreviousMonth = true;
|
|
|
+ }
|
|
|
+ if (i < this.swiperList.length - 1) {
|
|
|
+ this.haveNextMonth = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for(let k = 0; k < item.dayStudyList.length; k += 7) {
|
|
|
+ this.swiperList.push({
|
|
|
+ dayStudyList:item.dayStudyList.slice(k,k+7),
|
|
|
+ year: item.year,
|
|
|
+ month: item.month
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- if(this.listItem.calendarStudyVo.length > 1) {
|
|
|
- console.log('len')
|
|
|
- this.haveNextMonth = true;
|
|
|
+ if(!this.calendarStudyVo.dayStudyList) { //计划没有当前月
|
|
|
+ this.swiperIndex = 0;
|
|
|
+ // this.calendarStudyVo = this.listItem.calendarStudyVo[0];
|
|
|
+
|
|
|
+ if(this.swiperList.length > 1) {
|
|
|
+ console.log('len')
|
|
|
+ this.haveNextMonth = true;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ this.dealDayList()
|
|
|
}
|
|
|
- this.dealDayList();
|
|
|
}
|
|
|
+
|
|
|
},
|
|
|
openEdit(item) {
|
|
|
this.activeDate = '';
|
|
@@ -374,16 +468,16 @@ export default {
|
|
|
dealDayList() {
|
|
|
|
|
|
this.swiperList.forEach((swiper,index) => {
|
|
|
- let firstItem = swiper.dayStudyList[0]
|
|
|
- for (let i = 0; i < firstItem.studyDay; i++) {
|
|
|
- //补齐1号前的日数凑满一周
|
|
|
- swiper.dayStudyList.unshift({ date: 0 });
|
|
|
- }
|
|
|
+ // let firstItem = swiper.dayStudyList[0]
|
|
|
+ // for (let i = 0; i < firstItem.studyDay; i++) {
|
|
|
+ // //补齐1号前的日数凑满一周
|
|
|
+ // swiper.dayStudyList.unshift({ date: 0 });
|
|
|
+ // }
|
|
|
|
|
|
let date = new Date();
|
|
|
let num = date.getDate();
|
|
|
//如果不是当前月,默认显示第一周
|
|
|
- if ((date.getMonth() + 1) != this.calendarStudyVo.month) {
|
|
|
+ if ((date.getMonth() + 1) != swiper.month) {
|
|
|
num = 1;
|
|
|
}
|
|
|
|
|
@@ -669,7 +763,7 @@ export default {
|
|
|
self.list = result.data.rows;
|
|
|
if (result.data.rows.length > 0) {
|
|
|
self.listItem = self.list[0];
|
|
|
- self.dealMonth();
|
|
|
+ self.dealMonth(true);
|
|
|
self.havePlan = true;
|
|
|
// if (self.list.length > 0) {
|
|
|
// self.listItem = self.list[0];
|
|
@@ -712,10 +806,12 @@ export default {
|
|
|
},
|
|
|
close_calendar() {
|
|
|
this.isOpen = false;
|
|
|
+ this.dealMonth();
|
|
|
this.showDayList = this.calendarStudyVo.miniDayStudyList;
|
|
|
},
|
|
|
oepn_calendar() {
|
|
|
this.isOpen = true;
|
|
|
+ this.dealMonth();
|
|
|
this.showDayList = this.calendarStudyVo.dayStudyList;
|
|
|
},
|
|
|
random(min, max) {
|