张延森 vor 3 Jahren
Ursprung
Commit
fe461e5112
5 geänderte Dateien mit 82 neuen und 141 gelöschten Zeilen
  1. 0
    6
      src/App.vue
  2. 4
    49
      src/views/Course.vue
  3. 7
    12
      src/views/StrongPhoto.vue
  4. 0
    74
      src/views/Tabber.vue
  5. 71
    0
      src/views/components/BannerSwipe.vue

+ 0
- 6
src/App.vue Datei anzeigen

@@ -5,16 +5,10 @@
5 5
 </template>
6 6
 
7 7
 <script>
8
-import { UserLogin } from './util/api'
9 8
 import { mapState } from 'vuex'
10 9
 
11
-import Tabber from './views/Tabber.vue'
12
-
13 10
 export default {
14 11
   name: 'App',
15
-  components: {
16
-    Tabber
17
-  },
18 12
   computed: {
19 13
     ...mapState(['LOADING'])
20 14
   },

+ 4
- 49
src/views/Course.vue Datei anzeigen

@@ -1,16 +1,7 @@
1 1
 <template>
2 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>
3
+    <div class="banner-box-top" >
4
+      <banner-swipe :list="HomeBannerImages" />
14 5
     </div>
15 6
     
16 7
     <!-- list -->
@@ -31,13 +22,12 @@ import { getBanner, getCourse } from '@/util/api'
31 22
 
32 23
 export default {
33 24
   components: {
34
-    RationDiv: () => import('@/components/RatioDiv/index.vue'),
25
+    BannerSwipe: () => import('./components/BannerSwipe.vue'),
35 26
     CourseCard: () => import('./components/CourseCard.vue')
36 27
   },
37 28
 
38 29
   data() {
39 30
     return {
40
-      currentItem: -1,
41 31
       icon: require('@/assets/icon/courseIcon.svg'),
42 32
       loading: false,
43 33
       finished: true,
@@ -69,37 +59,12 @@ export default {
69 59
     },
70 60
     onBanner() {
71 61
       getBanner('Training').then((e) => {
72
-        this.HomeBannerImages = e.records
62
+        this.HomeBannerImages = (e.records || []).map(x => x.thumb)
73 63
 
74 64
         console.log(e)
75 65
       })
76 66
     },
77 67
     onLoad() {
78
-      // 异步更新数据
79
-      let params = {
80
-        // type: this.selectedType,
81
-        index: this.currentPage, //页数
82
-        size: this.pageSize //每页个数
83
-      }
84
-      // xxxxxxx(params).then((res) => {
85
-      //   console.log(res)
86
-      //   this.dataTotal = res.total
87
-      //   //进行判断
88
-      //   if (this.dataTotal <= this.pageSize) {
89
-      //     this.Array = res.data.list
90
-      //     console.log(this.Array)
91
-      //   } else {
92
-      //     this.currentPage++
93
-      //     let arr = res.data.data.list
94
-      //     this.Array = this.Array.concat(arr)
95
-      //   }
96
-      //   // 加载状态结束
97
-      //   this.loading = false
98
-      //   // 数据全部加载完成
99
-      //   if (this.Array.length >= this.dataTotal) {
100
-      //     this.finished = true //结束,显示我也是有底线的
101
-      //   }
102
-      // })
103 68
     }
104 69
   }
105 70
 }
@@ -116,16 +81,6 @@ export default {
116 81
   width: 100vw;
117 82
   padding-top: 10px;
118 83
 
119
-  .banner-box-top {
120
-    position: relative;
121
-    width: calc(100% - 20px);
122
-
123
-    .banner-swipe {
124
-      border-radius: 6px;
125
-      box-shadow: 0 0 6px 6px rgba(0, 0, 0, 0.12);
126
-    }
127
-  }
128
-
129 84
   .course-list {
130 85
     margin-top: 10vw;
131 86
   }

+ 7
- 12
src/views/StrongPhoto.vue Datei anzeigen

@@ -1,10 +1,6 @@
1 1
 <template>
2 2
   <div class="Photo-box">
3
-    <van-swipe :autoplay="3000">
4
-      <van-swipe-item v-for="(image, index) in photoBannerImages" :key="index">
5
-        <van-image width="100%" height="57vw" :src="image.thumb" />
6
-      </van-swipe-item>
7
-    </van-swipe>
3
+    <banner-swipe :list="photoBannerImages" />
8 4
     <div style="display: flex; aline-itme:center;margin-top: 30px;position:relative ">
9 5
       <!-- <div :class="`${classStyle?'Zhedie-box Donghua':'Zhedie-box'}`"> -->
10 6
       <div :class="{'Zhedie-box': true, 'expand': classStyle}">
@@ -45,6 +41,9 @@ import { parseTime } from '@/util/formattingData'
45 41
 import { getBanner } from '@/util/api'
46 42
 
47 43
 export default {
44
+  components: {
45
+    BannerSwipe: () => import('./components/BannerSwipe.vue'),
46
+  },
48 47
   data() {
49 48
     return {
50 49
       classStyle: false,
@@ -137,7 +136,7 @@ export default {
137 136
     },
138 137
     onBanner() {
139 138
       getBanner('Wonderful').then((e) => {
140
-        this.photoBannerImages = e.records
139
+        this.photoBannerImages = (e.records || []).map(x => x.thumb)
141 140
         // console.log(e)
142 141
       })
143 142
     }
@@ -150,12 +149,8 @@ export default {
150 149
   width: 100vw;
151 150
   height: 100%;
152 151
   background-color: #fff;
153
-  .van-swipe {
154
-    width: 95%;
155
-    border-radius: 10px;
156
-    margin: 10px auto;
157
-    box-shadow: 0px 8px 38px 0px rgba(0, 0, 0, 0.2);
158
-  }
152
+  padding-top: 10px;
153
+
159 154
   .Zhedie-box {
160 155
     padding: 0 4vw;
161 156
     overflow: hidden;

+ 0
- 74
src/views/Tabber.vue Datei anzeigen

@@ -1,74 +0,0 @@
1
-<template>
2
-  <div class="tabbar">
3
-    <van-tabbar class="van-tabbar" v-model="active" @change="onChange">
4
-      <van-tabbar-item icon="column">培训通知</van-tabbar-item>
5
-      <van-tabbar-item icon="photo">精彩集锦</van-tabbar-item>
6
-      <van-tabbar-item icon="manager">个人中心</van-tabbar-item>
7
-    </van-tabbar>
8
-  </div>
9
-</template>
10
-
11
-<script>
12
-export default {
13
-  name: 'Tabber',
14
-  props: {
15
-    // active: Number
16
-  },
17
-  data() {
18
-    return {
19
-      // tabbarTempValue: this.active,
20
-      active: 0
21
-    }
22
-  },
23
-  created() {
24
-    //由于 vant 标签栏路由模式,无法自动加载页面,所以这里需要初始化
25
-    // console.log(this.$route) //打印当前路由属性
26
-    this.active = 0
27
-
28
-    switch (this.$route.name) {
29
-      case 'Course':
30
-        this.active = 0
31
-        break
32
-      case 'StrongPhoto':
33
-        this.active = 1
34
-        break
35
-      case 'UserCenter':
36
-        this.active = 2
37
-        break
38
-      default:
39
-        break
40
-    }
41
-  },
42
-  methods: {
43
-    onChange(index) {
44
-      // console.log(index)
45
-      switch (index) {
46
-        case 0:
47
-          this.$router.push('/')
48
-
49
-          break
50
-        case 1:
51
-          this.$router.push('/StrongPhoto')
52
-
53
-          break
54
-        case 2:
55
-          this.$router.push('/UserCenter')
56
-
57
-          break
58
-        default:
59
-          break
60
-      }
61
-      // const routerArray = ['/Course', '/StrongPhoto', '/UserCenter']
62
-      // this.$router.push(routerArray[index])
63
-    }
64
-  }
65
-}
66
-</script>
67
-
68
-<style lang="less" scoped>
69
-.tabbar {
70
-  .van-tabbar {
71
-    // padding-bottom: 2em;
72
-  }
73
-}
74
-</style>

+ 71
- 0
src/views/components/BannerSwipe.vue Datei anzeigen

@@ -0,0 +1,71 @@
1
+<template>
2
+  <div class="banner-swipe-box" >
3
+    <van-swipe class="banner-swipe" :autoplay="3000" @change="i => current = i" :show-indicators="false">
4
+      <van-swipe-item v-for="image in list" :key="image">
5
+        <ration-div :ratio="0.6">
6
+          <van-image width="100%" height="100%" :src="image" />
7
+        </ration-div>
8
+      </van-swipe-item>
9
+    </van-swipe>
10
+    <div class="custom-indicator">
11
+      <span v-for="(image, index) in list" :key="image" :class="{'active': current === index }"></span>
12
+    </div>
13
+  </div>
14
+</template>
15
+
16
+<script>
17
+export default {
18
+  name: 'BannerSwipe',
19
+  components: {
20
+    RationDiv: () => import('@/components/RatioDiv/index.vue'),
21
+  },
22
+  props: {
23
+    list: {
24
+      type: Array,
25
+      default: () => ([])
26
+    }
27
+  },
28
+  data() {
29
+    return {
30
+      current: 0,
31
+    }
32
+  }
33
+}
34
+</script>
35
+
36
+<style lang="less" scoped>
37
+.banner-swipe-box {
38
+  position: relative;
39
+  margin-left: 10px;
40
+  margin-right: 10px;
41
+  width: calc(100% - 20px);
42
+
43
+  .banner-swipe {
44
+    border-radius: 6px;
45
+    box-shadow: 0 0 6px 6px rgba(0, 0, 0, 0.12);
46
+  }
47
+
48
+  .custom-indicator {
49
+    position: absolute;
50
+    width: 100%;
51
+    text-align: center;
52
+    left: 0;
53
+    right: 0;
54
+    z-index: 10;
55
+
56
+    & > span {
57
+      display: inline-block;
58
+      width: 1em;
59
+      height: 2px;
60
+      background: rgba(0, 0, 0, 0.2);
61
+
62
+      & + span {
63
+        margin-left: .2em;
64
+      }
65
+    }
66
+    .active {
67
+      background: rgba(0, 0, 0, .65);
68
+    }
69
+  }
70
+}
71
+</style>