banner.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <div id="banner_container">
  3. <!-- <img src="https://img.shuimuai.com/mp/banners/banner1%402x.png" class="full_img main_banner" alt="">-->
  4. <swiper
  5. class="screen-swiper round-dot full_img main_banner"
  6. :indicator-dots="true"
  7. :circular="true"
  8. :autoplay="true"
  9. interval="5000"
  10. duration="500"
  11. >
  12. <swiper-item
  13. v-for="(item,index) in banners"
  14. :key="index"
  15. class="full_img main_banner"
  16. >
  17. <img
  18. :src="item.src"
  19. mode="aspectFill"
  20. class="full_img main_banner"
  21. >
  22. <button
  23. class="cu-btn bg-yellow text-white join_button"
  24. @click="to_none(item.url)"
  25. >{{
  26. item.button_text
  27. }}
  28. </button>
  29. </swiper-item>
  30. </swiper>
  31. </div>
  32. </template>
  33. <script>
  34. import { getBannerList, getJointBanner } from "../requests/user";
  35. var $this;
  36. export default {
  37. name: "banner",
  38. data() {
  39. return {
  40. banners: [
  41. {
  42. id: 1,
  43. src: "https://img.shuimuai.com/mp/banner1_new.png",
  44. // src: "",
  45. url: "/pages/none/main",
  46. button_text: "关于水母星球",
  47. },
  48. {
  49. id: 2,
  50. src: "https://img.shuimuai.com/mp/banners/banner3%402x.png",
  51. url: "/pages/competition/main",
  52. button_text: "比赛详情",
  53. },
  54. {
  55. id: 3,
  56. src: "https://img.shuimuai.com/banner_blue.png",
  57. // src: "",
  58. url: "/pages/joint/main",
  59. button_text: "我要联名",
  60. },
  61. ],
  62. };
  63. },
  64. methods: {
  65. to_none($url) {
  66. mpvue.navigateTo({
  67. url: $url,
  68. });
  69. },
  70. getBanners() {
  71. getBannerList().then((res) => {
  72. if(res.data.code == 0){
  73. console.log("活动列表ID:", res);
  74. let $res = res.data;
  75. let $activities = $res.data;
  76. let $new_act = $activities.pop();
  77. console.log("轮播图", $new_act);
  78. $this.banners[1].src = $new_act["img"]
  79. ? "https://img.shuimuai.com/" + $new_act["img"]
  80. : "https://img.shuimuai.com/banner_activity_may_1.png";
  81. $this.banners[1].url =
  82. "/pages/competition/main?activity_id=" + $new_act["activity_id"];
  83. } else {
  84. $this.banners.splice(1, 1);
  85. }
  86. });
  87. },
  88. // jointBanner(){
  89. // getJointBanner().then((res) => {
  90. // console.log("banner活动", res.data.data)
  91. // let $banner_img = res.data.data
  92. // $this.banners[0].src = $banner_img[0].img
  93. // $this.banners[2].src = $banner_img[1].img
  94. // });
  95. // }
  96. },
  97. mounted() {
  98. $this.getBanners();
  99. // $this.jointBanner()
  100. },
  101. created() {
  102. $this = this;
  103. },
  104. };
  105. </script>
  106. <style>
  107. #banner_container {
  108. position: relative;
  109. width: 100%;
  110. z-index: 1;
  111. }
  112. .join_button {
  113. position: absolute;
  114. right: 33px;
  115. top: 110px;
  116. z-index: 2;
  117. }
  118. </style>