张延森 3 년 전
부모
커밋
b6bffdc3cb
6개의 변경된 파일327개의 추가작업 그리고 183개의 파일을 삭제
  1. 17
    0
      jsconfig.json
  2. 0
    178
      src/components/Course.vue
  3. 48
    0
      src/components/RatioDiv/index.vue
  4. 1
    5
      src/router/index.js
  5. 152
    0
      src/views/Course.vue
  6. 109
    0
      src/views/components/CourseCard.vue

+ 17
- 0
jsconfig.json 파일 보기

@@ -0,0 +1,17 @@
1
+{
2
+  "compilerOptions": {
3
+    "baseUrl": "./",
4
+    "paths": {
5
+      "@/components/*": [
6
+        "src/components/*"
7
+      ],
8
+      "@/util/*": [
9
+        "src/util/*"
10
+      ],
11
+    }
12
+  },
13
+  "exclude": [
14
+    "node_modules",
15
+    "dist"
16
+  ]
17
+}

+ 0
- 178
src/components/Course.vue 파일 보기

@@ -1,178 +0,0 @@
1
-<template>
2
-  <div class="Course-box">
3
-    <div style="banner-box-top">
4
-      <van-swipe :autoplay="3000">
5
-        <van-swipe-item v-for="(image, index) in HomeBannerImages" :key="index">
6
-          <van-image width="100%" height="100%" :src="image.thumb" />
7
-        </van-swipe-item>
8
-      </van-swipe>
9
-    </div>
10
-    <!-- list -->
11
-    <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
12
-      <div class="Card-box" v-for="(item, index) in courseList" :key="index">
13
-        <!-- <van-cell v-for="item in list" :key="item" :title="item" /> -->
14
-        <div>
15
-          <div class="Card-box-top">
16
-            <img :src="item.content" alt />
17
-            <div class="Card-box-top-box">
18
-              <div class="Card-box-top-title">{{item.title}}</div>
19
-              <div
20
-                class="Card-box-top-time"
21
-              >课程时间:{{parseTime(item.startDate, '{m}月{d}日 {h}:{i}')}}~{{parseTime(item.endDate, '{m}月{d}日 {h}:{i}')}}</div>
22
-            </div>
23
-          </div>
24
-          <div class="Card-box-botton" @click="goQuestion(item.courseId)">
25
-            <div>查看详情</div>
26
-            <van-icon name="arrow" />
27
-          </div>
28
-        </div>
29
-      </div>
30
-    </van-list>
31
-  </div>
32
-</template>
33
-
34
-<script>
35
-import { parseTime } from '../util/formattingData'
36
-
37
-import { getBanner, getCourse } from '../util/api'
38
-export default {
39
-  data() {
40
-    return {
41
-      icon: require('../assets/icon/courseIcon.svg'),
42
-      loading: false,
43
-      finished: true,
44
-      currentPage: 1,
45
-      pageSize: 10,
46
-      courseList: [],
47
-      HomeBannerImages: []
48
-    }
49
-  },
50
-  mounted() {
51
-    this.onBanner()
52
-    this.kecheng()
53
-  },
54
-
55
-  methods: {
56
-    goQuestion(courseId) {
57
-      // this.$router.push({ name: 'ClassInfo', params: { courseId: courseId } })
58
-      this.$router.push('/Questionnaire')
59
-    },
60
-    parseTime, //时间格式化
61
-
62
-    kecheng() {
63
-      getCourse().then((e) => {
64
-        // console.log(parseTime(aTime, '{y}年{m}月{d}日 {h}:{i}'))
65
-
66
-        this.courseList = e.records
67
-      })
68
-    },
69
-    onBanner() {
70
-      getBanner('Training').then((e) => {
71
-        this.HomeBannerImages = e.records
72
-
73
-        console.log(e)
74
-      })
75
-    },
76
-    onLoad() {
77
-      // 异步更新数据
78
-      let params = {
79
-        // type: this.selectedType,
80
-        index: this.currentPage, //页数
81
-        size: this.pageSize //每页个数
82
-      }
83
-      xxxxxxx(params).then((res) => {
84
-        console.log(res)
85
-        this.dataTotal = res.total
86
-        //进行判断
87
-        if (this.dataTotal <= this.pageSize) {
88
-          this.Array = res.data.list
89
-          console.log(this.Array)
90
-        } else {
91
-          this.currentPage++
92
-          let arr = res.data.data.list
93
-          this.Array = this.Array.concat(arr)
94
-        }
95
-        // 加载状态结束
96
-        this.loading = false
97
-        // 数据全部加载完成
98
-        if (this.Array.length >= this.dataTotal) {
99
-          this.finished = true //结束,显示我也是有底线的
100
-        }
101
-      })
102
-    }
103
-  }
104
-}
105
-</script>
106
-
107
-<style lang="less" scoped>
108
-.Course-box {
109
-  width: 100vw;
110
-
111
-  .van-swipe {
112
-    width: 95%;
113
-    border-radius: 10px;
114
-    margin: 10px auto;
115
-    box-shadow: 0px 8px 38px 0px rgba(0, 0, 0, 0.2);
116
-    margin-bottom: 2em;
117
-    height: 33vh;
118
-    .van-swipe-item {
119
-    }
120
-  }
121
-  .van-cell-group {
122
-    display: flex;
123
-  }
124
-
125
-  .Card-box {
126
-    width: 93%;
127
-    border-radius: 10px;
128
-    background-color: #fff;
129
-    margin: 1em auto 0.4em auto;
130
-    box-shadow: 0 0 15px rgb(214, 214, 214);
131
-
132
-    .Card-box-top {
133
-      display: flex;
134
-      align-items: center;
135
-      padding: 0.8em 0 0.6em 0.4em;
136
-      > img {
137
-        width: 65px;
138
-        height: 65px;
139
-        border-radius: 50%;
140
-
141
-        // padding: 20px;
142
-      }
143
-      &-box {
144
-        // width: 63vw;
145
-      }
146
-
147
-      &-title {
148
-        font-size: 16px;
149
-        font-weight: 700;
150
-        letter-spacing: 1px;
151
-        padding: 0 0 12px 10px;
152
-      }
153
-      &-time {
154
-        font-size: 12px;
155
-        color: rgb(133, 133, 133);
156
-        padding: 0px 0 0px 10px;
157
-      }
158
-    }
159
-    .Card-box-botton {
160
-      width: 90%;
161
-      margin: 0 auto;
162
-      border-top: 1px solid rgb(238, 238, 238);
163
-      display: flex;
164
-      color: rgb(133, 133, 133);
165
-      justify-content: space-between;
166
-      font-size: 10px;
167
-
168
-      > div {
169
-        padding: 10px 0 10px 0;
170
-      }
171
-      .van-icon {
172
-        position: relative;
173
-        top: 1.9vh;
174
-      }
175
-    }
176
-  }
177
-}
178
-</style>

