lrf402788946 5 éve
szülő
commit
f9adb36c02

BIN
src/assets/defaultNews.jpg


+ 4 - 4
src/pages/index/views/home.vue

@@ -2,7 +2,7 @@
   <div id="home">
     <!-- <test-user></test-user> -->
     <el-image style="width: 100%; height: 10rem" :src="url"></el-image>
-    <el-row type="flex" align="middle" class="menu_list">
+    <el-row align="middle" class="menu_list">
       <!-- drawerTalk = true" -->
       <el-col :span="6" class="list_border" @click.native="toHtml('talkList.html#/')">
         <el-col :span="24"><div class="el-icon-school icon_zoom"></div></el-col>
@@ -52,7 +52,7 @@
         <el-col :span="16">
           {{ news.title }}<b class="tip_en">{{ news.title }}</b>
         </el-col>
-        <el-col :span="8" class="more">
+        <el-col :span="8" class="more" @click.native="toHtml(`newsList.html#/${news.id}?title=${news.title}`)">
           查看更多
         </el-col>
       </el-row>
@@ -66,7 +66,7 @@
         <el-col :span="16">
           {{ notice.title }}<b class="tip_en">{{ notice.title }}</b>
         </el-col>
-        <el-col :span="8" class="more">
+        <el-col :span="8" class="more" @click.native="toHtml(`newsList.html#/${notice.id}?title=${notice.title}`)">
           查看更多
         </el-col>
       </el-row>
@@ -263,7 +263,7 @@ export default {
   height: 3rem;
 }
 .menu_list {
-  padding: 0 1rem;
+  padding: 0.5rem 1rem;
 }
 .list_border {
   border: 0.0625rem solid #ebeced;

+ 19 - 0
src/pages/newsList/App.vue

@@ -0,0 +1,19 @@
+<template>
+  <div>
+    <router-view />
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'app',
+  components: {},
+};
+</script>
+
+<style lang="less">
+body {
+  padding: 0;
+  margin: 0;
+}
+</style>

+ 20 - 0
src/pages/newsList/main.js

@@ -0,0 +1,20 @@
+import Vue from 'vue';
+import App from './App.vue';
+import router from './router';
+import store from './store/index';
+import '@/plugins/element.js';
+import '@/plugins/axios';
+import '@/plugins/methods';
+import '@/plugins/check-res';
+import '@/plugins/meta';
+import '@/plugins/filters';
+import '@/plugins/loading';
+import './plugins/nuts';
+
+Vue.config.productionTip = false;
+
+new Vue({
+  router,
+  store,
+  render: h => h(App),
+}).$mount('#app');

+ 9 - 0
src/pages/newsList/plugins/nuts.js

@@ -0,0 +1,9 @@
+import Vue from 'vue';
+import { InfiniteLoading, Calendar, Button, ActionSheet, Scroller, Navbar } from '@nutui/nutui';
+
+InfiniteLoading.install(Vue);
+Calendar.install(Vue);
+Button.install(Vue);
+ActionSheet.install(Vue);
+Scroller.install(Vue);
+Navbar.install(Vue);

+ 16 - 0
src/pages/newsList/router.js

@@ -0,0 +1,16 @@
+import Vue from 'vue';
+import Router from 'vue-router';
+
+Vue.use(Router);
+
+const router = new Router({
+  routes: [
+    {
+      path: '/:id',
+      name: 'list',
+      component: () => import('./views/list.vue'),
+    },
+  ],
+});
+
+export default router;

+ 16 - 0
src/pages/newsList/store/index.js

@@ -0,0 +1,16 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import * as site from '@/store/site';
+import * as modules from '@/store/module';
+import * as column from '@/store/column';
+import * as news from '@/store/news';
+Vue.use(Vuex);
+
+export default new Vuex.Store({
+  modules: {
+    site: site,
+    module: modules,
+    column: column,
+    news: news,
+  },
+});

+ 57 - 0
src/pages/newsList/views/item.vue

