浏览代码

Merge branch 'master' of http://git.ycjcjy.com/state_grid/training-wx

李志伟 3 年前
父节点
当前提交
00a3165724

+ 0
- 14
src/App.vue 查看文件

@@ -1,7 +1,6 @@
1 1
 <template>
2 2
   <div id="app">
3 3
     <router-view />
4
-    <Tabber />
5 4
   </div>
6 5
 </template>
7 6
 
@@ -19,19 +18,6 @@ export default {
19 18
   computed: {
20 19
     ...mapState(['LOADING'])
21 20
   },
22
-  mounted() {
23
-    // this.onLogin()
24
-  },
25
-  methods: {
26
-    // onLogin() {
27
-    //   UserLogin('123').then((e) => {
28
-    //     console.log(e)
29
-    //     console.log(22222222222222222222222)
30
-    //     let tokens = e.token
31
-    //     this.$store.commit('SET_USER_INFO', { token: tokens })
32
-    //   })
33
-    // }
34
-  }
35 21
 }
36 22
 </script>
37 23
 

+ 0
- 147
src/components/ClassInfo.vue 查看文件

@@ -1,147 +0,0 @@
1
-<template>
2
-  <div class="class-box">
3
-    <img width="100%" height="200vh" :src="ClassContent.thumb" alt />
4
-    <div class="class-box-body">
5
-      <div class="class-box-body-top">
6
-        <div class="class-box-body-top-title">{{ClassContent.title}}</div>
7
-        <div class="class-box-body-top-Info">
8
-          <div
9
-            class="class-box-body-top-Info-Time"
10
-          >课程时间:{{parseTime(ClassContent.startDate,'{m}月{d}日 {h}:{i}')}}~{{parseTime(ClassContent.endDate,'{m}月{d}日 {h}:{i}')}}</div>
11
-          <div
12
-            class="class-box-body-top-Info-Shoucang"
13
-            @click="ClassContent.isFavored==null? collectionHande():deleteColl()"
14
-          >
15
-            <img :src="ClassContent.isFavored?on:off" alt />
16
-            <span>{{ClassContent.isFavored?'已收藏':'收藏'}}</span>
17
-          </div>
18
-        </div>
19
-      </div>
20
-      <div class="class-box-body-box">
21
-        <div>{{ClassContent.subTitle}}</div>
22
-        <img :src="ClassContent.content" alt />
23
-      </div>
24
-    </div>
25
-  </div>
26
-</template>
27
-
28
-<script>
29
-import { getCourseInfof, addCollection, deleteCollection } from '../util/api'
30
-import { parseTime, SignInTime } from '../util/formattingData'
31
-
32
-export default {
33
-  data() {
34
-    return {
35
-      ClassContent: {},
36
-      isShoucang: false,
37
-      courseIds: '',
38
-
39
-      on: require('../assets/Collection/on.png'),
40
-      off: require('../assets/Collection/off.png')
41
-    }
42
-  },
43
-  mounted() {
44
-    this.onloadClass()
45
-    this.courseIds = this.$route.query.courseId
46
-  },
47
-  methods: {
48
-    parseTime,
49
-    onloadClass() {
50
-      getCourseInfof(this.$route.query.courseId).then((e) => {
51
-        this.ClassContent = e
52
-        if (e.isFavored) {
53
-          this.isShoucang = true
54
-        }
55
-
56
-        console.log(e)
57
-      })
58
-    },
59
-    collectionHande() {
60
-      addCollection({
61
-        targetId: this.$route.query.courseId,
62
-        targetName: this.ClassContent.title,
63
-        targetType: 'course'
64
-      }).then((e) => {
65
-        console.log(e)
66
-        this.$toast('收藏成功')
67
-        this.onloadClass()
68
-      })
69
-    },
70
-    deleteColl() {
71
-      deleteCollection({
72
-        targetId: this.$route.query.courseId,
73
-        targetName: this.ClassContent.title,
74
-        targetType: 'course'
75
-      }).then((e) => {
76
-        console.log(e)
77
-        this.$toast('取消收藏成功')
78
-        this.onloadClass()
79
-      })
80
-    }
81
-  }
82
-}
83
-</script>
84
-
85
-<style lang="less" scoped>
86
-.class-box {
87
-  width: 100vw;
88
-  height: 100%;
89
-  &-body {
90
-    width: 100%;
91
-    border-radius: 30px;
92
-    background-color: #fff;
93
-    position: absolute;
94
-    top: 54vw;
95
-    height: calc(100% - 54vh);
96
-    &-top {
97
-      width: 100%;
98
-      height: 10vh;
99
-
100
-      &-title {
101
-        padding: 10px 20px 8px 20px;
102
-        width: 70%;
103
-        font-size: 14px;
104
-        font-weight: 700;
105
-      }
106
-      &-Info {
107
-        padding: 0px 20px;
108
-
109
-        display: flex;
110
-        align-items: center;
111
-        justify-content: space-between;
112
-
113
-        &-Time {
114
-          font-size: 9px;
115
-          color: #999;
116
-        }
117
-        &-Shoucang {
118
-          display: flex;
119
-          align-items: center;
120
-
121
-          > img {
122
-            width: 18px;
123
-            padding-right: 5px;
124
-          }
125
-          & > span {
126
-            color: #999;
127
-            font-size: 10px;
128
-          }
129
-        }
130
-      }
131
-    }
132
-    &-box {
133
-      margin: 0 auto;
134
-      box-shadow: 0 0 15px rgb(214, 214, 214);
135
-      min-height: 67vh;
136
-      border-radius: 30px;
137
-      background-color: #fff;
138
-      position: absolute;
139
-      top: 13vh;
140
-      padding: 1.5em;
141
-      > img {
142
-        width: 100%;
143
-      }
144
-    }
145
-  }
146
-}
147
-</style>

