templateE.vue 3.5 KB

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