@@ -0,0 +1,57 @@
+<template>
+  <div id="item">
+    <list-layout @search="toSearch" :needSearch="false" :hasMore="hasMore">
+      <template v-slot:content>
+        <el-row style="background:#fff" v-for="(item, index) in list" :key="index" :gutter="10" @click.native="toHtml(item)">
+          <el-col :span="8">
+            <el-image fit="cover" :src="item.pic ? item.pic : defaultImg"></el-image>
+          </el-col>
+          <el-col :span="16">
+            <el-col :span="24">{{ item.title }}</el-col>
+            <el-col :span="24" class="content_word">
+              <span v-html="item.content"></span>
+            </el-col>
+          </el-col>
+        </el-row>
+      </template>
+    </list-layout>
+  </div>
+</template>
+
+<script>
+import listLayout from '@/layout/list-layout.vue';
+export default {
+  name: 'list-item',
+  props: {
+    list: null,
+    hasMore: { type: Boolean, default: true },
+    index: null,
+  },
+  components: {
+    listLayout,
+  },
+  data: () => ({
+    defaultImg: require('@/assets/defaultNews.jpg'),
+  }),
+  created() {},
+  computed: {},
+  methods: {
+    toSearch() {
+      this.$emit(`search`, { index: this.index, info: 'nextPage' });
+    },
+    toHtml(item) {
+      window.location.href = `news.html#/${item.id}`;
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.content_word {
+  font-size: 12px;
+  color: #3333338f;
+  overflow: hidden;
+  text-overflow: ellipsis;
+  white-space: nowrap;
+}
+</style>

+ 123 - 0
src/pages/newsList/views/list.vue

@@ -0,0 +1,123 @@
+<template>
+  <div id="list">
+    <el-image style="width: 100%; height: 10rem" :src="url"></el-image>
+    <el-tabs v-model="activeName" style="padding:10px;" @tab-click="tabClick">
+      <el-tab-pane v-for="(item, index) in list" :key="index" :name="`${index}`" :label="item.title">
+        <item @search="toSearch" :list="item.children" :hasMore="item.hasMore" :index="item.index"></item>
+      </el-tab-pane>
+    </el-tabs>
+  </div>
+</template>
+
+<script>
+import { mapActions } from 'vuex';
+import item from './item.vue';
+export default {
+  metaInfo() {
+    return {
+      title: this.title ? this.title : '就业信息网',
+    };
+  },
+  name: 'list',
+  props: {},
+  components: {
+    item,
+  },
+  data: () => ({
+    site: {},
+    url: '',
+    list: [],
+    activeName: '0',
+  }),
+  created() {
+    this.getSite();
+    this.getColumn();
+  },
+  computed: {
+    module_id() {
+      return this.$route.params.id;
+    },
+    title() {
+      return this.$route.query.title;
+    },
+  },
+  methods: {
+    ...mapActions(['siteOperation', 'columnOperation', 'newsOperation']),
+    async getSite() {
+      let site = sessionStorage.getItem('site');
+      if (!site) {
+        let result = await this.siteOperation({ type: 'search', data: { site: this.$site } });
+        if (`${result.errcode}` === `0`) {
+          sessionStorage.setItem('site', JSON.stringify(result.data));
+          this.$set(this, `site`, result.data);
+        }
+      } else {
+        this.$set(this, `site`, JSON.parse(site));
+      }
+      this.$set(this, `url`, this.site.banner);
+    },
+    //根据条件获取栏目
+    async getColumn(data = {}) {
+      let res = await this.columnOperation({ type: 'list', data: { parent_id: this.module_id } });
+      this.$set(this, `list`, res.data);
+      for (const key in this.list) {
+        this.toSearch({ index: key });
+      }
+    },
+    //根据条件获取信息
+    async getNewsList(item, news_type, options) {
+      let data = { ...options, news_type: news_type };
+      data.parent_id = news_type === '1' ? item.id : item.content_id;
+      let res = await this.newsOperation({ type: 'list', data: data });
+      if (`${res.errcode}` === '0') {
+        for (const val of res.data) {
+          let result = await this.newsOperation({ type: 'search', data: { id: val.id } });
+          if (`${result.errcode}` === '0') {
+            val.content = result.data.content;
+          } else {
+            this.$message.error(result.errmsg ? result.errmsg : 'error');
+          }
+        }
+        return res;
+      } else {
+        this.$message.error(res.errmsg ? res.errmsg : 'error');
+      }
+    },
+    async toSearch({ index, info }) {
+      let target = JSON.parse(JSON.stringify(this.list[index]));
+      if (target.hasMore === false) return;
+      //分页处理
+      if (info === 'nextPage') {
+        target.page++;
+        target.skip = (target.page - 1) * target.limit;
+      } else {
+        target.page = 1;
+        target.skip = 0;
+        target.limit = this.$limit;
+      }
+      //数据处理
+      if (target.type === 'bugList' || target.type === 'column') {
+        let res = await this.getNewsList(target, target.news_type, { skip: target.skip, limit: target.limit });
+        if (`${res.errcode}` === '0') {
+          target.children ? target.children.concat(res.data) : (target.children = res.data);
+          target.hasMore = target.children.length < res.total;
+        }
+        this.$set(this.list, index, target);
+      } else if (target.type === 'content') {
+        target.path = `news.html#/${target.content_id}`;
+      }
+    },
+    tabClick() {
+      let target = this.list[this.activeName];
+      console.log(target);
+      if (target.type === 'url') {
+        window.location.href = target.url;
+      } else if (target.type === 'content') {
+        window.location.href = `news.html#/${target.id}`;
+      }
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 1 - 0
vue.config.js

@@ -15,6 +15,7 @@ module.exports = {
     student: 'src/pages/student/main.js',
     // corp: 'src/pages/corp/main.js',
     register: 'src/pages/register/main.js',
+    newsList: 'src/pages/newsList/main.js',
   },
   configureWebpack: config => {
     Object.assign(config, {