|
@@ -6,7 +6,7 @@
|
|
<NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
|
|
<NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
|
|
</el-col>
|
|
</el-col>
|
|
<el-col :span="24" class="main">
|
|
<el-col :span="24" class="main">
|
|
- 主题偶
|
|
|
|
|
|
+ <mainData :lesson="lesson" :today="today" @getLesson="getLesson"></mainData>
|
|
</el-col>
|
|
</el-col>
|
|
<el-col :span="24" class="foot">
|
|
<el-col :span="24" class="foot">
|
|
<footInfo></footInfo>
|
|
<footInfo></footInfo>
|
|
@@ -19,23 +19,109 @@
|
|
<script>
|
|
<script>
|
|
import NavBar from '@/layout/common/topInfo.vue';
|
|
import NavBar from '@/layout/common/topInfo.vue';
|
|
import footInfo from '@/layout/common/footInfo.vue';
|
|
import footInfo from '@/layout/common/footInfo.vue';
|
|
|
|
+import mainData from '@/layout/index/mainData.vue';
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
import { mapState, createNamespacedHelpers } from 'vuex';
|
|
|
|
+const { mapActions: lesson } = createNamespacedHelpers('lesson');
|
|
export default {
|
|
export default {
|
|
name: 'index',
|
|
name: 'index',
|
|
props: {},
|
|
props: {},
|
|
components: {
|
|
components: {
|
|
NavBar,
|
|
NavBar,
|
|
footInfo,
|
|
footInfo,
|
|
|
|
+ mainData,
|
|
},
|
|
},
|
|
data: function() {
|
|
data: function() {
|
|
return {
|
|
return {
|
|
title: '',
|
|
title: '',
|
|
isleftarrow: '',
|
|
isleftarrow: '',
|
|
navShow: true,
|
|
navShow: true,
|
|
|
|
+ lesson: {},
|
|
|
|
+ today: {},
|
|
};
|
|
};
|
|
},
|
|
},
|
|
- created() {},
|
|
|
|
- methods: {},
|
|
|
|
|
|
+ created() {
|
|
|
|
+ let today = this.getDay();
|
|
|
|
+ let todate = this.getDate();
|
|
|
|
+ this.$set(this.today, `date`, todate);
|
|
|
|
+ this.$set(this.today, `day`, today);
|
|
|
|
+
|
|
|
|
+ if (this.user !== undefined) {
|
|
|
|
+ this.searchInfo();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ ...lesson({ lessionInfo: 'fetch', lessionlist: 'query' }),
|
|
|
|
+ // 查询课程详情
|
|
|
|
+ async searchInfo() {
|
|
|
|
+ let classid = sessionStorage.getItem('classid');
|
|
|
|
+ const result = await this.lessionlist({ classid });
|
|
|
|
+ let lessones = {};
|
|
|
|
+ for (const val of result.data) {
|
|
|
|
+ lessones = val;
|
|
|
|
+ }
|
|
|
|
+ var lesson = lessones.lessons.find(item => item.date === this.getDate());
|
|
|
|
+ this.$set(this, `lesson`, lesson);
|
|
|
|
+ // 获取课程开始-结束日期
|
|
|
|
+ this.$set(this, `originLesson`, lessones.lessons);
|
|
|
|
+ var ress = this.originLesson.filter(item => item.date === this.date);
|
|
|
|
+ this.$set(this, `lesson`, ress);
|
|
|
|
+ lessones.lessons.sort(function(a, b) {
|
|
|
|
+ if (a.date < b.date) {
|
|
|
|
+ return -1;
|
|
|
|
+ } else if (a.date > b.date) {
|
|
|
|
+ return 1;
|
|
|
|
+ } else {
|
|
|
|
+ if (a.date < b.date) {
|
|
|
|
+ return 1;
|
|
|
|
+ } else if (a.date > b.date) {
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ let ltime = lessones.lessons.map((i, index) => {
|
|
|
|
+ let object = { date: i.date, day: this.getDay(i.date) };
|
|
|
|
+ if (index !== 0) return object;
|
|
|
|
+ });
|
|
|
|
+ //排序
|
|
|
|
+ var appArray = _.uniqWith(ltime, _.isEqual);
|
|
|
|
+ appArray.sort(function(a, b) {
|
|
|
|
+ if (a.date < b.date) {
|
|
|
|
+ return -1;
|
|
|
|
+ } else if (a.date > b.date) {
|
|
|
|
+ return 1;
|
|
|
|
+ } else {
|
|
|
|
+ if (a.date < b.date) {
|
|
|
|
+ return 1;
|
|
|
|
+ } else if (a.date > b.date) {
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ this.$set(this, `arrange`, _.compact(appArray));
|
|
|
|
+ },
|
|
|
|
+ // 获取时间
|
|
|
|
+ getDay(date = new Date()) {
|
|
|
|
+ var str = '星期' + '日一二三四五六'.charAt(new Date(date).getDay());
|
|
|
|
+ return str;
|
|
|
|
+ },
|
|
|
|
+ getDate(date = new Date()) {
|
|
|
|
+ let res = new Date(date)
|
|
|
|
+ .toLocaleDateString()
|
|
|
|
+ .replace('/', '-')
|
|
|
|
+ .replace('/', '-');
|
|
|
|
+ let arr = res.split('-');
|
|
|
|
+ arr[1] = arr[1] * 1 >= 10 ? `${arr[1]}` : `0${arr[1]}`;
|
|
|
|
+ arr[2] = arr[2] * 1 >= 10 ? `${arr[2]}` : `0${arr[2]}`;
|
|
|
|
+ return `${arr[0]}-${arr[1]}-${arr[2]}`;
|
|
|
|
+ },
|
|
|
|
+ //点击日期获取课程
|
|
|
|
+ getLesson(date) {
|
|
|
|
+ var res = this.originLesson.filter(item => item.date === date.date);
|
|
|
|
+ this.$set(this, `lesson`, res);
|
|
|
|
+ },
|
|
|
|
+ },
|
|
computed: {
|
|
computed: {
|
|
...mapState(['user']),
|
|
...mapState(['user']),
|
|
},
|
|
},
|