Browse Source

修改主页

lrf402788946 5 years ago
parent
commit
674f6cda10

+ 4 - 3
src/components/index.vue

@@ -7,7 +7,7 @@
         </div>
       </el-col>
       <el-col :span="24" class="menu">
-        <menuInfo></menuInfo>
+        <menuInfo :menuList="menuList"></menuInfo>
       </el-col>
       <el-col :span="24" class="banner">
         <banner :info="info"></banner>
@@ -15,7 +15,7 @@
       <el-col :span="24" class="newsNotice">
         <div class="w_1200">
           <el-col :span="16" class="news">
-            <news :imglist="imglist"></news>
+            <news :newsList="newsList"></news>
           </el-col>
           <el-col :span="7" class="notice">
             <notice :noticeList="noticeList"></notice>
@@ -75,11 +75,12 @@ export default {
   name: 'index',
   props: {
     info: null, //头部信息
-    imglist: null, //新闻信息
+    newsList: null, //新闻信息
     noticeList: null, //通知公告
     recruitList: null, //最新招聘信息
     companyList: null, //招聘企业
     nativeList: null, //信息网导航
+    menuList: null, //菜单列表
   },
   components: {
     top, //头部

+ 1 - 1
src/layout/index/calendar.vue

@@ -62,7 +62,7 @@ export default {
     },
   }),
   created() {
-    this.search();
+    // this.search();
   },
   computed: {},
   methods: {

+ 22 - 3
src/layout/index/company.vue

@@ -1,19 +1,19 @@
 <template>
   <div id="company">
-    <el-row>
+    <el-row v-loading="loading">
       <el-col :span="24" class="company">
         <el-col :span="24" class="newsTop">
           <el-col :span="18" class="text">
             {{ title }}
           </el-col>
           <el-col :span="6" class="link">
-            <el-link :underline="false">MORE<i class="el-icon-circle-plus-outline" style="color:#f8b024;font-weight:bold;margin:0 5px;"></i> </el-link>
+            <!-- <el-link :underline="false">MORE(todo)<i class="el-icon-circle-plus-outline" style="color:#f8b024;font-weight:bold;margin:0 5px;"></i> </el-link> -->
           </el-col>
         </el-col>
         <el-col :span="24" class="info">
           <el-col :span="12" class="list" v-for="(item, index) in companyList" :key="index">
             <el-col :span="24" class="title">
-              <p class="textOver">{{ item.title }}({{ item.time }})</p>
+              <p class="textOver">{{ item.title }}({{ item.meta | getDate }})</p>
             </el-col>
           </el-col>
         </el-col>
@@ -23,6 +23,7 @@
 </template>
 
 <script>
+import _ from 'lodash';
 export default {
   name: 'company',
   props: {
@@ -30,11 +31,29 @@ export default {
   },
   components: {},
   data: () => ({
+    loading: true,
     title: '招聘企业',
   }),
+  watch: {
+    companyList: {
+      handler(val) {
+        if (val) this.loading = false;
+      },
+    },
+  },
   created() {},
   computed: {},
   methods: {},
+  filters: {
+    getDate(meta) {
+      let createdAt = _.get(meta, `createdAt`);
+      let date = new Date(createdAt)
+        .toLocaleDateString()
+        .replace('/', '-')
+        .replace('/', '-');
+      return date;
+    },
+  },
 };
 </script>
 

+ 3 - 3
src/layout/index/contact.vue

@@ -8,9 +8,9 @@
               联系我们
             </el-col>
             <el-col :span="24" class="title">
-              <p><i class="el-icon-location-outline"></i>{{ info.address }}</p>
+              <p v-html="info.content"><i class="el-icon-location-outline"></i></p>
             </el-col>
-            <el-col :span="24" class="title">
+            <!-- <el-col :span="24" class="title">
               <p><i class="el-icon-message"></i>{{ info.email }}</p>
             </el-col>
             <el-col :span="24" class="title">
@@ -21,7 +21,7 @@
             </el-col>
             <el-col :span="24" class="title">
               <p><i class="el-icon-timer"></i>{{ info.date }}</p>
-            </el-col>
+            </el-col> -->
           </el-col>
           <el-col :span="12" class="ditu">
             <p>地图</p>

+ 1 - 1
src/layout/index/foot.vue

@@ -2,7 +2,7 @@
   <div id="foot">
     <el-row>
       <el-col :span="24" class="foot">
-        <p class="textOver">{{ info.footTitle }}</p>
+        <p class="textOver">{{ info.copyright }}</p>
         <el-image :src="footUrl"></el-image>
       </el-col>
     </el-row>

+ 26 - 7
src/layout/index/menuInfo.vue

@@ -7,19 +7,32 @@
             :default-active="activeIndex1"
             class="el-menu-demo"
             mode="horizontal"
-            @select="handleSelect"
             background-color="#0457c7"
             text-color="#fff"
             active-text-color="#fff"
+            :router="true"
           >
-            <el-menu-item index="1">首页</el-menu-item>
-            <el-menu-item index="2">政策法规</el-menu-item>
+            <el-menu-item index="/">首页</el-menu-item>
+            <template v-for="(item, index) in menuList">
+              <el-submenu :index="`${index}`" :key="index" v-if="item.type !== 'url' && item.type !== 'content'">
+                <template slot="title">
+                  {{ item.title }}
+                </template>
+                <template v-for="(sub, subIndex) in item.children">
+                  <el-menu-item :index="sub.path" :key="subIndex" v-if="sub.type !== 'url'">{{ sub.title }}</el-menu-item>
+                  <el-menu-item :index="``" :key="subIndex" @click="turnTo(sub.url)" v-else> {{ sub.title }}</el-menu-item>
+                </template>
+              </el-submenu>
+              <el-menu-item v-else-if="item.type === 'content'" :index="item.path" :key="index">{{ item.title }}</el-menu-item>
+              <el-menu-item v-else :index="``" :key="index" @click="turnTo(item.url)">{{ item.title }}</el-menu-item>
+            </template>
+            <!-- <el-menu-item index="2">政策法规</el-menu-item>
             <el-menu-item index="3">网上大厅</el-menu-item>
             <el-menu-item index="4">招聘信息</el-menu-item>
             <el-menu-item index="5">就业指导</el-menu-item>
             <el-menu-item index="6">党员之家</el-menu-item>
             <el-menu-item index="7">调查问卷</el-menu-item>
-            <el-menu-item index="8">关于我们</el-menu-item>
+            <el-menu-item index="8">关于我们</el-menu-item> -->
           </el-menu>
         </div>
       </el-col>
@@ -30,7 +43,9 @@
 <script>
 export default {
   name: 'menuInfo',
-  props: {},
+  props: {
+    menuList: null,
+  },
   components: {},
   data: () => ({
     activeIndex1: '1',
@@ -38,8 +53,8 @@ export default {
   created() {},
   computed: {},
   methods: {
-    handleSelect(key, keyPath) {
-      console.log(key, keyPath);
+    turnTo(url) {
+      window.open(url);
     },
   },
 };
@@ -54,6 +69,10 @@ export default {
   height: 40px;
   line-height: 40px;
 }
+/deep/.el-menu--horizontal > .el-submenu .el-submenu__title {
+  height: 40px;
+  line-height: 40px;
+}
 /deep/.el-menu--horizontal > .el-menu-item {
   border-bottom: none;
 }

+ 16 - 6
src/layout/index/naitve.vue

@@ -1,11 +1,11 @@
 <template>
   <div id="naitve">
-    <el-row>
+    <el-row v-loading="loading">
       <el-col :span="24" class="native">
-        <el-tabs v-model="activeName" type="card" :before-leave="handleClick">
-          <el-tab-pane v-for="(item, index) in nativeList" :key="index">
-            <span slot="label">{{ item.title }}</span>
-            <el-col :span="6" v-for="(tag, index) in item.children" :key="index" class="enterList">
+        <el-tabs v-model="activeName" type="card">
+          <el-tab-pane name="0">
+            <span slot="label">网站导航</span>
+            <el-col :span="6" v-for="(tag, index) in nativeList" :key="index" class="enterList">
               <el-col :span="24" class="title">
                 <el-link :underline="false" :href="tag.url" target="_blank">{{ tag.title }} </el-link>
               </el-col>
@@ -24,7 +24,17 @@ export default {
     nativeList: null,
   },
   components: {},
-  data: () => ({}),
+  data: () => ({
+    loading: true,
+    activeName: '0',
+  }),
+  watch: {
+    nativeList: {
+      handler(val) {
+        if (val) this.loading = false;
+      },
+    },
+  },
   created() {},
   computed: {},
   methods: {},

+ 46 - 12
src/layout/index/news.vue

@@ -1,35 +1,45 @@
 <template>
   <div id="news">
-    <el-row>
+    <el-row v-loading="loading">
       <el-col :span="24" class="news">
         <el-col :span="24" class="newsTop">
           <el-col :span="18" class="text">
-            {{ title }}
+            {{ newsList.title || title }}
           </el-col>
           <el-col :span="6" class="link">
-            <el-link :underline="false">MORE<i class="el-icon-circle-plus-outline" style="color:#f8b024;font-weight:bold;margin:0 5px;"></i> </el-link>
+            <el-link :underline="false" @click="$router.push({ path: path })">
+              MORE<i class="el-icon-circle-plus-outline" style="color:#f8b024;font-weight:bold;margin:0 5px;"></i>
+            </el-link>
           </el-col>
         </el-col>
         <el-col :span="24" class="info">
           <el-col :span="11" class="block">
             <el-carousel :interval="5000" arrow="always" ref="shubiao">
-              <el-carousel-item v-for="(item, index) in imglist" :key="index" :name="`${index}`">
+              <el-carousel-item v-for="(item, index) in infoList" :key="index" :name="`${index}`">
                 <!-- @click="$router.push({ path: `/info/detail?id=${item.id}` })" -->
-                <el-link :underline="false">
-                  <el-image style="width:369px;height:242px;" :src="item.url"></el-image>
+                <el-link :underline="false" @click="$router.push({ path: `/info/detail?id=${item.id}` })">
+                  <el-image style="width:369px;height:242px;" :src="item.pic"></el-image>
                   <el-col :span="24" class="cont">
-                    <p>{{ item.content }}</p>
+                    <p>{{ item.title }}</p>
                   </el-col>
                 </el-link>
               </el-carousel-item>
             </el-carousel>
           </el-col>
           <el-col :span="12" class="content">
-            <el-col :span="24" class="titList" @mouseover="shuYi(index)" :class="newListActive(item)" v-for="(item, index) in imglist" :key="index">
+            <el-col
+              :span="24"
+              class="titList"
+              @mouseover="shuYi(index)"
+              :class="newListActive(item)"
+              v-for="(item, index) in infoList"
+              :key="index"
+              @click="$router.push({ path: `/info/detail?id=${tag.id}` })"
+            >
               <span class="shu"></span>
               <!-- @click="$router.push({ path: `/info/detail?id=${tag.id}` })" -->
               <span class="title">{{ item.title }}</span>
-              <span class="time">{{ item.time }}</span>
+              <span class="time">{{ item.publish_time }}</span>
             </el-col>
           </el-col>
         </el-col>
@@ -39,18 +49,42 @@
 </template>
 
 <script>
+import _ from 'lodash';
 export default {
   name: 'news',
   props: {
-    imglist: null,
+    newsList: null,
   },
   components: {},
   data: () => ({
+    loading: true,
     title: '就业动态',
+    infoList: [],
+    path: undefined,
   }),
+  watch: {
+    newsList: {
+      handler(val) {
+        if (val) this.assignData(val);
+      },
+    },
+  },
   created() {},
   computed: {},
   methods: {
+    assignData(data) {
+      let columns = _.get(data, 'children');
+      let news = [];
+      for (const item of columns) {
+        if (!this.path) this.path = item.path;
+        let newsList = _.get(item, `children`);
+        if (newsList) {
+          news = news.concat(news, newsList);
+        }
+      }
+      this.$set(this, `infoList`, news);
+      this.loading = false;
+    },
     shuYi(index) {
       this.$refs.shubiao.setActiveItem(`${index}`);
     },
@@ -126,7 +160,7 @@ p {
   font-size: 14px;
   color: #5b5b5b;
   display: inline-block;
-  width: 300px;
+  width: 270px;
   padding: 0 10px;
   overflow: hidden;
   text-overflow: ellipsis;
@@ -136,7 +170,7 @@ p {
   font-size: 14px;
   color: #5b5b5b;
   display: inline-block;
-  width: 70px;
+  width: 100px;
   overflow: hidden;
   padding: 0 10px;
 }

+ 32 - 5
src/layout/index/notice.vue

@@ -1,17 +1,19 @@
 <template>
-  <div id="notice">
+  <div id="notice" v-loading="loading">
     <el-row>
       <el-col :span="24" class="notice">
         <el-col :span="24" class="newsTop">
           <el-col :span="18" class="text">
-            {{ title }}
+            {{ noticeList.title || title }}
           </el-col>
           <el-col :span="6" class="link">
-            <el-link :underline="false">MORE<i class="el-icon-circle-plus-outline" style="color:#f8b024;font-weight:bold;margin:0 5px;"></i> </el-link>
+            <el-link :underline="false" @click="$router.push({ path: path })">
+              MORE<i class="el-icon-circle-plus-outline" style="color:#f8b024;font-weight:bold;margin:0 5px;"></i>
+            </el-link>
           </el-col>
         </el-col>
         <el-col :span="24" class="info">
-          <el-col :span="24" class="list" v-for="(item, index) in noticeList" :key="index">
+          <el-col :span="24" class="list" v-for="(item, index) in infoList" :key="index" @click="$router.push({ path: `/info/detail?id=${tag.id}` })">
             <span class="shu"></span>
             <span class="title">{{ item.title }}</span>
           </el-col>
@@ -22,6 +24,7 @@
 </template>
 
 <script>
+import _ from 'lodash';
 export default {
   name: 'notice',
   props: {
@@ -29,11 +32,35 @@ export default {
   },
   components: {},
   data: () => ({
+    loading: true,
     title: '通知公告',
+    infoList: [],
+    path: undefined,
   }),
+  watch: {
+    noticeList: {
+      handler(val) {
+        if (val) this.assignData(val);
+      },
+    },
+  },
   created() {},
   computed: {},
-  methods: {},
+  methods: {
+    assignData(data) {
+      let columns = _.get(data, 'children');
+      let notice = [];
+      for (const item of columns) {
+        if (!this.path) this.path = item.path;
+        let noticeList = _.get(item, `children`);
+        if (noticeList) {
+          notice = notice.concat(notice, noticeList);
+        }
+      }
+      this.$set(this, `infoList`, notice);
+      this.loading = false;
+    },
+  },
 };
 </script>
 

+ 36 - 5
src/layout/index/recruit.vue

@@ -1,6 +1,6 @@
 <template>
   <div id="recruit">
-    <el-row>
+    <el-row v-loading="loading">
       <el-col :span="24" class="recruit">
         <el-col :span="24" class="newsTop">
           <el-col :span="18" class="text">
@@ -21,13 +21,13 @@
           </el-col>
           <el-col :span="24" class="listinfo" v-for="(item, index) in recruitList" :key="index">
             <el-col :span="6" class="title">
-              <p class="textOver"><span class="dian"></span>{{ item.title }}</p>
+              <p class="textOver"><span class="dian"></span>{{ item.title }}todo:跳转至公司详情</p>
             </el-col>
             <el-col :span="6" class="jobs">
-              <p class="textOver">{{ item.jobs }}</p>
+              <p class="textOver">{{ item.jobs | getJobs }}</p>
             </el-col>
-            <el-col :span="6" class="link"><el-link :underline="false">[在线投递简历]</el-link></el-col>
-            <el-col :span="6" class="date">{{ item.date }}</el-col>
+            <el-col :span="6" class="link"><el-link :underline="false">[点击查看详情]todo:跳转至详情</el-link></el-col>
+            <el-col :span="6" class="date">{{ item.meta | getDate }}</el-col>
           </el-col>
         </el-col>
       </el-col>
@@ -36,6 +36,7 @@
 </template>
 
 <script>
+import _ from 'lodash';
 export default {
   name: 'recruit',
   props: {
@@ -44,10 +45,40 @@ export default {
   components: {},
   data: () => ({
     title: '最新招聘信息',
+    loading: true,
+    path: undefined,
   }),
   created() {},
   computed: {},
+  watch: {
+    recruitList: {
+      handler(val) {
+        if (val) this.loading = false;
+      },
+    },
+  },
   methods: {},
+  filters: {
+    getJobs(jobs) {
+      let returns = null;
+      if (jobs.length > 0) {
+        for (const item of jobs) {
+          returns = returns === null ? `${item.job_name}` : `${returns};${item.job_name}`;
+        }
+      } else {
+        returns = '无招聘职位';
+      }
+      return returns;
+    },
+    getDate(meta) {
+      let createdAt = _.get(meta, `createdAt`);
+      let date = new Date(createdAt)
+        .toLocaleDateString()
+        .replace('/', '-')
+        .replace('/', '-');
+      return date;
+    },
+  },
 };
 </script>
 

+ 1 - 1
src/layout/index/top.vue

@@ -3,7 +3,7 @@
     <el-row>
       <el-col :span="24" class="info">
         <el-col :span="12" class="left">
-          <el-image style="height:120px;" :src="info.src"></el-image>
+          <el-image style="height:120px;" :src="info.logo"></el-image>
         </el-col>
         <el-col :span="12" class="right">
           <p class="phone"><i class="el-icon-phone-outline" style="color:#868686;"></i>{{ info.phone }}</p>

+ 23 - 0
src/store/column.js

@@ -0,0 +1,23 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  list: `/api/cms/column/list`,
+  fetch: id => `/api/cms/column/fetch/${id}`,
+};
+export const state = () => ({});
+export const mutations = {};
+export const actions = {
+  async getColumn({ commit }, { type, data }) {
+    let result;
+    if (type === `list`) {
+      result = await this.$axios.$get(api.list, data);
+    } else {
+      let { id } = data;
+      result = await this.$axios.$get(api.fetch(id));
+    }
+
+    return result;
+  },
+};

+ 18 - 1
src/store/index.js

@@ -1,5 +1,13 @@
 import Vue from 'vue';
 import Vuex from 'vuex';
+import * as site from './site';
+import * as menu from './menu';
+import * as modules from './module';
+import * as column from './column';
+import * as news from './news';
+import * as jobinfo from './jobinfo';
+import * as posts from './posts';
+import * as linkCor from './link-cor';
 
 Vue.use(Vuex);
 
@@ -7,5 +15,14 @@ export default new Vuex.Store({
   state: {},
   mutations: {},
   actions: {},
-  modules: {},
+  modules: {
+    site: site,
+    menu: menu,
+    modules: modules,
+    column: column,
+    news: news,
+    jobinfo: jobinfo,
+    posts: posts,
+    linkCor: linkCor,
+  },
 });

+ 37 - 0
src/store/jobinfo.js

@@ -0,0 +1,37 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  list: `/api/jobs/infos`,
+  fetch: id => `/api/jobs/infos/${id}`,
+};
+export const state = () => ({});
+export const mutations = {};
+export const actions = {
+  //在线招聘
+  async getJobInfo({ state }, { type, data }) {
+    let { skip = 0, limit } = data;
+    let result;
+    if (type === 'list') {
+      let { schid, is_practice, ...searchInfo } = data;
+      result = await this.$axios.$get(
+        api.list,
+        {},
+        {
+          schid: schid,
+          is_practice: is_practice,
+          skip: skip,
+          limit: limit,
+          status: 1,
+          ...searchInfo,
+        }
+      );
+    }
+    if (type === 'search') {
+      let { id } = data;
+      result = await this.$axios.$get(api.fetch(id));
+    }
+    return result;
+  },
+};

+ 21 - 0
src/store/link-cor.js

@@ -0,0 +1,21 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  list: `/api/cms/img/list`,
+  fetch: id => `/api/cms/img/list/${id}`,
+};
+export const state = () => ({});
+export const mutations = {};
+export const actions = {
+  //在线招聘
+  async getLink({ state }) {
+    let result = {};
+    let corps = await this.$axios.$get(api.list, { type: 'cooperation', is_use: '0' });
+    if (corps.errcode === 0) result.corps = corps.data;
+    let links = await this.$axios.$get(api.list, { type: 'link', is_use: '0' });
+    if (links.errcode === 0) result.links = links.data;
+    return result;
+  },
+};

+ 22 - 0
src/store/menu.js

@@ -0,0 +1,22 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  list: `/api/cms/menu/list`,
+  fetch: id => `/api/cms/menu/fetch/${id}`,
+};
+export const state = () => ({});
+export const mutations = {};
+export const actions = {
+  async getMenu({ commit }, { type, data }) {
+    let result;
+    if (type === `list`) {
+      result = await this.$axios.$get(api.list, data);
+    } else {
+      let { id } = data;
+      result = await this.$axios.$get(api.fetch(id));
+    }
+    return result;
+  },
+};

+ 15 - 0
src/store/module.js

@@ -0,0 +1,15 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  list: `/api/cms/modules/list`,
+};
+export const state = () => ({});
+export const mutations = {};
+export const actions = {
+  async getModule({ commit }, { type, data }) {
+    let result = await this.$axios.$get(_.get(api, type), data);
+    return result;
+  },
+};

+ 24 - 0
src/store/news.js

@@ -0,0 +1,24 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  list: `/api/cms/news/list`,
+  fetch: id => `/api/cms/news/fetch/${id}`,
+  bugList: `/api/cms/newscreeper/list`,
+};
+export const state = () => ({});
+export const mutations = {};
+export const actions = {
+  async getNews({ commit }, { type, data }) {
+    let result;
+    if (type !== 'fetch') {
+      result = await this.$axios.$get(api.bugList, data);
+    } else {
+      let { id } = data;
+      result = await this.$axios.$get(api.fetch(id));
+    }
+
+    return result;
+  },
+};

+ 38 - 0
src/store/posts.js

@@ -0,0 +1,38 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  list: `/api/jobs/posts`,
+  fetch: id => `/api/jobs/posts/${id}`,
+};
+export const state = () => ({});
+export const mutations = {};
+export const actions = {
+  //在线招聘
+  async getPosts({ state }, { type, data }) {
+    let { skip = 0, limit } = data;
+    let result;
+    if (type === 'list') {
+      let { schid, corpid, is_practice, is_publish, ...searchInfo } = data;
+      result = await this.$axios.$get(
+        api.list,
+        {},
+        {
+          schid: schid,
+          corpid: corpid,
+          is_practice: is_practice,
+          skip: skip,
+          limit: limit,
+          is_publish: is_publish,
+          ...searchInfo,
+        }
+      );
+    }
+    if (type === 'fetch') {
+      let { id } = data;
+      result = await this.$axios.$get(api.fetch(id));
+    }
+    return result;
+  },
+};

+ 21 - 0
src/store/site.js

@@ -0,0 +1,21 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  query: `/api/cms/site/query`,
+  fetch: `/api/cms/site/config`,
+  content: `/api/cms/site/content`,
+};
+export const state = () => ({});
+export const mutations = {};
+export const actions = {
+  async getSite({ commit }, { type, data }) {
+    let content = await this.$axios.$get(api.content, {});
+    let result = await this.$axios.$get(_.get(api, `fetch`));
+    if (content.data && `${content.errcode}` === '0') {
+      result.data.content = content && content.data ? content.data : '';
+    }
+    return result;
+  },
+};

+ 1 - 1
src/util/axios-wrapper.js

@@ -83,7 +83,7 @@ export default class AxiosWrapper {
       }
       // unwrap data
       if (this.unwrap) {
-        res = _.omit(res, ['errcode', 'errmsg', 'details']);
+        res = _.omit(res, ['errmsg', 'details']);
         const keys = Object.keys(res);
         if (keys.length === 1 && keys.includes('data')) {
           res = res.data;

+ 197 - 44
src/views/index.vue

@@ -1,19 +1,27 @@
 <template>
   <div id="index">
     <index-detail
-      :info="info"
-      :imglist="imglist"
+      :info="site"
+      :newsList="newsList"
       :noticeList="noticeList"
-      :recruitList="recruitList"
-      :companyList="companyList"
-      :nativeList="nativeList"
+      :recruitList="jobinfoList"
+      :companyList="corpList"
+      :nativeList="linkList"
+      :menuList="menu"
     ></index-detail>
   </div>
 </template>
 
 <script>
 import indexDetail from '@/components/index.vue';
+import { mapActions, mapState } from 'vuex';
+import _ from 'lodash';
 export default {
+  metaInfo() {
+    return {
+      title: this.siteTitle ? this.siteTitle : '就业信息网',
+    };
+  },
   name: 'index',
   props: {},
   components: {
@@ -31,47 +39,192 @@ export default {
       date: '办公时间:周一至周五,法定假日不对外办公。',
       footTitle: '吉ICP备09006292号-1 Copyright 2013 版权所有 吉林省高等学校毕业生就业指导中心 All Rights Reserved',
     },
-    imglist: [
-      {
-        url: require('@/assets/news.png'),
-        title: '省成功举办全国高校就业指导人员培训',
-        time: '2019-12-2',
-        content: '省成功举办全国高校就业指导人员培训省成功举办全国高校就业指导人员培训',
-      },
-    ],
-    noticeList: [
-      {
-        title: '省成功举办全国高校就业指导人员培训省成功举办全国高校就业指导人员培训',
-      },
-    ],
-    recruitList: [
-      {
-        title: '辽源市百康药业有限责任公司',
-        jobs: '招聘化学和药学相关专业',
-        date: '2019-12-02',
-      },
-    ],
-    companyList: [
-      {
-        title: '[广西] 中国建筑材料工业地质勘查中心广西总队',
-        time: '(10-15)',
-      },
-    ],
-    nativeList: [
-      {
-        title: '网站导航',
-        children: [
-          {
-            title: '长春工业大学就业信息网',
-            url: 'http://99991.smart.cc-lotus.info/www/',
-          },
-        ],
-      },
-    ],
+    site: {}, //站点信息
+    siteTitle: {}, //站点标题
+    menu: [], //菜单
+    modules: [], //模块
+    newsList: [], //新闻模块
+    noticeList: [], //公告模块
+    self1List: [], //自定义模块现在没用
+    self2List: [], //自定义模块现在没用
+    jobinfoList: [], //招聘信息
+    linkList: [], //网站导航
+    corpList: [], //招聘企业
   }),
-  created() {},
+  async created() {
+    await this.toGetSite(); //获取主站信息
+    this.loadMenu(); //获取菜单信息
+    this.toGetModule(); //获取模块信息
+    this.toGetJobInfo(); //获取招聘信息
+    this.toGetLinks(); //招聘信息+网站链接
+  },
   computed: {},
-  methods: {},
+  methods: {
+    ...mapActions(['getSite', `getMenu`, 'getColumn', 'getModule', 'getNews', 'getJobInfo', 'getPosts', 'getLink']),
+    //站点信息
+    async toGetSite() {
+      let site = sessionStorage.getItem('site');
+      if (!site) {
+        let result = await this.getSite({ type: 'search' });
+        if (result.errcode === 0) {
+          sessionStorage.setItem('site', JSON.stringify(result.data));
+          if (_.get(result.data, `custom`)) {
+            let item = result.custom;
+            // this.getfloating(item);
+          }
+          this.$set(this, `site`, result.data);
+          this.$set(this, `siteTitle`, this.site.name);
+        }
+      } else {
+        this.$set(this, `site`, JSON.parse(site));
+        this.$set(this, `siteTitle`, this.site.name);
+        let arr = this.site;
+        if (arr.custom) {
+          let item = arr.custom;
+          // this.getfloating(item);
+        }
+      }
+    },
+    //菜单
+    async loadMenu() {
+      let menu = sessionStorage.getItem('menu');
+      if (menu) {
+        this.$set(this, `menu`, JSON.parse(menu));
+        this.finishedMenu();
+        return;
+      } else this.toGetMenu();
+    },
+    async toGetMenu() {
+      let result = await this.getMenu({ type: `list` });
+      if (result.errcode === 0) {
+        sessionStorage.setItem('menu', JSON.stringify(result.data));
+        this.$set(this, `menu`, result.data);
+        this.finishedMenu();
+      }
+    },
+    async finishedMenu() {
+      let menus = JSON.parse(JSON.stringify(this.menu));
+      for (const item of menus) {
+        if (item.type === 'content') {
+          item.path = `/info/detail?id=${item.content_id}`;
+        } else if (item.type !== 'url') {
+          let res = await this.completeMenu(item);
+          item.children = res;
+        }
+      }
+      this.$set(this, `menu`, menus);
+    },
+    async completeMenu(item) {
+      let result = await this.getColumn({
+        type: `list`,
+        data: { parent_id: item.id },
+      });
+      if (result.errcode === 0) {
+        let columns = result.data;
+        for (const col of columns) {
+          if (col.type === 'content') {
+            col.path = `/info/detail?id=${col.content_id}`;
+          } else if (col.type !== 'url') {
+            col.path = `/info/list/${col.id}`;
+          }
+        }
+        return columns;
+      }
+    },
+    //模块
+    async loadModule() {
+      let modules = sessionStorage.getItem('modules');
+      if (modules) {
+        this.$set(this, `modules`, JSON.parse(modules));
+        return;
+      }
+      this.toGetMenu();
+    },
+    async toGetModule() {
+      let result = await this.getModule({ type: `list` });
+      if (result.errcode === 0) {
+        sessionStorage.setItem('modules', JSON.stringify(result.data));
+        this.$set(this, `modules`, result.data);
+        this.finishedModule();
+      }
+    },
+    async finishedModule() {
+      let modules = JSON.parse(JSON.stringify(this.modules));
+      for (const item of modules) {
+        if (`${item.is_use}` === `0`) {
+          let res = await this.completeModules(item);
+          item.children = res;
+        }
+      }
+      for (const item of modules) {
+        this.$set(this, `${item.category}List`, item);
+      }
+      this.$set(this, `modules`, modules);
+    },
+    async completeModules(item) {
+      let result = await this.getColumn({
+        type: `list`,
+        data: { parent_id: item.id },
+      });
+      if (result.errcode === 0) {
+        let columns = result.data;
+        for (const col of columns) {
+          if (col.type === `bugList`) {
+            col.path = `/info/list/${col.content_id}`;
+            col.children = await this.completeColumn(col);
+          } else if (col.type === `column`) {
+            col.path = `/info/list/${col.id}`;
+            col.children = await this.completeColumn(col);
+          } else if (col.type === `content`) {
+            col.path = `/info/detail?id=${col.content_id}`;
+          }
+        }
+        return columns;
+      }
+    },
+    async completeColumn(item) {
+      let data = { skip: 0, limit: 8 };
+      if (item.type === `bugList`) {
+        data.news_type = `0`;
+        data.parent_id = item.content_id;
+      } else {
+        data.news_type = `1`;
+        data.parent_id = item.id;
+      }
+      let result = await this.getNews({ type: 'bugList', data: data });
+      if (result.errcode === 0) {
+        return result.data;
+      }
+    },
+    //获取招聘信息
+    async toGetJobInfo() {
+      let result = await this.getJobInfo({ type: 'list', data: { limit: 8 } });
+      if (`${result.errcode}` === '0') {
+        for (const item of result.data) {
+          if (!item.jobs || !(item.jobs.length > 0)) continue;
+          let jobs = [];
+          for (let job of item.jobs) {
+            let jobInfo = await this.toGetPosts(job);
+            jobs.push(jobInfo);
+          }
+          item.jobs = jobs;
+        }
+        this.$set(this, 'jobinfoList', result.data);
+      } else {
+        this.$message.error(result.errmsg ? result.errmsg : 'error');
+      }
+    },
+    async toGetPosts(id) {
+      let result = await this.getPosts({ type: 'fetch', data: { id: id } });
+      if (result.errcode === 0) return result.data;
+    },
+    //招聘单位+网站链接
+    async toGetLinks() {
+      let { links = [], corps = [] } = await this.getLink();
+      this.$set(this, `linkList`, links);
+      this.$set(this, `corpList`, corps);
+    },
+  },
 };
 </script>
 

+ 12 - 0
vue.config.js

@@ -23,6 +23,18 @@ module.exports = {
     port: '8001',
     //api地址前缀
     proxy: {
+      '/api': {
+        target: 'http://smart.cc-lotus.info',
+        ws: true,
+        onProxyReq(proxyReq, req, res) {
+          proxyReq.setHeader('x-tenant', 'master');
+        },
+      },
+      '/files': {
+        target: 'http://smart.cc-lotus.info',
+        changeOrigin: true,
+        ws: true,
+      },
       '/weixin': {
         target: 'http://smart.cc-lotus.info',
         changeOrigin: true,