guhongwei 4 years ago
parent
commit
cc54c27a98

+ 14 - 0
src/router/index.js

@@ -264,6 +264,20 @@ const routes = [
     meta: { title: '科技频道', isleftarrow: true },
     meta: { title: '科技频道', isleftarrow: true },
     component: () => import('../views/channel/detail.vue'),
     component: () => import('../views/channel/detail.vue'),
   },
   },
+  // 12-23新闻类信息
+
+  {
+    path: '/scienceNews/index',
+    name: 'scienceNews',
+    meta: { title: '科技新闻', isleftarrow: false },
+    component: () => import('../views/scienceNews/index.vue'),
+  },
+  {
+    path: '/scienceNews/detail',
+    name: 'detail',
+    meta: { title: '科技新闻', isleftarrow: true },
+    component: () => import('../views/scienceNews/detail.vue'),
+  },
 ];
 ];
 
 
 const router = new VueRouter({
 const router = new VueRouter({

+ 2 - 0
src/store/index.js

@@ -18,6 +18,7 @@ import channelVideo from './live/channelVideo';
 // 11-3新闻资讯
 // 11-3新闻资讯
 import journcolumn from './market/journcolumn';
 import journcolumn from './market/journcolumn';
 import journnews from './market/journnews';
 import journnews from './market/journnews';
+import scienceNews from './market/scienceNews';
 // 科技超市
 // 科技超市
 import product from './market/product';
 import product from './market/product';
 import exportuser from './market/exportuser';
 import exportuser from './market/exportuser';
@@ -81,5 +82,6 @@ export default new Vuex.Store({
     journnews,
     journnews,
     channel,
     channel,
     channelVideo,
     channelVideo,
+    scienceNews,
   },
   },
 });
 });

+ 39 - 0
src/store/market/scienceNews.js

@@ -0,0 +1,39 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  newsInfo: `/api/market/scienceNews`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit = undefined, ...info } = {}) {
+    const res = await this.$axios.$get(api.newsInfo, { skip, limit, ...info });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.newsInfo}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.newsInfo}/${payload}`);
+    return res;
+  },
+  async update({ commit }, { id, ...info } = {}) {
+    const res = await this.$axios.$post(`${api.newsInfo}/update/${id}`, { ...info });
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.newsInfo}/${payload}`);
+    return res;
+  },
+};
+
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 155 - 0
src/views/scienceNews/detail.vue

