lrf402788946 il y a 5 ans
Parent
commit
2d893d0845
4 fichiers modifiés avec 27 ajouts et 10 suppressions
  1. 5 2
      src/components/index.vue
  2. 4 5
      src/layout/index/weilai.vue
  3. 3 2
      src/router/index.js
  4. 15 1
      src/views/index.vue

+ 5 - 2
src/components/index.vue

@@ -37,7 +37,7 @@
             </el-col>
           </el-col>
           <el-col :span="24" class="main_3">
-            <weilai :pic="info.advert" :advertlink="info.advertlink"></weilai>
+            <weilai :info="adv.adv1"></weilai>
           </el-col>
           <el-col :span="24" class="main_4">
             <el-col :span="11" class="service">
@@ -55,7 +55,9 @@
           <recruit :recruitList="recruitList" :zixunList="zixunList"></recruit>
         </el-col>
         <el-col :span="24" class="main_3">
-          <weilai :pic="info.advert" :advertlink="info.advertlink"></weilai>
+          <div class="w_1270">
+            <weilai :info="adv.adv2"></weilai>
+          </div>
         </el-col>
         <div class="w_1270">
           <el-col :span="24" class="login">
@@ -108,6 +110,7 @@ export default {
     zixunList: null, //就业咨询
     nativeList: null, //网站导航
     list: null,
+    adv: null, //广告位,目前只有adv1,adv2
   },
   components: {
     top, //头部

+ 4 - 5
src/layout/index/weilai.vue

@@ -1,9 +1,9 @@
 <template>
   <div id="weilai">
     <el-row>
-      <el-col :span="24" class="image">
-        <el-link :underline="false" :href="advertlink">
-          <el-image style="width:100%;height:200px;" :src="pic ? pic : url"></el-image>
+      <el-col :span="24" class="image" v-if="info">
+        <el-link :underline="false" :href="info.url || ''">
+          <el-image style="width:100%;height:200px;" :src="info.pic || ''"></el-image>
         </el-link>
       </el-col>
     </el-row>
@@ -14,8 +14,7 @@
 export default {
   name: 'weilai',
   props: {
-    advertlink: null,
-    pic: null,
+    info: null,
   },
   components: {},
   data: () => ({

+ 3 - 2
src/router/index.js

@@ -102,8 +102,9 @@ const router = new Router({
 router.beforeEach((to, from, next) => {
   let fPath = from.path;
   let tPath = to.fullPath;
-  if (fPath === '/index') window.open(`.${tPath}`);
-  else next();
+  if (fPath === '/index') {
+    window.open(`.${tPath}`);
+  } else next();
 });
 router.afterEach((to, from, next) => {
   window.scrollTo(0, 0);

+ 15 - 1
src/views/index.vue

@@ -17,6 +17,7 @@
       :backColor="backColor"
       :list="list"
       @onsave="onsaveClick"
+      :adv="adv"
     ></index-detail>
   </div>
 </template>
@@ -99,6 +100,7 @@ export default {
       },
     ],
     backColor: '#0457c7',
+    adv: {}, //广告位
   }),
   async created() {
     await this.toGetSite(); //获取主站信息
@@ -287,7 +289,19 @@ export default {
     //请求广告列表
     async getAdv() {
       let res = await this.advQuery({ skip: 0, limit: 2 });
-      console.log(res);
+      if (this.$checkRes(res)) {
+        let adv1 = res.data[0];
+        let adv2 = res.data[1];
+        if (adv1.type == '0') {
+          let Obj = JSON.parse(adv1.url);
+          adv1.url = `/newsList/module/${Obj.id}?title=${Obj.title}`;
+        }
+        if (adv2.type == '0') {
+          let Obj = JSON.parse(adv2.url);
+          adv2.url = `/newsList/module/${Obj.id}?title=${Obj.title}`;
+        }
+        this.$set(this, `adv`, { adv1, adv2 });
+      }
     },
   },
 };