明梦爽
2021-11-18 1714ea49fbbeb8bcb9f9f896ffb873362e8cdca8
动态获取
4个文件已修改
2个文件已添加
451 ■■■■ 已修改文件
src/api/api.js 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/Home.vue 68 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/page/introduce.vue 130 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/page/zhengce.vue 97 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/request.js 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/notice.vue 109 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/api.js
New file
@@ -0,0 +1,28 @@
//用于写接口
//post请求参数放在data里面,get请求参数放在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,
  })
}
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
          }
        })
      }
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>
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)
        })
    }
  }
}
src/utils/request.js
New file
@@ -0,0 +1,19 @@
//对axios的封装
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
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>