mBanner.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <view class="swiperBg">
  3. <view class='boutique' v-if="isShow && bastBanner.length && !isIframe">
  4. <swiper autoplay="true" indicator-dots="true" :circular="circular" :interval="interval" :duration="duration"
  5. indicator-color="rgba(252,65,65,0.3)" indicator-active-color="#fc4141">
  6. <block v-for="(item,index) in bastBanner">
  7. <swiper-item :key='index'>
  8. <view style='width:100%;height:100%;' hover-class='none' @click="goDetail(item)">
  9. <image :src="item.img" class="slide-image" />
  10. </view>
  11. </swiper-item>
  12. </block>
  13. </swiper>
  14. </view>
  15. <view class='boutique' v-if="bastBanner.length && isIframe">
  16. <swiper autoplay="true" indicator-dots="true" :circular="circular" :interval="interval" :duration="duration"
  17. indicator-color="rgba(252,65,65,0.3)" indicator-active-color="#fc4141">
  18. <block v-for="(item,index) in bastBanner">
  19. <swiper-item :key='index'>
  20. <view style='width:100%;height:100%;' hover-class='none' @click="goDetail(item)">
  21. <image :src="item.img" class="slide-image" />
  22. </view>
  23. </swiper-item>
  24. </block>
  25. </swiper>
  26. </view>
  27. <block v-if="isIframe && !bastBanner.length">
  28. <view class="empty-img">暂无图片,请上传图片</view>
  29. </block>
  30. </view>
  31. </template>
  32. <script>
  33. let app = getApp()
  34. import {
  35. goPage
  36. } from '@/libs/order.js'
  37. export default {
  38. name: 'swiperBg',
  39. props: {
  40. dataConfig: {
  41. type: Object,
  42. default: () => {}
  43. }
  44. },
  45. data() {
  46. return {
  47. indicatorDots: false,
  48. circular: true,
  49. autoplay: true,
  50. interval: 3000,
  51. duration: 500,
  52. bastBanner: [], //图片轮播数据
  53. name: this.$options.name,
  54. isIframe: false,
  55. isShow: true
  56. };
  57. },
  58. watch: {
  59. dataConfig: {
  60. immediate: true,
  61. handler(nVal, oVal) {
  62. if(nVal){
  63. this.bastBanner = nVal.imgList.list;
  64. this.isShow = nVal.isShow.val;
  65. }
  66. }
  67. }
  68. },
  69. created() {
  70. this.isIframe = app.globalData.isIframe
  71. },
  72. mounted() {
  73. },
  74. methods: {
  75. //替换安全域名
  76. setDomain: function(url) {
  77. url = url ? url.toString() : '';
  78. //本地调试打开,生产请注销
  79. if (url.indexOf("https://") > -1) return url;
  80. else return url.replace('http://', 'https://');
  81. },
  82. goDetail(url) {
  83. goPage().then(res => {
  84. console.log('hhhhhh',url);
  85. let urls = url.info[1].value
  86. if (urls.indexOf("http") != -1) {
  87. // #ifdef H5
  88. location.href = urls
  89. // #endif
  90. } else {
  91. if (['/pages/goods_cate/goods_cate', '/pages/order_addcart/order_addcart', '/pages/user/index'].indexOf(urls) ==
  92. -1) {
  93. uni.navigateTo({
  94. url: urls
  95. })
  96. } else {
  97. uni.navigateTo({
  98. url: urls
  99. })
  100. }
  101. }
  102. })
  103. }
  104. }
  105. }
  106. </script>
  107. <style lang="scss">
  108. .empty-img {
  109. width: 690rpx;
  110. height: 300rpx;
  111. border-radius: 14rpx;
  112. margin: 26rpx auto 0 auto;
  113. background-color: #ccc;
  114. text-align: center;
  115. line-height: 300rpx;
  116. .iconfont{
  117. font-size: 50rpx;
  118. }
  119. }
  120. .boutique {
  121. width: 690rpx;
  122. height: 300rpx;
  123. margin: 28rpx auto 0 auto;
  124. }
  125. .boutique swiper {
  126. width: 100%;
  127. height: 100%;
  128. position: relative;
  129. }
  130. .boutique image {
  131. width: 100%;
  132. height: 260rpx;
  133. }
  134. .boutique .wx-swiper-dot {
  135. width: 7rpx;
  136. height: 7rpx;
  137. border-radius: 50%;
  138. }
  139. .boutique .wx-swiper-dot-active {
  140. width: 20rpx;
  141. border-radius: 5rpx;
  142. }
  143. .boutique .wx-swiper-dots.wx-swiper-dots-horizontal {
  144. margin-bottom: -8rpx;
  145. }
  146. </style>