123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- <template>
- <div id="banner_container">
- <!-- <img src="https://img.shuimuai.com/mp/banners/banner1%402x.png" class="full_img main_banner" alt="">-->
- <swiper
- class="screen-swiper round-dot full_img main_banner"
- :indicator-dots="true"
- :circular="true"
- :autoplay="true"
- interval="5000"
- duration="500"
- >
- <swiper-item
- v-for="(item,index) in banners"
- :key="index"
- class="full_img main_banner"
- >
- <img
- :src="item.src"
- mode="aspectFill"
- class="full_img main_banner"
- >
- <button
- class="cu-btn bg-yellow text-white join_button"
- @click="to_none(item.url)"
- >{{
- item.button_text
- }}
- </button>
- </swiper-item>
- </swiper>
- </div>
- </template>
- <script>
- import {getBannerList} from "../requests/user";
- var $this;
- export default {
- name: "HomeBanner",
- data() {
- return {
- banners: [
- {
- id: 1,
- src: "https://img.shuimuai.com/mp/banner1_new.png",
- // src: "",
- url: "/pages/none/main",
- button_text: "关于水母星球",
- },
- {
- id: 2,
- src: "https://img.shuimuai.com/mp/banners/banner3%402x.png",
- url: "/pages/competition/main",
- button_text: "参加比赛",
- },
- {
- id: 3,
- src: "https://img.shuimuai.com/banner_blue.png",
- // src: "",
- url: "/pages/joint/main",
- button_text: "我要联名",
- },
- ],
- };
- },
- methods: {
- to_none($url) {
- mpvue.navigateTo({
- url: $url,
- });
- },
- getBanners() {
- getBannerList().then((res) => {
- if(res.data.code == 0){
- console.log("活动列表ID:", res);
- let $res = res.data;
- let $activities = $res.data;
- let $new_act = $activities.pop();
- console.log("轮播图", $new_act);
- $this.banners[1].src = $new_act["img"]
- ? "https://img.shuimuai.com/" + $new_act["img"]
- : "https://img.shuimuai.com/banner_activity_may_1.png";
- $this.banners[1].url =
- "/pages/competition/main?activity_id=" + $new_act["activity_id"];
- } else {
- $this.banners.splice(1, 1);
- }
- });
- },
- },
- mounted() {
- $this.getBanners();
- // $this.jointBanner()
- },
- created() {
- $this = this;
- },
- };
- </script>
- <style>
- #banner_container {
- position: relative;
- width: 100%;
- z-index: 1;
- }
- .join_button {
- position: absolute;
- right: 33px;
- top: 110px;
- z-index: 2;
- }
- </style>
|