+ 48
- 0
src/components/RatioDiv/index.vue 파일 보기

@@ -0,0 +1,48 @@
1
+<template>
2
+  <div class="ratio-div">
3
+    <div class="ratio-div_box" :style="boxStyle"></div>
4
+    <div class="ratio-div_content"><slot></slot></div>
5
+  </div>
6
+</template>
7
+
8
+<script>
9
+export default {
10
+  name: 'RatioDiv',
11
+  props: {
12
+    ratio: Number
13
+  },
14
+  computed: {
15
+    boxStyle() {
16
+      if (!this.ratio) return {}
17
+
18
+      const percent = (this.ratio * 100).toFixed(2);
19
+      return {
20
+        paddingBottom: `${percent}%`
21
+      }
22
+    }
23
+  }
24
+}
25
+</script>
26
+
27
+<style lang="less" scoped>
28
+.ratio-div {
29
+  position: relative;
30
+  width: 100%;
31
+  overflow: hidden;
32
+
33
+  &_box {
34
+    width: 100%;
35
+    position: relative;
36
+    height: 0;
37
+    z-index: -1;
38
+  }
39
+
40
+  &_content {
41
+    width: 100%;
42
+    height: 100%;
43
+    position: absolute;
44
+    left: 0;
45
+    top: 0;
46
+  }
47
+}
48
+</style>

+ 1
- 5
src/router/index.js 파일 보기

@@ -5,7 +5,7 @@ import Router from 'vue-router'
5 5
 
6 6
 import store from '../store'
7 7
 
8
-import Course from '../components/Course.vue'//课程
8
+import Course from '@/views/Course.vue'//课程
9 9
 import MyCollection from '../components/MyCollection.vue'//收藏
