From 1714ea49fbbeb8bcb9f9f896ffb873362e8cdca8 Mon Sep 17 00:00:00 2001
From: 明梦爽 <2972214568@qq.com>
Date: 星期四, 18 十一月 2021 10:47:59 +0800
Subject: [PATCH] 动态获取
---
src/utils/request.js | 19 ++
src/api/api.js | 28 +++
src/components/Home.vue | 68 ++++++--
src/components/page/introduce.vue | 130 ++++++++++++----
src/components/page/zhengce.vue | 97 ++++++++++-
src/views/notice.vue | 109 +++++++------
6 files changed, 338 insertions(+), 113 deletions(-)
diff --git a/src/api/api.js b/src/api/api.js
new file mode 100644
index 0000000..839ac98
--- /dev/null
+++ b/src/api/api.js
@@ -0,0 +1,28 @@
+//鐢ㄤ簬鍐欐帴鍙�
+//post璇锋眰鍙傛暟鏀惧湪data閲岄潰锛実et璇锋眰鍙傛暟鏀惧湪params閲岃竟
+
+import request from "../utils/request";
+//瀵艰埅鏍忓垪琛�
+export const getNavList = data => {
+ return request({
+ method: 'GET',
+ url: '/contype/findList',
+ params:data,
+ })
+}
+//鑾峰彇灏忔爣棰�
+export const getMinTitle = data => {
+ return request({
+ method: 'POST',
+ url: '/category/findCategoryIdByContypeId',
+ data,
+ })
+}
+//鑾峰彇鏂伴椈鍒楄〃
+export const getNewsList = data => {
+ return request({
+ method: 'POST',
+ url: '/newsTheme/findByTypeIdAndCategoryId',
+ data,
+ })
+}
\ No newline at end of file
diff --git a/src/components/Home.vue b/src/components/Home.vue
index 4038afd..df42532 100644
--- a/src/components/Home.vue
+++ b/src/components/Home.vue
@@ -23,9 +23,9 @@
<el-menu-item
:key="index"
v-for="(item, index) in menuList"
- :index="item.index"
+ :index="(item.id).toString()"
>
- {{ item.name }}
+ {{ item.contypeName }}
</el-menu-item>
</el-menu>
</el-row>
@@ -40,37 +40,65 @@
</template>
<script>
+import {getNavList} from '../api/api'
export default {
name: '',
data() {
return {
- activeIndex: 'index',
- menuList: [
- { index: 'index', name: '棣栭〉' },
- { index: 'introduce', name: '绉戝崗姒傚喌' },
- { index: 'zhengce', name: '鏀跨瓥娉曡' },
- { index: 'keXieXiangMu', name: '绉戝崗椤圭洰' },
- { index: 'xueShuJiaoLiu', name: '瀛︽湳浜ゆ祦' },
- { index: 'banShiZhiNan', name: '鍔炰簨鎸囧崡' },
- { index: 'kePu', name: '绉戞櫘椋庨噰' },
- { index: 'xueXiaoShouYe', name: '瀛︽牎棣栭〉' },
- { index: 'telephone', name: '鑱旂郴鎴戜滑' }
- ]
+ activeIndex: '1',
+ menuList: [],
}
},
- created() {},
+ created() {
+ this.getNavArr();
+ },
mounted() {},
watch: {},
methods: {
+ //鑾峰彇瀵艰埅鏍�
+ getNavArr(){
+ const data ={};
+ //.then() 涓昏鐢ㄤ簬涓�涓嚱鏁扮敤鍒板彟涓�涓嚱鏁扮殑杩斿洖鍊�
+ getNavList(data).then(res => {
+ console.log('res', res)
+ if(res.code == 200){
+ this.menuList = res.data
+ }
+ }).catch(err => {
+ console.log('err', err)
+ })
+ },
+ formatterTitle(t){
+ switch(t){
+ case '1':
+ return 'index'
+ case '2':
+ return 'introduce'
+ case '3':
+ return 'zhengce'
+ case '4':
+ return 'keXieXiangMu'
+ case '5':
+ return 'xueShuJiaoLiu'
+ case '6':
+ return 'banShiZhiNan'
+ case '7':
+ return 'kePu'
+ case '8':
+ return 'xueXiaoShouYe'
+ case '9':
+ return 'telephone'
+ }
+ },
handleSelect(key, keyPath) {
- console.log(key, keyPath)
- if (key == 'xueXiaoShouYe') {
- window.location.href = 'https://www.pdsu.edu.cn/#'
+ if (key == '8') {
+ window.open('https://www.pdsu.edu.cn/#')
} else {
this.$router.push({
- path: '/home/' + key,
+ path: '/home/' + this.formatterTitle(key),
query: {
- title: key
+ title: this.formatterTitle(key),
+ id:key
}
})
}
diff --git a/src/components/page/introduce.vue b/src/components/page/introduce.vue
index e00f011..45694b9 100644
--- a/src/components/page/introduce.vue
+++ b/src/components/page/introduce.vue
@@ -4,27 +4,52 @@
<globalTitle />
</el-row>
<el-row class="mart10">
- <el-col :span="4" class="marr10">
- <ul>
- <li
- v-for="(item, index) in menuList"
- :key="index"
- class="liStylenone liPointer marb10"
- @click="changeMenu(item.name)"
- >
- <b :class="cont == item.name?'ft-blue':'ft-black'">{{ item.name }}</b>
- </li>
- </ul>
- </el-col>
- <el-col :span="18">
- <div v-html="cont"></div>
- </el-col>
+ <!-- 灏忔爣棰� -->
+ <el-col :span="4" class="marr10">
+ <ul>
+ <li
+ v-for="(item, index) in menuList"
+ :key="index"
+ class="liStylenone liPointer marb10"
+ @click="changeMenu(item)"
+ >
+ <b :class="cont == item.categoryName ? 'ft-blue' : 'ft-black'">{{
+ item.categoryName
+ }}</b>
+ </li>
+ </ul>
+ </el-col>
+ <el-card class="box-card">
+ <el-col :span="18">
+ <div>
+ <el-row
+ class="marb10"
+ :key="index"
+ v-for="(item, index) in newsList"
+ >
+ {{ item.title }}
+ </el-row>
+ </div>
+ <!-- 鍒嗛〉 -->
+ <div>
+ <el-pagination
+ @current-change="handleCurrentChange"
+ :current-page.sync="currentPage"
+ :page-size="20"
+ layout="total, pager, next"
+ :total="total"
+ >
+ </el-pagination>
+ </div>
+ </el-col>
+ </el-card>
</el-row>
</div>
</template>
<script>
import globalTitle from '../globalTitle.vue'
+import { getMinTitle, getNewsList } from '../../api/api'
export default {
name: 'introduce',
components: {
@@ -32,28 +57,69 @@
},
data() {
return {
- cont:'',
- menuList: [
- { name: '绠�浠�' },
- { name: '绔犵▼' },
- { name: '缁勭粐鏈烘瀯' },
- { name: '宸ヤ綔鑱岃矗' },
- { name: '涓撹亴浜哄憳' }
- ]
+ cont: '',
+ menuList: [],
+ newsList: [],
+ total: 0,
+ currentPage: 1
}
},
- mounted(){
- this.cont = this.menuList[0].name;
+ created() {
+ this.getMinTitleList()
},
- methods:{
- changeMenu(val){
- this.cont = val;
+ mounted() {},
+ watch: {
+ menuList(newval, oldval) {
+ this.getAllNewsList(this.menuList[0])
+ this.cont = this.menuList[0].categoryName
+ }
+ },
+ methods: {
+ handleCurrentChange(val) {
+ console.log(`褰撳墠椤�: ${val}`)
},
+ changeMenu(val) {
+ this.getAllNewsList(val)
+ this.cont = val.categoryName
+ },
+ getMinTitleList() {
+ const data = {
+ contypeId: this.$route.query.id,
+ p: 1
+ }
+ getMinTitle(data)
+ .then((res) => {
+ console.log('res', res)
+ if (res.code == 200) {
+ this.menuList = res.data.records
+ }
+ })
+ .catch((err) => {
+ console.log('err', err)
+ })
+ },
+ getAllNewsList(item) {
+ const data = {
+ categoryId: item.id,
+ contypeId: item.contypeId,
+ p: this.currentPage
+ }
+ getNewsList(data)
+ .then((res) => {
+ console.log('res', res)
+ if (res.code == 200) {
+ this.newsList = res.data.records
+ this.total = Number(res.data.total)
+ }
+ })
+ .catch((err) => {
+ console.log('err', err)
+ })
+ }
}
}
</script>
<style lang="less" scoped>
-
ul {
width: 200px;
li {
@@ -63,10 +129,10 @@
text-align: center;
}
}
-.ft-blue{
- color:rgb(9, 143, 252);
+.ft-blue {
+ color: rgb(9, 143, 252);
}
-.ft-black{
+.ft-black {
color: #000;
}
</style>
\ No newline at end of file
diff --git a/src/components/page/zhengce.vue b/src/components/page/zhengce.vue
index 5e906bd..02e7cb6 100644
--- a/src/components/page/zhengce.vue
+++ b/src/components/page/zhengce.vue
@@ -4,25 +4,52 @@
<globalTitle />
</el-row>
<el-row class="mart10">
+ <!-- 灏忔爣棰� -->
<el-col :span="4" class="marr10">
<ul>
<li
- :key="index"
v-for="(item, index) in menuList"
+ :key="index"
class="liStylenone liPointer marb10"
- @click="changeMenu(item.name)"
+ @click="changeMenu(item)"
>
- <b :class="cont == item.name?'ft-blue':'ft-black'"> {{ item.name }} </b>
+ <b :class="cont == item.categoryName ? 'ft-blue' : 'ft-black'">{{
+ item.categoryName
+ }}</b>
</li>
</ul>
</el-col>
- <el-col :span="18"><div v-html="cont"></div></el-col>
+ <el-card class="box-card">
+ <el-col :span="18">
+ <div>
+ <el-row
+ class="marb10"
+ :key="index"
+ v-for="(item, index) in newsList"
+ >
+ {{ item.title }}
+ </el-row>
+ </div>
+ <!-- 鍒嗛〉 -->
+ <div>
+ <el-pagination
+ @current-change="handleCurrentChange"
+ :current-page.sync="currentPage"
+ :page-size="20"
+ layout="total, pager, next"
+ :total="total"
+ >
+ </el-pagination>
+ </div>
+ </el-col>
+ </el-card>
</el-row>
</div>
</template>
<script>
import globalTitle from '../globalTitle.vue'
+import { getMinTitle, getNewsList } from '../../api/api'
export default {
name: 'zhengce',
components: {
@@ -30,20 +57,64 @@
},
data() {
return {
- cont:'',
- menuList: [
- { name: '涓浗绉戝崗鏀跨瓥娉曡' },
- { name: '鍦版柟绉戝崗鏀跨瓥娉曡' },
- { name: '绀惧洟绠$悊鏂囦欢' }
- ]
+ cont: '',
+ menuList: [],
+ newsList: [],
+ total: 0,
+ currentPage: 1
}
},
- mounted() {
- this.cont = this.menuList[0].name;
+ created() {
+ this.getMinTitleList()
+ },
+ mounted() {},
+ watch: {
+ menuList(newval, oldval) {
+ this.getAllNewsList(this.menuList[0])
+ this.cont = this.menuList[0].categoryName
+ }
},
methods: {
+ handleCurrentChange(val) {
+ console.log(`褰撳墠椤�: ${val}`)
+ },
changeMenu(val) {
- this.cont = val;
+ this.getAllNewsList(val)
+ this.cont = val.categoryName
+ },
+ getMinTitleList() {
+ const data = {
+ contypeId: this.$route.query.id,
+ p: 1
+ }
+ getMinTitle(data)
+ .then((res) => {
+ console.log('res', res)
+ if (res.code == 200) {
+ this.menuList = res.data.records
+ }
+ })
+ .catch((err) => {
+ console.log('err', err)
+ })
+ },
+ getAllNewsList(item) {
+ const data = {
+ categoryId: item.id,
+ contypeId: item.contypeId,
+ p: this.currentPage
+ }
+ getNewsList(data)
+ .then((res) => {
+ console.log('res', res)
+ if (res.code == 200) {
+ this.newsList = res.data.records
+ this.total = Number(res.data.total)
+ }
+ })
+ .catch((err) => {
+ console.log('err', err)
+ })
}
}
}
diff --git a/src/utils/request.js b/src/utils/request.js
new file mode 100644
index 0000000..254bdeb
--- /dev/null
+++ b/src/utils/request.js
@@ -0,0 +1,19 @@
+//瀵筧xios鐨勫皝瑁�
+import axios from 'axios'
+let is_baseURL = 'http://8.140.68.52:8181/'//娴嬭瘯鐜
+//鍒涘缓axios瀹炰緥
+const request = axios.create({
+ baseURL: is_baseURL
+})
+//response鏈嶅姟鍣ㄥ搷搴旀嫤鎴櫒
+request.interceptors.response.use(
+ response => {
+ const res = response.data
+ return res
+ },
+ error => {
+ console.log('err',error)
+ }
+)
+
+export default request
diff --git a/src/views/notice.vue b/src/views/notice.vue
index ae982b2..78dbb4a 100644
--- a/src/views/notice.vue
+++ b/src/views/notice.vue
@@ -8,16 +8,18 @@
</el-row>
<div>
<ul>
- <li
+ <li
class="lieBiao liPointer"
:key="index"
- v-for="(item ,index) in noticeList"
+ v-for="(item, index) in noticeList"
>
<div class="time">
- <span>{{ item.date }}</span>
- <span>{{ item.years }}</span>
+ <span>{{ item.categoryId }}</span>
+ <span>{{ item.contypeId }}</span>
</div>
- <div class="title" @click="toNoticeMsg(item.title)">{{ item.title }}</div>
+ <div class="title" @click="toNoticeMsg(item.title)">
+ {{ item.title }}
+ </div>
</li>
</ul>
</div>
@@ -25,33 +27,44 @@
</template>
<script>
export default {
- name:'notice',
- data(){
- return{
- noticeList:[
- {years:'2021',date:'11-2',title:'鎴戞槸鏍囬1'},
- {years:'2021',date:'11-2',title:'鎴戞槸鏍囬2'},
- {years:'2021',date:'11-2',title:'鎴戞槸鏍囬3'},
- {years:'2021',date:'11-2',title:'鎴戞槸鏍囬4'},
- {years:'2021',date:'11-2',title:'鎴戞槸鏍囬5'},
-
- ]
+ name: 'notice',
+ data() {
+ return {
+ noticeList:
+ // {years:'2021',date:'11-2',title:'鎴戞槸鏍囬1'},
+ // {years:'2021',date:'11-2',title:'鎴戞槸鏍囬2'},
+ // {years:'2021',date:'11-2',title:'鎴戞槸鏍囬3'},
+ // {years:'2021',date:'11-2',title:'鎴戞槸鏍囬4'},
+ // {years:'2021',date:'11-2',title:'鎴戞槸鏍囬5'},
+ {
+ categoryId: 1,
+ contypeId: 2,
+ coverPath: '13',
+ dataString: '123',
+ title:"12"
+ }
}
},
- methods:{
- toNoticeMsg(t){
+ created(){
+ // getnews() {
+ // const res = this.$http.post('newsTheme/insert',this.noticeList)
+ // console.log(res);
+ // }
+ },
+ methods: {
+ toNoticeMsg(t) {
this.$router.push({
- path:'/home/noticeMessage',
- query:{
- title:t
+ path: '/home/noticeMessage',
+ query: {
+ title: t
}
})
},
- goMore(val){
+ goMore(val) {
this.$router.push({
- path:'/home/moreMessage',
- query:{
- type:val,
+ path: '/home/moreMessage',
+ query: {
+ type: val
}
})
}
@@ -59,27 +72,27 @@
}
</script>
<style lang="less" scoped>
- .underline{
- border-bottom: 1px solid #0f99e9;
- }
- .lieBiao{
- width: 95%;
- height: 80px;
- background: rgb(202, 202, 202);
- display: flex;
- justify-content: space-between;
- overflow: hidden;
- margin-bottom: 10px;
- }
- .time{
- width: 100px;
- overflow: hidden;
- display: flex;
- flex-direction: column;
- }
- .title{
- width: 500px;
- height: 70px;
- overflow: hidden;
- }
+.underline {
+ border-bottom: 1px solid #0f99e9;
+}
+.lieBiao {
+ width: 95%;
+ height: 80px;
+ background: rgb(202, 202, 202);
+ display: flex;
+ justify-content: space-between;
+ overflow: hidden;
+ margin-bottom: 10px;
+}
+.time {
+ width: 100px;
+ overflow: hidden;
+ display: flex;
+ flex-direction: column;
+}
+.title {
+ width: 500px;
+ height: 70px;
+ overflow: hidden;
+}
</style>
\ No newline at end of file
--
Gitblit v1.8.0