topic.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <view v-if="activityData.length > 0" :style="'margin-top:'+mbConfig+'rpx;'" class="skeleton-rect">
  3. <view class="activity_count" :style="'background:'+bgColor+';margin: 0 '+prConfig+'rpx;border-radius:'+bgStyle+'rpx'">
  4. <view class="spike-bd">
  5. <view class="title">
  6. <image class="title-img" src="/static/images/topic_title.png"></image>
  7. </view>
  8. <navigator :url="merId ? '/pages/store/home/index?id='+merId+'&type=4' : '/pages/activity/topic/index'" class="more-btn" hover-class="none">
  9. 进入专题
  10. <text class="iconfont icon-jiantou" hover-class="none"></text>
  11. </navigator>
  12. </view>
  13. <view v-if="activityData.length">
  14. <!-- 单图模式 -->
  15. <block v-if="activityData.length == 1">
  16. <view class="topic_swiper"
  17. v-for="(item,index) in activityData"
  18. :key="index"
  19. @click="goTopicDetail(item.info[1].value)">
  20. <image :src="item.img"></image>
  21. </view>
  22. </block>
  23. <view v-else class="topic_swiper" :class="[pointerStyle?'circular':'square',conStyle?'':'fillet','dot'+txtStyle]">
  24. <swiper indicator-dots="true" :autoplay="autoplay" :circular="true" :interval="2500" :duration="duration"
  25. indicator-color="rgba(255,255,255,0.6)" indicator-active-color="rgba(233, 51, 35, 1)">
  26. <block v-for="(item,index) in activityData" :key="index">
  27. <swiper-item>
  28. <view @click="goTopicDetail(item.info[1].value)" class='slide-navigator acea-row row-between-wrapper'>
  29. <image :src="item.img" class="slide-image"></image>
  30. </view>
  31. </swiper-item>
  32. </block>
  33. </swiper>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. export default {
  41. name: 'topic',
  42. props: {
  43. dataConfig: {
  44. type: Object,
  45. default: () => {}
  46. },
  47. merId: {
  48. type: String || Number,
  49. default: ''
  50. }
  51. },
  52. data() {
  53. return {
  54. indicatorDots: false,
  55. autoplay: true,
  56. duration: 500,
  57. activityData: this.dataConfig.menuConfig.list,
  58. bgColor: this.dataConfig.colorShow.val ? this.dataConfig.bgColor.color[0].item : 'transparent',
  59. mbConfig: this.dataConfig.mbConfig.val*2, //页面间距
  60. prConfig: this.dataConfig.prConfig.val*2, //背景间距
  61. txtStyle: this.dataConfig.txtStyle.type,
  62. bgStyle: this.dataConfig.bgStyle.type ? 20 : 0,
  63. colorShow: this.dataConfig.colorShow.val,
  64. pointerStyle: this.dataConfig.pointerStyle.type, //指示点样式
  65. conStyle: this.dataConfig.conStyle.type, //内容样式
  66. };
  67. },
  68. created() {},
  69. mounted() {
  70. console.log(this.dataConfig)
  71. console.log(this.activityData)
  72. },
  73. methods: {
  74. goTopicDetail(url) {
  75. if(url.indexOf("http") != -1){
  76. // #ifdef H5
  77. location.href = url
  78. // #endif
  79. }else{
  80. if(['/pages/goods_cate/goods_cate','/pages/order_addcart/order_addcart','/pages/user/index'].indexOf(url) == -1){
  81. uni.navigateTo({
  82. url:url
  83. })
  84. }else{
  85. uni.switchTab({
  86. url:url
  87. })
  88. }
  89. }
  90. }
  91. }
  92. }
  93. </script>
  94. <style lang="scss">
  95. @import '../style/main.scss';
  96. .activity_count{
  97. margin-bottom: 20rpx;
  98. background: #ffffff;
  99. border-radius: 16rpx;
  100. position: relative;
  101. padding: 24rpx 20rpx 26rpx;
  102. /deep/swiper-item,uni-swiper-item,swiper{
  103. height: 278rpx;
  104. }
  105. /deep/uni-image,/deep/image,/deep/.easy-loadimage{
  106. width: 650rpx;
  107. height: 278rpx;
  108. border-radius: 16rpx;
  109. }
  110. /deep/.uni-swiper-wrapper{
  111. overflow: hidden;
  112. }
  113. }
  114. .topic_swiper{
  115. width: 650rpx;
  116. margin: 0 auto;
  117. line-height: 0;
  118. &.fillet {
  119. border-radius: 0;
  120. /deep/uni-image,/deep/image,/deep/.easy-loadimage{
  121. border-radius: 0;
  122. }
  123. }
  124. // 圆形指示点
  125. &.circular {
  126. /deep/.uni-swiper-dot {
  127. width: 10rpx;
  128. height: 10rpx;
  129. background: rgba(0, 0, 0, .4);
  130. }
  131. /deep/.uni-swiper-dot-active {
  132. background: rgba(233, 51, 35, 1);
  133. }
  134. }
  135. // 方形指示点
  136. &.square {
  137. /deep/.uni-swiper-dot {
  138. width: 20rpx;
  139. height: 5rpx;
  140. border-radius: 3rpx;
  141. background: rgba(0, 0, 0, .4);
  142. }
  143. /deep/.uni-swiper-dot-active {
  144. background: rgba(233, 51, 35, 1);
  145. }
  146. }
  147. }
  148. /deep/.dot0 .uni-swiper-dots-horizontal{
  149. left: 10%;
  150. }
  151. /deep/.dot1 .uni-swiper-dots-horizontal{
  152. left: 50%;
  153. }
  154. /deep/.dot2 .uni-swiper-dots-horizontal{
  155. left: 90%;
  156. }
  157. </style>