templateE.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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.appletsImage" 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. import caimeiApi from '@/common/config/caimeiApi.js'
  35. export default {
  36. name: 'templateH',
  37. components: {
  38. uniGrader
  39. },
  40. props: {
  41. pageData: {
  42. type: Object
  43. },
  44. userIdentity: {
  45. type: Number
  46. }
  47. },
  48. data() {
  49. return {
  50. productList: [],
  51. swiperCurrent: 0,
  52. pageSize: 4
  53. }
  54. },
  55. created() {
  56. this.initData(this.pageData)
  57. },
  58. watch: {
  59. pageData: {
  60. handler: function(el) {
  61. //监听对象的变换使用 function,箭头函数容易出现this指向不正确
  62. this.pageData = el
  63. this.initData(this.pageData)
  64. },
  65. deep: true
  66. }
  67. },
  68. methods: {
  69. initData(data) {
  70. while(data.floorImageList.length > 0){
  71. this.productList.push(data.floorImageList.splice(0,this.pageSize))
  72. }
  73. },
  74. swiperChange(e) {
  75. //轮播切换
  76. const index = e.detail.current
  77. this.swiperCurrent = index
  78. },
  79. navigaitionTo(item){
  80. if (item.adsImage === '' && item.linkType === -1) {
  81. return
  82. }
  83. caimeiApi.FlooryNavigateTo(item)
  84. }
  85. }
  86. }
  87. </script>
  88. <style lang="scss">
  89. .section_page_main {
  90. width: 100%;
  91. height: auto;
  92. box-sizing: border-box;
  93. .recommend-list {
  94. width: 100%;
  95. height: 500rpx;
  96. position: relative;
  97. padding-bottom: 20rpx;
  98. .tui-banner-swiper {
  99. width: 100%;
  100. margin: 0 auto;
  101. background: #f7f7f7;
  102. height: 445rpx;
  103. overflow: hidden;
  104. transform: translateY(0);
  105. .img-box {
  106. width: 339rpx;
  107. height: 210rpx;
  108. float: left;
  109. margin: 24rpx 24rpx 0 0;
  110. overflow: hidden;
  111. border-radius: 16rpx;
  112. image {
  113. width: 339rpx;
  114. height: 210rpx;
  115. }
  116. &:nth-child(2n) {
  117. margin-right: 0;
  118. }
  119. &:nth-child(1),
  120. &:nth-child(2) {
  121. margin-top: 0;
  122. }
  123. }
  124. }
  125. }
  126. .swiper__recommenddots-box {
  127. position: absolute;
  128. bottom: 0;
  129. left: 0;
  130. right: 0;
  131. /* #ifndef APP-NVUE */
  132. display: flex;
  133. /* #endif */
  134. flex: 1;
  135. flex-direction: row;
  136. justify-content: center;
  137. align-items: center;
  138. height: 60rpx;
  139. .swiper__dots-item {
  140. width: 8rpx;
  141. height: 8rpx;
  142. border-radius: 100%;
  143. margin-left: 6px;
  144. background-color: rgba(225, 86, 22, 0.3);
  145. }
  146. .swiper__dots-long {
  147. width: 32rpx;
  148. height: 8rpx;
  149. border-radius: 4rpx;
  150. background-color: #e15616;
  151. transition: all 0.4s;
  152. }
  153. }
  154. }
  155. </style>