10 10
 import signIn from '../components/signIn.vue'//打卡
11 11
 import ClassInfo from '../components/ClassInfo.vue'//课堂详情
@@ -21,10 +21,6 @@ Vue.use(Router)
21 21
 
22 22
 
23 23
 const router = new Router({
24
-
25
-  mode: "history",
26
-
27
-
28 24
   routes: [
29 25
 
30 26
 

+ 152
- 0
src/views/Course.vue 파일 보기

@@ -0,0 +1,152 @@
1
+<template>
2
+  <div class="Course-box">
3
+    <div class="banner-box-top mglr-10" >
4
+      <van-swipe class="banner-swipe" :autoplay="3000" @change="i => currentItem = i" :show-indicators="false">
5
+        <van-swipe-item v-for="(image, index) in HomeBannerImages" :key="index">
6
+          <ration-div :ratio="0.6">
7
+            <van-image width="100%" height="100%" :src="image.thumb" />
8
+          </ration-div>
9
+        </van-swipe-item>
10
+      </van-swipe>
11
+      <div class="custom-indicator">
12
+        <span v-for="(_, index) in HomeBannerImages" :key="index" :class="{'active': currentItem === index }"></span>
13
+      </div>
14
+    </div>
15
+    
16
+    <!-- list -->
17
+    <van-list class="mglr-10 course-list" v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
18
+      <course-card v-for="item in courseList" :key="item.courseId" v-bind="item"></course-card>
19
+    </van-list>
20
+  </div>
21
+</template>
22
+
23
+<script>
24
+import { parseTime } from '@/util/formattingData'
25
+import { getBanner, getCourse } from '@/util/api'
26
+
27
+export default {
28
+  components: {
29
+    RationDiv: () => import('@/components/RatioDiv/index.vue'),
30
+    CourseCard: () => import('./components/CourseCard.vue')
31
+  },
32
+
33
+  data() {
34
+    return {
35
+      currentItem: -1,
36
+      icon: require('@/assets/icon/courseIcon.svg'),
37
+      loading: false,
38
+      finished: true,
39
+      currentPage: 1,
40
+      pageSize: 10,
41
+      courseList: [],
42
+      HomeBannerImages: []
43
+    }
44
+  },
45
+  mounted() {
46
+    this.onBanner()
47
+    this.kecheng()
48
+  },
49
+
50
+  methods: {
51
+    goQuestion(courseId) {
52
+      // this.$router.push({ name: 'ClassInfo', params: { courseId: courseId } })
53
+      this.$router.push('/Questionnaire')
54
+    },
55
+    parseTime, //时间格式化
56
+
57
+    kecheng() {
58
+      getCourse().then((e) => {
59
+        // console.log(parseTime(aTime, '{y}年{m}月{d}日 {h}:{i}'))
60
+
61
+        this.courseList = e.records
62
+      })
63
+    },
64
+    onBanner() {
65
+      getBanner('Training').then((e) => {
66
+        this.HomeBannerImages = e.records
67
+
68
+        console.log(e)
69
+      })
70
+    },
71
+    onLoad() {
72
+      // 异步更新数据
73
+      let params = {
74
+        // type: this.selectedType,
75
+        index: this.currentPage, //页数
76
+        size: this.pageSize //每页个数
77
+      }
78
+      xxxxxxx(params).then((res) => {
79
+        console.log(res)
80
+        this.dataTotal = res.total
81
+        //进行判断
82
+        if (this.dataTotal <= this.pageSize) {
83
+          this.Array = res.data.list
84
+          console.log(this.Array)
85
+        } else {
86
+          this.currentPage++
87
+          let arr = res.data.data.list
88
+          this.Array = this.Array.concat(arr)
89
+        }
90
+        // 加载状态结束
91
+        this.loading = false
92
+        // 数据全部加载完成
93
+        if (this.Array.length >= this.dataTotal) {
94
+          this.finished = true //结束,显示我也是有底线的
95
+        }
96
+      })
97
+    }
98
+  }
99
+}
100
+</script>
101
+
102
+<style lang="less" scoped>
103
+
104
+.mglr-10 {
105
+  margin-left: 10px;
106
+  margin-right: 10px;
107
+}
108
+
109
+.Course-box {
110
+  width: 100vw;
111
+
112
+  .banner-box-top {
113
+    position: relative;
114
+    margin-top: 10px;
115
+    width: calc(100% - 20px);
116
+
117
+    .banner-swipe {
118
+      border-radius: 6px;
119
+      box-shadow: 0 0 6px 6px rgba(0, 0, 0, 0.12);
120
+    }
121
+  }
122
+
123
+  .course-list {
124
+    margin-top: 2em;
125
+  }
126
+
127
+  .custom-indicator {
128
+    position: absolute;
129
+    width: 100%;
130
+    text-align: center;
131
+    left: 0;
132
+    right: 0;
133
+    bottom: -1em;
134
+    z-index: 10;
135
+
136
+    & > span {
137
+      display: inline-block;
138
+      width: 1em;
139
+      height: 2px;
140
+      background: rgba(0, 0, 0, 0.2);
141
+
142
+      & + span {
143
+        margin-left: .2em;
144
+      }
145
+    }
146
+    .active {
147
+      background: rgba(0, 0, 0, .65);
148
+    }
149
+  }
150
+
151
+}
152
+</style>

+ 109
- 0
src/views/components/CourseCard.vue 파일 보기

@@ -0,0 +1,109 @@
1
+<template>
2
+  <div class="course-card">
3
+    <div class="media-box">
4
+      <div class="media-head">
5
+        <img :src="thumb" alt="">
6
+      </div>
7
+      <div class="media-body">
8
+        <div class="title">{{title}}</div>
9
+        <div class="subtitle">{{dateStr}}</div>
10
+      </div>
11
+    </div>
12
+    <div class="card-footer">
13
+      <div class="footer-body">
14
+        查看详情
15
+      </div>
16
+      <div class="footer-action">
17
+        <van-icon name="arrow" />
18
+      </div>
19
+    </div>
20
+  </div>
21
+</template>
22
+
23
+<script>
24
+import { parseTime } from "@/util/formattingData";
25
+
26
+export default {
27
+  name: 'CourseCard',
28
+  props: {
29
+    title: String,
30
+    startDate: [String, Date],
31
+    endDate: [String, Date],
32
+    thumb: String
33
+  },
34
+  computed: {
35
+    dateStr() {
36
+      if (!this.startDate || !this.endDate) return '课程时间: 暂无';
37
+
38
+      const start = parseTime(this.startDate, '{y}-{m}-{d} {h}:{i}')
39
+      const end = parseTime(this.endDate, '{y}-{m}-{d} {h}:{i}')
40
+
41
+      return `课程时间: ${start} ~ ${end}`
42
+    }
43
+  }
44
+}
45
+</script>
46
+
47
+<style lang="less" scoped>
48
+.course-card {
49
+  font-size: 14px;
50
+  width: 100%;
51
+  box-sizing: border-box;
52
+  border-radius: 6px;
53
+  box-shadow: 0px 0px 4px 4px rgba(0, 0, 0, 0.06);
54
+
55
+  & + & {
56
+    margin-top: 1.5em;
57
+  }
58
+
59
+  .media-box, .card-footer {
60
+    display: flex;
61
+    justify-content: space-between;
62
+  }
63
+
64
+  .media-box {
65
+    padding: 1em;
66
+    .media-head {
67
+      flex: none;
68
+      width: 20vw;
69
+
70
+      & > img {
71
+        width: 100%;
72
+        min-height: 20vw;
73
+        border-radius: 50%;
74
+        box-shadow: 0 0 2px 2px rgba(0, 0, 0, 0.25);
75
+      }
76
+    }
77
+
78
+    .media-body {
79
+      margin-left: 1em;
80
+      flex: 1;
81
+
82
+      .title {
83
+        font-size: 1.2em;
84
+        color: #000;
85
+        min-height: 2.6em;
86
+        line-height: 1.3em;
87
+      }
88
+
89
+      .subtitle {
90
+        color: rgb(133, 133, 133);
91
+      }
92
+    }
93
+  }
94
+
95
+  .card-footer {
96
+    padding: 1em;
97
+    border-top: 1px solid rgb(238, 238, 238);
98
+
99
+    & > div {
100
+      color: rgb(133, 133, 133);
101
+    }
102
+
103
+    .footer-action {
104
+      flex: none;
105
+      width: 1em;
106
+    }
107
+  }
108
+}
109
+</style>