templateE.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <view class="section_page_main clearfix">
  3. <view class="recommend-list">
  4. <swiper
  5. class="tui-banner-swiper"
  6. :autoplay="true"
  7. :interval="5000"
  8. :duration="500"
  9. :circular="true"
  10. @change="swiperChange"
  11. >
  12. <swiper-item class="clearfix" v-for="(list,index1) in productList" :key="index1">
  13. <view class="img-box" v-for="(product,index2) in list" :key="index2" @click="navigaitionTo(product)">
  14. <image :src="product.adsImage" mode="aspectFill"></image>
  15. </view>
  16. </swiper-item>
  17. </swiper>
  18. <view class="swiper__recommenddots-box" v-if="productList.length > 1">
  19. <view
  20. v-for="(item, idx) in productList"
  21. :key="idx"
  22. :class="[idx === swiperCurrent ? 'swiper__dots-long' : 'none']"
  23. :data-index="swiperCurrent"
  24. class="swiper__dots-item"
  25. >
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. import { mapState, mapMutations } from 'vuex'
  33. import uniGrader from '@/components/uni-grade/uni-grade.vue'
  34. export default {
  35. name: 'templateH',
  36. components: {
  37. uniGrader
  38. },
  39. props: {
  40. pageData: {
  41. type: Object
  42. },
  43. userIdentity: {
  44. type: Number
  45. }
  46. },
  47. data() {
  48. return {
  49. productList: [],
  50. swiperCurrent: 0,
  51. pageSize: 4
  52. }
  53. },
  54. created() {
  55. this.initData(this.pageData)
  56. },
  57. watch: {
  58. pageData: {
  59. handler: function(el) {
  60. //监听对象的变换使用 function,箭头函数容易出现this指向不正确
  61. this.pageData = el
  62. this.initData(this.pageData)
  63. },
  64. deep: true
  65. }
  66. },
  67. methods: {
  68. initData(data) {
  69. while(data.floorImageList.length > 0){
  70. this.productList.push(data.floorImageList.splice(0,this.pageSize))
  71. }
  72. },
  73. swiperChange(e) {
  74. //轮播切换
  75. const index = e.detail.current
  76. this.swiperCurrent = index
  77. },
  78. navigaitionTo(item){
  79. console.log(item);
  80. if(item.link){
  81. uni.navigateTo({
  82. url:`/h5/pages/article/path?link=${item.link}`
  83. })
  84. }
  85. }
  86. }
  87. }
  88. </script>
  89. <style lang="scss">
  90. .section_page_main {
  91. width: 100%;
  92. height: auto;
  93. box-sizing: border-box;
  94. .recommend-list {
  95. width: 100%;
  96. height: 500rpx;
  97. position: relative;
  98. padding-bottom: 20rpx;
  99. .tui-banner-swiper {
  100. width: 100%;
  101. margin: 0 auto;
  102. background: #f7f7f7;
  103. height: 445rpx;
  104. overflow: hidden;
  105. transform: translateY(0);
  106. .img-box {
  107. width: 339rpx;
  108. height: 210rpx;
  109. float: left;
  110. margin: 24rpx 24rpx 0 0;
  111. overflow: hidden;
  112. border-radius: 16rpx;
  113. image {
  114. width: 339rpx;
  115. height: 210rpx;
  116. }
  117. &:nth-child(2n) {
  118. margin-right: 0;
  119. }
  120. &:nth-child(1),
  121. &:nth-child(2) {
  122. margin-top: 0;
  123. }
  124. }
  125. }
  126. }
  127. .swiper__recommenddots-box {
  128. position: absolute;
  129. bottom: 0;
  130. left: 0;
  131. right: 0;
  132. /* #ifndef APP-NVUE */
  133. display: flex;
  134. /* #endif */
  135. flex: 1;
  136. flex-direction: row;
  137. justify-content: center;
  138. align-items: center;
  139. height: 60rpx;
  140. .swiper__dots-item {
  141. width: 8rpx;
  142. height: 8rpx;
  143. border-radius: 100%;
  144. margin-left: 6px;
  145. background-color: rgba(225, 86, 22, 0.3);
  146. }
  147. .swiper__dots-long {
  148. width: 32rpx;
  149. height: 8rpx;
  150. border-radius: 4rpx;
  151. background-color: #e15616;
  152. transition: all 0.4s;
  153. }
  154. }
  155. }
  156. </style>