+ 13
- 0
src/global_style.less 查看文件

@@ -0,0 +1,13 @@
1
+
2
+.flex {
3
+  display: flex;
4
+}
5
+
6
+.flex-1 {
7
+  flex: 1;
8
+}
9
+
10
+.flex-0 {
11
+  flex: none;
12
+}
13
+

+ 2
- 2
src/layout/index.vue 查看文件

@@ -4,12 +4,12 @@
4 4
     <router-view />
5 5
 
6 6
     <!-- 底部导航栏 -->
7
-    <van-tabbar v-model="active">
7
+    <van-tabbar v-model="active" active-color="#000" inactive-color="#D9DEE4" >
8 8
       <van-tabbar-item
9 9
         v-for="item in tabbar"
10
-        @click="goto(item.path)"
11 10
         :key="item.path"
12 11
         :icon="item.icon"
12
+        :to="item.path"
13 13
       >{{ item.text }}</van-tabbar-item>
14 14
     </van-tabbar>
15 15
   </div>

+ 14
- 14
src/main.js 查看文件

@@ -1,12 +1,5 @@
1 1
 import Vue from 'vue'
2
-import App from './App.vue'
3
-import animated from 'animate.css'
4
-import { Login, redirect } from './util/initial'
5
-
6
-import Questionnaire from './components/Questionnaire'
7
-import Loading from './components/Questionnaire/Loading.vue';
8
-import router from './router/index'//路由
9
-import store from './store';//状态管理
2
+import 'animate.css'
10 3
 import {
11 4
   Cell, CellGroup,
12 5
   Icon,
@@ -21,6 +14,16 @@ import {
21 14
   NavBar,
22 15
   Image, SwipeItem, Tag, Swipe, Divider, Picker, Popup, List,ImagePreview 
23 16
 } from 'vant';
17
+import App from './App.vue'
18
+import { Login, redirect } from './util/initial'
19
+
20
+// import Questionnaire from './views/components/Questionnaire'
21
+// import Loading from './views/components/Questionnaire/Loading.vue';
22
+import router from './router/index'//路由
23
+import store from './store';//状态管理
24
+
25
+import './global_style.less'
26
+
24 27
 Vue.config.productionTip = false
25 28
 
26 29
 Vue.use(Popup);
@@ -44,9 +47,9 @@ Vue.use(Notify);
44 47
 Vue.use(Tabbar).use(TabbarItem);
45 48
 Vue.use(Button);
46 49
 Vue.use(Icon);
47
-Vue.component('v-loading', Loading);
48
-Vue.use(Questionnaire)
49
-Vue.use(animated)
50
+// Vue.component('v-loading', Loading);
51
+// Vue.use(Questionnaire)
52
+// Vue.use(animated)
50 53
 
51 54
 // Vue.use(Tabbar);
52 55
 // Vue.use(TabbarItem);
@@ -62,6 +65,3 @@ Login().then(e => {
62 65
   }).$mount('#app')
63 66
 
64 67
 })
65
-
66
-
67
-

