activity.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <view>
  3. <ujp-navbar title="优惠活动" :is-back="false" ></ujp-navbar>
  4. <view class="background">
  5. <view class="banner" v-for="(item,i) in bannerList"
  6. :key="i">
  7. <u-image width="100%" @click="clickBanner(i)"
  8. mode="scaleToFill" height="250" border-radius ="12"
  9. :src="item.picUrl"></u-image>
  10. <view class="tag"
  11. v-if="item.isMain">
  12. <img src="@/assets/img/buy/tip.png">
  13. </view>
  14. </view>
  15. <u-divider bg-color="#F2F4F4" >已经到底了</u-divider>
  16. </view>
  17. <Tabbar :current="1" ref="tabbarMain" ></Tabbar>
  18. </view>
  19. </template>
  20. <script>
  21. import Tabbar from '@/components/Tabbar.vue';
  22. import * as newsApi from '@/apis/news.js'
  23. export default {
  24. data() {
  25. return {
  26. bannerList: [],
  27. }
  28. },
  29. components: {
  30. Tabbar
  31. },
  32. onShow() {
  33. if (this.$refs.tabbarMain) {
  34. this.$refs.tabbarMain.setcount(1);
  35. }
  36. },onLoad() {
  37. this.getBannerInfo("homepage");
  38. },
  39. methods: {
  40. getBannerInfo(code) {
  41. uni.showLoading({
  42. title: "加载中",
  43. mask: true,
  44. })
  45. newsApi.getBannerInfo(code).then((res) => {
  46. this.bannerList = res.data;
  47. uni.hideLoading()
  48. //document.getElementsByClassName("uni-swiper-wrapper")[0].parentNode.style="background-color: rgb(255, 255, 255); height: 120px;"
  49. }).catch(error => {
  50. uni.showToast({
  51. title: error,
  52. icon: "none"
  53. })
  54. })
  55. },
  56. clickBannerTopI(i) {
  57. var mod = this.bannerListTop[i];
  58. //this.showTop = false;
  59. this.clickBanner(0, true, mod)
  60. },
  61. clickBannerTop() {
  62. var mod = this.bannerListTop[this.showTopIndex];
  63. this.showTop = false;
  64. this.clickBanner(0, true, mod)
  65. },
  66. clickBanner(index, bl, modout) {
  67. var uurl = "";
  68. var mod = this.bannerList[index]
  69. if (modout) {
  70. mod = modout;
  71. }
  72. mod.clickUrl = mod.linkUrl
  73. if (mod.linkPicUrl && !bl) {
  74. this.showOss = true;
  75. this.showOssImg = mod.linkPicUrl;
  76. this.showOssIndex = index;
  77. } else if (mod.clickUrl == null) {
  78. } else if (mod.clickUrl.indexOf('http') == 0) {
  79. window.location = mod.clickUrl + uurl;
  80. } else if (mod.clickUrl.slice(-5) == 'login' && this.userId) {
  81. } else if (mod.clickUrl.indexOf('#/') == 0) {
  82. if (mod.clickUrl.indexOf("?") == -1) {
  83. mod.clickUrl += '?';
  84. }
  85. var url = mod.clickUrl.split("#")[1]
  86. //window.location = mod.clickUrl;
  87. uni.navigateTo({
  88. url: url + uurl
  89. })
  90. } else if (mod.clickUrl == '#' || mod.clickUrl == '') {
  91. } else {
  92. uni.navigateTo({
  93. url: mod.clickUrl + uurl
  94. })
  95. }
  96. },
  97. }
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. .tag {
  102. top: -100rpx;
  103. left: 460rpx;
  104. position: relative;
  105. border-radius: 4px 4px 4px 0px;
  106. color: #fff;
  107. padding: 2px 6px;
  108. font-size: 20rpx;
  109. line-height: 20rpx;
  110. height: 10rpx;
  111. //background: linear-gradient(to right bottom, rgba(255, 255, 255, 0.4), transparent) var(--bg, #EA3447);
  112. background-blend-mode: soft-light;
  113. img{
  114. height: 74rpx;
  115. width: 240rpx;
  116. }
  117. }
  118. .background{
  119. padding-bottom: 30px;
  120. }
  121. .banner{
  122. margin: 24rpx;
  123. }
  124. </style>