明梦爽
2022-01-26 08e0f4f66d2e39a19b91e8e2fe1bcad75569d4b8
src/components/page/index.vue
@@ -3,10 +3,10 @@
    <!-- 首页上半部分 -->
    <el-row type="flex" class="row-bg" justify="space-between">
        <div class="block marr10">
          <el-carousel height="460px"  arrow="always" :interval="2000">
          <el-carousel height="460px"  arrow="always" :interval="3000">
            <el-carousel-item v-for="(item,index) in imgList" :key="index">
              <div>
                <img :src="item.path"  alt="" style="width:105%;">
              <div @click="gonew(item.id)" class="cursor">
                <img :src="'http://localhost:8080/'+item.picturePath"  alt="" style="width:105%;">
              </div>
            </el-carousel-item>
          </el-carousel>
@@ -19,6 +19,14 @@
      <school class="school"/>
      <other class="other"/>
    </el-row>
    <!-- 定位fixed -->
    <div class="fixed1">
      <a href="#"><img src="../../assets/gzh.jpg" alt=""></a>
    </div>
    <div class="fixed2">
      <a href="#"><img src="../../assets/wb.jpg" alt=""></a>
    </div>
  </div>
</template>
<script>
@@ -27,16 +35,42 @@
import school from '../../views/school.vue'
import other from '../../views/other.vue'
import {getNewsList} from '../../api/api'
export default {
  components: { notice, work, school, other },
  name: 'index',
  data(){
    return{
      imgList:[
        { path:require('../../assets/boer.jpg'),index: 1},
        { path:require('../../assets/boer2.jpg'),index: 2},
        { path:require('../../assets/boer.jpg'),index: 3},
      ]
      // imgList:[
      //   { path:require('../../assets/1.jpg'),index: 1},
      //   { path:require('../../assets/2.jpg'),index: 2},
      //   { path:require('../../assets/3.jpg'),index: 3},
      // ],
      imgList:[],
    }
  },
  created(){
    this.getnews()
  },
  methods:{
    getnews(){
      const data ={
        current:1,
        newsCategoryId:45,
        size:3
      }
      getNewsList(data).then(res => {
        console.log(res);
        if(res.code == 200){
          this.imgList = res.data.records
        }
      }).catch(err => {
        console.log(err);
      })
    },
    gonew(id){
      this.$router.push({path:'/home/news',query:{id:id}})
    }
  }
}
@@ -66,4 +100,14 @@
  width: 20%;
  margin-left: 5px;
}
.fixed1 {
  position: fixed;
  top:270px;
  right: 2px;
}
.fixed2 {
  position: fixed;
  top:340px;
  right: 2px;
}
</style>