+ 28
- 70
src/router/index.js 查看文件

@@ -3,56 +3,47 @@
3 3
 import Vue from 'vue'
4 4
 import Router from 'vue-router'
5 5
 
6
-import store from '../store'
7
-
8 6
 import Course from '@/views/Course.vue'//课程
9
-import MyCollection from '@/components/MyCollection.vue'//收藏
10
-import signIn from '@/components/signIn.vue'//打卡
11
-import ClassInfo from '@/components/ClassInfo.vue'//课堂详情
7
+import MyCollection from '@/views/MyCollection.vue'//收藏
8
+import signIn from '@/views/signIn.vue'//打卡
9
+import ClassInfo from '@/views/ClassInfo.vue'//课堂详情
12 10
 import StrongPhoto from '@/views/StrongPhoto.vue'//精彩集锦
13 11
 import UserCenter from '@/views/UserCenter.vue'//我的页面
14
-import Questionnaire from '@/components/Questionnaire.vue'
15
-import SetUser from '@/components/userPages/SetUser.vue'//修改个人信息
12
+import Questionnaire from '@/views/Questionnaire.vue'
13
+import SetUser from '@/views/userPages/SetUser.vue'//修改个人信息
16 14
 // // import Login from '../Login.vue'
17 15
 
18 16
 
19 17
 Vue.use(Router)
20 18
 