@@ -0,0 +1,155 @@
+<template>
+  <div id="detail">
+    <el-row>
+      <el-col :span="24" class="detail">
+        <el-col :span="24" class="top">
+          <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow" @onClickLeft="onClickLeft"> </NavBar>
+        </el-col>
+        <el-col :span="24" class="main">
+          <el-col :span="24" class="title">{{ info.title }}</el-col>
+          <el-col :span="24" class="other">
+            <p>
+              <span class="textOver">信息来源:{{ info.orgin || '暂无' }}</span>
+              <span class="textOver">发布时间:{{ info.publish_time || '暂无' }}</span>
+            </p>
+            <p class="textOver">文章作者:{{ info.publish || '暂无' }}</p>
+          </el-col>
+          <el-col :span="24" v-if="info.picture != null || undefined" class="img">
+            <van-image :src="info.picture">
+              <div slot="error" class="image-slot">
+                <i class="el-icon-picture-outline"></i>
+              </div>
+            </van-image>
+          </el-col>
+          <el-col :span="24" class="con" v-html="info.content"> </el-col>
+          <el-col :span="24" class="four" v-if="info.filepath">
+            <h4>附件:</h4>
+            <el-link :href="info.filepath" :underline="false">{{ info.filepathname || '附件下载' }}</el-link>
+          </el-col>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import { mapState, createNamespacedHelpers } from 'vuex';
+import NavBar from '@/layout/common/topInfo.vue';
+const { mapActions: scienceNews } = createNamespacedHelpers('scienceNews');
+export default {
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  name: 'detail',
+  props: {},
+  components: {
+    NavBar,
+  },
+  data: function() {
+    return {
+      // 头部标题
+      title: '',
+      // meta为true
+      isleftarrow: '',
+      // 返回
+      navShow: true,
+      //详情
+      info: {},
+    };
+  },
+  created() {
+    this.search();
+  },
+  methods: {
+    ...scienceNews(['fetch']),
+    //查询详情
+    async search() {
+      const res = await this.fetch(this.id);
+      if (this.$checkRes(res)) {
+        this.$set(this, `info`, res.data);
+      }
+    },
+    // 返回
+    onClickLeft() {
+      this.$router.push({ path: '/scienceNews/index' });
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+    id() {
+      return this.$route.query.id;
+    },
+  },
+  mounted() {
+    this.title = this.$route.meta.title;
+    this.isleftarrow = this.$route.meta.isleftarrow;
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.detail {
+  width: 100%;
+  min-height: 667px;
+  position: relative;
+  background-color: #f9fafc;
+}
+.top {
+  height: 46px;
+  overflow: hidden;
+}
+.main {
+  // min-height: 570px;
+  // margin: 0 0 50px 0;
+  padding: 10px;
+  .title {
+    text-align: center;
+    color: #044b79;
+    font-size: 18px;
+    font-weight: bolder;
+  }
+  .other {
+    font-size: 16px;
+    color: #666;
+    padding: 20px 0;
+    border-bottom: 1px dashed #ccc;
+    p:nth-child(1) {
+      span {
+        display: inline-block;
+        width: 50%;
+      }
+    }
+    p:nth-child(2) {
+      text-align: center;
+    }
+  }
+  .img {
+    text-align: center;
+    margin: 0 0 15px 0;
+    .el-image {
+      width: 60%;
+    }
+  }
+  .con {
+    margin-top: 20px;
+  }
+}
+/deep/table {
+  width: 100%;
+}
+/deep/.con p img {
+  width: 100%;
+  height: 300px;
+  margin: 5px 0px;
+  display: block;
+}
+/deep/.con div img {
+  width: 100%;
+  height: 260px;
+  display: block;
+}
+/deep/.con p {
+  font-size: 14px;
+  color: #444;
+}
+</style>

+ 120 - 0
src/views/scienceNews/index.vue

@@ -0,0 +1,120 @@
+<template>
+  <div id="index">
+    <el-row>
+      <el-col :span="24" class="style">
+        <el-col :span="24" class="top">
+          <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
+        </el-col>
+        <el-col :span="24" class="down">
+          <el-col :span="24" class="list" v-for="(item, index) in list" :key="index" @click.native="show(item)">
+            <el-col :span="18" class="title textOver">
+              {{ item.title }}
+            </el-col>
+            <el-col :span="6" class="date">
+              {{ item.publish_time }}
+            </el-col>
+            <el-col :span="24" class="other">
+              <p class="textOver">
+                作者:<span>{{ item.publish || '暂无' }}</span>
+              </p>
+              <p class="textOver">
+                信息来源:<span>{{ item.orgin }}</span>
+              </p>
+            </el-col>
+          </el-col>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import NavBar from '@/layout/common/topInfo.vue';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: scienceNews } = createNamespacedHelpers('scienceNews');
+export default {
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  name: 'index',
+  props: {},
+  components: {
+    NavBar,
+  },
+  data: function() {
+    return {
+      // 头部标题
+      title: '',
+      // meta为true
+      isleftarrow: '',
+      // 返回
+      navShow: true,
+      list: [],
+    };
+  },
+  async created() {
+    await this.search();
+  },
+  methods: {
+    ...scienceNews(['query', 'fetch', 'create', 'update', 'delete']),
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      let res = await this.query({ skip, ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+      }
+    },
+    show(data) {
+      this.$router.push({ path: '/scienceNews/detail', query: { id: data.id } });
+    },
+  },
+  mounted() {
+    this.title = this.$route.meta.title;
+    this.isleftarrow = this.$route.meta.isleftarrow;
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {},
+};
+</script>
+
+<style lang="less" scoped>
+.style {
+  width: 100%;
+  height: 100%;
+  position: relative;
+  background-color: #f9fafc;
+  .top {
+    height: 46px;
+    overflow: hidden;
+  }
+  .down {
+    padding: 10px;
+    .list {
+      background-color: #fff;
+      border-radius: 5px;
+      margin: 0 0 10px 0;
+      padding: 5px;
+      .title {
+        font-size: 18px;
+        font-weight: bold;
+      }
+      .date {
+        text-align: right;
+        font-size: 16px;
+        padding: 6px 0 0 0;
+      }
+      .other {
+        margin: 5px 0 0 0;
+        p {
+          font-size: 16px;
+          padding: 5px 0;
+          span {
+            color: #666;
+          }
+        }
+      }
+    }
+  }
+}
+</style>