templateB.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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: 6,
  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. this.$api.getStorage().then(resolve => {
  70. this.shopId = resolve.shopId ? resolve.shopId : 0
  71. })
  72. while(data.floorImageList.length > 0){
  73. this.productList.push(data.floorImageList.splice(0,this.pageSize))
  74. }
  75. },
  76. swiperChange(e) {
  77. //轮播切换
  78. const index = e.detail.current
  79. this.swiperCurrent = index
  80. },
  81. navigaitionTo(item){
  82. console.log(item);
  83. if(item.link){
  84. uni.navigateTo({
  85. url:`/h5/pages/article/path?link=${item.link}`
  86. })
  87. }
  88. }
  89. }
  90. }
  91. </script>
  92. <style lang="scss">
  93. .section_page_main {
  94. width: 100%;
  95. height: auto;
  96. box-sizing: border-box;
  97. .recommend-list {
  98. width: 100%;
  99. height: 380rpx;
  100. position: relative;
  101. padding-bottom: 20rpx;
  102. .tui-banner-swiper {
  103. width: 100%;
  104. margin: 0 auto;
  105. background: #f7f7f7;
  106. height: 330rpx;
  107. overflow: hidden;
  108. transform: translateY(0);
  109. .img-box {
  110. width: 224rpx;
  111. height: 156rpx;
  112. float: left;
  113. margin: 15rpx 15rpx 0 0;
  114. overflow: hidden;
  115. border-radius: 8rpx;
  116. image {
  117. width: 224rpx;
  118. height: 156rpx;
  119. }
  120. &:nth-child(3n) {
  121. margin-right: 0;
  122. }
  123. &:nth-child(1),
  124. &:nth-child(2),
  125. &:nth-child(3) {
  126. margin-top: 0;
  127. }
  128. }
  129. }
  130. }
  131. .swiper__recommenddots-box {
  132. position: absolute;
  133. bottom: 0;
  134. left: 0;
  135. right: 0;
  136. /* #ifndef APP-NVUE */
  137. display: flex;
  138. /* #endif */
  139. flex: 1;
  140. flex-direction: row;
  141. justify-content: center;
  142. align-items: center;
  143. height: 60rpx;
  144. .swiper__dots-item {
  145. width: 8rpx;
  146. height: 8rpx;
  147. border-radius: 100%;
  148. margin-left: 6px;
  149. background-color: rgba(225, 86, 22, 0.3);
  150. }
  151. .swiper__dots-long {
  152. width: 32rpx;
  153. height: 8rpx;
  154. border-radius: 4rpx;
  155. background-color: #e15616;
  156. transition: all 0.4s;
  157. }
  158. }
  159. }
  160. </style>