21
-
22
-
23 19
 const router = new Router({
24 20
   routes: [
25 21
 
26
-
27
-    //培训通知
28 22
     {
29 23
       path: '/',
30
-      name: 'Course',
31
-      component: Course,
32
-      meta: {
33
-        requireAuth: true //是否登陆
34
-      }
35
-
36
-
37
-    },
38
-    //精彩集锦
39
-    {
40
-      path: '/StrongPhoto',
41
-      name: 'StrongPhoto',
42
-      component: StrongPhoto,
43
-      meta: {
44
-        requireAuth: true //是否登陆
45
-      }
46
-
47
-    },
48
-    //个人中心
49
-    {
50
-      path: '/UserCenter',
51
-      name: 'UserCenter',
52
-      component: UserCenter,
53
-      meta: {
54
-        requireAuth: false //是否登陆
55
-      }
24
+      name: 'index',
25
+      redirect: '/Course',
26
+      component: () => import('@/layout/index.vue'),
27
+      children: [
28
+        //培训通知
29
+        {
30
+          path: 'Course',
31
+          name: 'Course',
32
+          component: Course,
33
+        },
34
+        //精彩集锦
35
+        {
36
+          path: 'StrongPhoto',
37
+          name: 'StrongPhoto',
38
+          component: StrongPhoto,
39
+        },
40
+        //个人中心
41
+        {
42
+          path: 'UserCenter',
43
+          name: 'UserCenter',
44
+          component: UserCenter,
45
+        },
46
+      ]
56 47
     },
57 48
 
58 49
     // 修改个人信息
@@ -60,66 +51,33 @@ const router = new Router({
60 51
       path: '/SetUser',
61 52
       name: 'SetUser',
62 53
       component: SetUser,
63
-      meta: {
64
-        requireAuth: true //是否登陆
65
-      }
66 54
     },
67 55
     //问卷页面
68 56
     {
69 57
       path: '/Questionnaire',
70 58
       name: 'Questionnaire',
71 59
       component: Questionnaire,
72
-      meta: {
73
-        requireAuth: true //是否登陆
74
-      }
75 60
     },
76 61
     //打卡页面
77 62
     {
78 63
       path: '/signIn',
79 64
       name: 'signIn',
80 65
       component: signIn,
81
-      meta: {
82
-        requireAuth: true //是否登陆
83
-      }
84 66
     },
85 67
     //课程详情页面
86 68
     {
87 69
       path: '/ClassInfo',
88 70
       name: 'ClassInfo',
89 71
       component: ClassInfo,
90
-      meta: {
91
-        requireAuth: true,//是否登陆
92
-        showBottomTabBar: true
93
-      }
94 72
     },
95 73
     //收藏
96 74
     {
97 75
       path: '/MyCollection',
98 76
       name: 'MyCollection',
99 77
       component: MyCollection,
100
-
101 78
     },
102
-
103
-
104 79
   ]
105 80
 
106 81
 })
107
-router.beforeEach((to, from, next) => {
108
-  const { personId } = store.state.user
109
-
110
-
111
-  console.log('-----person.personId---->', personId)
112
-
113
-  // 未登录
114
-  if (!personId) {
115
-    console.log(2222222);
116
-  } else {
117
-    console.log('登陆了');
118
-  }
119
-
120
-  next()
121
-})
122
-
123
-
124 82
 
125 83
 export default router;

+ 177
- 0
src/views/ClassInfo.vue 查看文件

@@ -0,0 +1,177 @@
1
+<template>
2
+  <div class="class-box">
3
+    <ratio-div class="thumb-banner" :ratio="0.6">
4
+      <img width="100%" :src="ClassContent.thumb" alt />
5
+    </ratio-div>
6
+
7
+    <div class="summary">
8
+      <div class="title">
9
+        {{ClassContent.title}}
10
+      </div>
11
+      <div class="flex" style="margin-top: 16px">
12
+        <div class="flex-1 subtitle">
13
+          {{dateStr}}
14
+        </div>
15
+        <div class="flex-0" @click="handleFavor()">
16
+          <span>
17
+            <van-icon size="1.4em" :name="favor.icon" :color="favor.color" />
18
+          </span>
19
+          <span class="star-favor">{{favor.text}}</span>
20
+        </div>
21
+      </div>
22
+    </div>
23
+
24
+    <div class="content-bar"></div>
25
+    
26
+    <div class="class-box-body">
27
+      <img :src="ClassContent.content" alt />
28
+    </div>
29
+  </div>
30
+</template>
31
+
32
+<script>
33
+import { getCourseInfof, addCollection, deleteCollection } from '@/util/api'
34
+import { parseTime, SignInTime } from '@/util/formattingData'
35
+
36
+export default {
37
+  components: {
38
+    RatioDiv: () => import('@/components/RatioDiv/index.vue')
39
+  },
40
+  data() {
41
+    return {
42
+      ClassContent: {},
43
+      isShoucang: false,
44
+      courseIds: '',
45
+
46
+      on: require('@/assets/Collection/on.png'),
47
+      off: require('@/assets/Collection/off.png')
48
+    }
49
+  },
50
+  computed: {
51
+    dateStr() {
52
+      if (!this.startDate || !this.endDate) return '课程时间: 暂无';
53
+
54
+      const start = parseTime(this.startDate, '{y}-{m}-{d} {h}:{i}')
55
+      const end = parseTime(this.endDate, '{y}-{m}-{d} {h}:{i}')
56
+
57
+      return `课程时间: ${start} ~ ${end}`
58
+    },
59
+    favor() {
60
+      const isFavored = this.ClassContent.isFavored || false
61
+
62
+      return {
63
+        icon: isFavored ? 'star' : 'star-o',
64
+        color: isFavored ? '#2BB898' : '#000',
65
+        text: isFavored?'已收藏':'收藏',
66
+      }
67
+    }
68
+  },
69
+  watch: {
70
+    '$route.query.courseId': {
71
+      handler(id) {
72
+        this.onloadClass(id)
73
+      },
74
+      immediate: true
75
+    }
76
+  },
77
+  methods: {
78
+    onloadClass(id) {
79
+      const courseId = id || this.$route.query.courseId;
80
+
81
+      getCourseInfof(courseId).then((e) => {
82
+        this.ClassContent = e
83
+        if (e.isFavored) {
84
+          this.isShoucang = true
85
+        }
86
+
87
+        console.log(e)
88
+      })
89
+    },
90
+    handleFavor() {
91
+      if (this.ClassContent.isFavored) {
92
+        this.deleteColl()
93
+      } else {
94
+        this.collectionHande()
95
+      }
96
+    },
97
+    collectionHande() {
98
+      addCollection({
99
+        targetId: this.$route.query.courseId,
100
+        targetName: this.ClassContent.title,
101
+        targetType: 'course'
102
+      }).then((e) => {
103
+        console.log(e)
104
+        this.ClassContent.isFavored = true
105
+        this.$toast('收藏成功')
106
+        // this.onloadClass()
107
+      })
108
+    },
109
+    deleteColl() {
110
+      deleteCollection({
111
+        targetId: this.$route.query.courseId,
112
+        targetName: this.ClassContent.title,
113
+        targetType: 'course'
114
+      }).then((e) => {
115
+        console.log(e)
116
+        this.ClassContent.isFavored = false
117
+        this.$toast('取消收藏成功')
118
+      })
119
+    }
120
+  }
121
+}
122
+</script>
123
+
124
+<style lang="less" scoped>
125
+.class-box {
126
+  font-size: 14px;
127
+  height: 100%;
128
+  background: #fff;
129
+
130
+  .summary {
131
+    margin-top: -30px;
132
+    font-size: 12px;
133
+    color: #000;
134
+    padding: 24px 2em 3em;
135
+    background-color: #f9f9f9;
136
+    box-sizing: border-box;
137
+    border-top-left-radius: 30px;
138
+    border-top-right-radius: 30px;
139
+    position: relative;
140
+
141
+    .title {
142
+      font-size: 1.3em;
143
+      // min-height: 2.6em;
144
+      line-height: 1.4em;
145
+    }
146
+    .subtitle {
147
+      color: rgb(133, 133, 133);
148
+    }
149
+
150
+    .star-favor {
151
+      display: inline-block;
152
+      margin-left: .6em;
153
+      vertical-align: top;
154
+    }
155
+  }
156
+
157
+  .content-bar {
158
+    position: relative;
159
+    margin-top: -1.5em;
160
+    box-shadow: 0 0 4px 4px rgba(0, 0, 0, .08);
161
+    border-top-left-radius: 30px;
162
+    border-top-right-radius: 30px;
163
+    height: 30px;
164
+    background: #fff;
165
+  }
166
+
167
+  &-body {
168
+    position: relative;
169
+    background: #fff;
170
+    padding: 0 2em 1em;
171
+
172
+    > img {
173
+      width: 100%;
174
+    }
175
+  }
176
+}
177
+</style>

+ 6
- 1
src/views/Course.vue 查看文件

@@ -15,7 +15,12 @@
15 15
     
16 16
     <!-- list -->
17 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>
18
+      <course-card
19
+        v-for="item in courseList"
20
+        :key="item.courseId"
21
+        v-bind="item"
22
+        @click.native="$router.push({ name: 'ClassInfo', query: { courseId: item.courseId } })"
23
+      ></course-card>
19 24
     </van-list>
20 25
   </div>
21 26
 </template>

src/components/MyCollection.vue → src/views/MyCollection.vue 查看文件


src/components/Questionnaire.vue → src/views/Questionnaire.vue 查看文件

@@ -61,15 +61,15 @@
61 61
 </template>
62 62
 
63 63
 <script>
64
-import { getQuestion, getQuestionInfo, getQuestionAnswer } from '../util/api'
65
-import query from '../util/query'
64
+import { getQuestion, getQuestionInfo, getQuestionAnswer } from '@/util/api'
65
+// import query from '@/util/query'
66 66
 
67 67
 export default {
68 68
   name: 'QuestionDetail',
69 69
   components: {
70
-    Question: () => import('./Question'),
71
-    Popup: () => import('./Questionnaire/Popup.vue'),
72
-    QuestionnHome: () => import('./QuestionnHome.vue')
70
+    Question: () => import('./components/Question'),
71
+    Popup: () => import('./components/Questionnaire/Popup.vue'),
72
+    QuestionnHome: () => import('./components/QuestionnHome.vue')
73 73
   },
74 74
   props: {},
75 75
   data() {

src/components/Question/Answer.vue → src/views/components/Question/Answer.vue 查看文件


src/components/Question/TextAreas.vue → src/views/components/Question/TextAreas.vue 查看文件


src/components/Question/Title.vue → src/views/components/Question/Title.vue 查看文件


src/components/Question/index.vue → src/views/components/Question/index.vue 查看文件


src/components/QuestionnHome.vue → src/views/components/QuestionnHome.vue 查看文件

@@ -6,7 +6,7 @@
6 6
 </template>
7 7
 
8 8
 <script>
9
-import { getQuestionnaire } from '../util/api'
9
+import { getQuestionnaire } from '@/util/api'
10 10
 
11 11
 export default {
12 12
   name: 'QuestionnHome',

src/components/Questionnaire/Loading.vue → src/views/components/Questionnaire/Loading.vue 查看文件


src/components/Questionnaire/Many.vue → src/views/components/Questionnaire/Many.vue 查看文件


src/components/Questionnaire/Popup.vue → src/views/components/Questionnaire/Popup.vue 查看文件


src/components/Questionnaire/index.js → src/views/components/Questionnaire/index.js 查看文件


src/components/signIn.vue → src/views/signIn.vue 查看文件


src/components/userPages/SetUser.vue → src/views/userPages/SetUser.vue 查看文件