templateE.vue 3.3 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.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. }else if(item.linkType === -1){
  83. uni.navigateTo({
  84. url:`/h5/pages/activity/activity-detail?adsImage=${item.adsImage}&title=${item.name}`
  85. })
  86. }else{
  87. caimeiApi.FlooryNavigateTo(item)
  88. }
  89. }
  90. }
  91. }
  92. </script>
  93. <style lang="scss">
  94. .section_page_main {
  95. width: 100%;
  96. height: auto;
  97. box-sizing: border-box;
  98. .recommend-list {
  99. width: 100%;
  100. height: 500rpx;
  101. position: relative;
  102. padding-bottom: 20rpx;
  103. .tui-banner-swiper {
  104. width: 100%;
  105. margin: 0 auto;
  106. background: #f7f7f7;
  107. height: 445rpx;
  108. overflow: hidden;
  109. transform: translateY(0);
  110. .img-box {
  111. width: 339rpx;
  112. height: 210rpx;
  113. float: left;
  114. margin: 24rpx 24rpx 0 0;
  115. overflow: hidden;
  116. border-radius: 16rpx;
  117. image {
  118. width: 339rpx;
  119. height: 210rpx;
  120. }
  121. &:nth-child(2n) {
  122. margin-right: 0;
  123. }
  124. &:nth-child(1),
  125. &:nth-child(2) {
  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>