CareerLearn.vue
5.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
<template>
<!-- 推荐书籍 生涯故事 生涯案例 -->
<div class="career_learn">
<Top :active="active" :isCareerTop="isCareerTop" ></Top>
<!-- 主体内容 -->
<div class="career_wrap">
<!-- 面包屑 -->
<div class="major_title layout align_left">
<el-breadcrumb separator="|">
<el-breadcrumb-item>首页</el-breadcrumb-item>
<el-breadcrumb-item>生涯学习</el-breadcrumb-item>
<el-breadcrumb-item>{{isNav == 0?"推荐书籍":isNav == 1?"生涯案例":"生涯故事"}}</el-breadcrumb-item>
</el-breadcrumb>
</div>
<!-- 内容 -->
<div class="career_main clearfix">
<!-- 导航栏 -->
<div class="career_nav clearfix">
<div
class="nav_single"
:class="{nav_bottom:isNav == index}"
v-for="(item,index) in navList"
:key="index"
@click="changeNav(index)"
>{{item}}</div>
</div>
<!-- 推荐书籍 -->
<div class="career_book clearfix" v-if="isNav == 0">
<div class="clearfix">
<dl v-for="item in bookList" :key="item.id" @click="toDetail(item)">
<dt>
<img :src="item.image" alt />
</dt>
<dd>{{item.name}}</dd>
</dl>
</div>
<!-- 分页 -->
<el-pagination
v-show="totalPage>1"
background
layout="prev, pager, next"
:page-count="totalPage"
@current-change="handleCurrentChange"
></el-pagination>
</div>
<!-- 生涯案例 -->
<div class="career_book clearfix" v-if="isNav == 1">
<div class="clearfix">
<dl v-for="item in bookList" :key="item.id" @click="toDetail(item)">
<dt>
<img :src="item.image" alt />
</dt>
<dd>{{item.name}}</dd>
</dl>
</div>
<!-- 分页 -->
<el-pagination
v-show="totalPage>1"
background
layout="prev, pager, next"
:page-count="totalPage"
@current-change="handleCurrentChange"
></el-pagination>
</div>
<!-- 生涯故事 -->
<div class="career_book clearfix" v-if="isNav == 2">
<div class="clearfix">
<dl v-for="item in bookList" :key="item.id" @click="toDetail(item)">
<dt>
<img :src="item.image" alt />
</dt>
<dd>{{item.name}}</dd>
</dl>
</div>
<!-- 分页 -->
<el-pagination
v-show="totalPage>1"
background
layout="prev, pager, next"
:page-count="totalPage"
@current-change="handleCurrentChange"
></el-pagination>
</div>
</div>
</div>
<Bottom2></Bottom2>
</div>
</template>
<script>
import Top from "../../common/Top";
import Bottom2 from "../../common/Bottom2";
import { post } from "@/api/http";
export default {
data() {
return {
active: 4,
navList: ["推荐书籍", "生涯案例", "生涯故事"],
isNav: 0,
bookList: [],
// 推荐书籍分页
// 生涯案例分页
//生涯故事分页
totalPage: 0,
page: "",
type: 1,
isCareerTop:-1
};
},
methods: {
// 分页
handleCurrentChange(val) {
this.page = val;
this.getBooksList();
},
changeNav(index) {
this.isNav = index;
this.isCareerTop = index;
// console.log(this.isCareerTop,"当前页面")
// console.log(this.$store.state.isCareer,"vuex1")
this.type = index + 1;
this.getBooksList();
},
// 详情
toDetail(item) {
this.$router.push({
path: "/CareerDetail",
query: { id: item.id }
});
},
// 学习资源列表
getBooksList() {
let url = "/api/resource/getBooksList/";
let params = {
type: this.type,
page: this.page
};
post(url, params).then(res => {
this.bookList = res.res_list;
this.totalPage = res.total_page;
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
});
}
},
components: {
Top,
Bottom2
},
mounted() {
this.isNav = this.$route.query.isNav;
this.isCareerTop = this.$route.query.isNav;
this.type = this.isNav / 1 + 1;
this.getBooksList();
},
watch: {
$route(to, from) {
this.isNav = to.query.isNav;
this.changeNav(this.isNav);
// this.isCareerTop = this.isNav;
},
isCareerTop(newV,oldV){
this.$store.commit("changeStatus",newV)
// console.log(this.$store.state.isCareer,"监听vuex")
// console.log(newV,oldV,"监听")
}
}
};
</script>
<style scoped>
@import "../../../style/career.css";
.career_learn {
background-color: #f2f5fa;
width: 100%;
}
.career_wrap {
width: 1200px;
margin: 0 auto;
}
.career_main {
width: 1200px;
background-color: #fff;
}
</style>