templateA.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <view class="section_page_main clearfix">
  3. <view class="recommend-list" :style="hasLessImage?'height:82px':''">
  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:82px':''"
  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: 8,
  54. imageCount:0
  55. }
  56. },
  57. created() {
  58. this.initData(this.pageData)
  59. },
  60. watch: {
  61. pageData: {
  62. handler: function(el) {
  63. //监听对象的变换使用 function,箭头函数容易出现this指向不正确
  64. this.pageData = el
  65. this.initData(this.pageData)
  66. },
  67. deep: true
  68. }
  69. },
  70. computed:{
  71. hasLessImage(){
  72. return this.imageCount <= 4
  73. }
  74. },
  75. methods: {
  76. initData(data) {
  77. this.imageCount = data.floorImageList.length
  78. while(data.floorImageList.length > 0){
  79. this.productList.push(data.floorImageList.splice(0,this.pageSize))
  80. }
  81. },
  82. swiperChange(e) {
  83. //轮播切换
  84. const index = e.detail.current
  85. this.swiperCurrent = index
  86. },
  87. navigaitionTo(item){
  88. if (item.adsImage === '' && item.linkType === -1) {
  89. return
  90. }else if(item.linkType === -1){
  91. uni.navigateTo({
  92. url:`/h5/pages/activity/activity-detail?adsImage=${item.adsImage}&title=${item.name}`
  93. })
  94. }else{
  95. caimeiApi.FlooryNavigateTo(item)
  96. }
  97. }
  98. }
  99. }
  100. </script>
  101. <style lang="scss">
  102. .section_page_main {
  103. width: 100%;
  104. height: auto;
  105. box-sizing: border-box;
  106. .recommend-list {
  107. width: 100%;
  108. height: 390rpx;
  109. position: relative;
  110. padding-bottom: 20rpx;
  111. .tui-banner-swiper {
  112. width: 100%;
  113. margin: 0 auto;
  114. background: #f7f7f7;
  115. height: 350rpx;
  116. overflow: hidden;
  117. transform: translateY(0);
  118. .img-box {
  119. width: 164rpx;
  120. height: 164rpx;
  121. float: left;
  122. margin: 15rpx 15rpx 0 0;
  123. overflow: hidden;
  124. border-radius: 8rpx;
  125. image {
  126. width: 164rpx;
  127. height: 164rpx;
  128. }
  129. &:nth-child(4n) {
  130. margin-right: 0;
  131. }
  132. &:nth-child(1),
  133. &:nth-child(2),
  134. &:nth-child(3),
  135. &:nth-child(4) {
  136. margin-top: 0;
  137. }
  138. }
  139. }
  140. }
  141. .swiper__recommenddots-box {
  142. position: absolute;
  143. bottom: 0;
  144. left: 0;
  145. right: 0;
  146. /* #ifndef APP-NVUE */
  147. display: flex;
  148. /* #endif */
  149. flex: 1;
  150. flex-direction: row;
  151. justify-content: center;
  152. align-items: center;
  153. height: 60rpx;
  154. .swiper__dots-item {
  155. width: 8rpx;
  156. height: 8rpx;
  157. border-radius: 100%;
  158. margin-left: 6px;
  159. background-color: rgba(225, 86, 22, 0.3);
  160. }
  161. .swiper__dots-long {
  162. width: 32rpx;
  163. height: 8rpx;
  164. border-radius: 4rpx;
  165. background-color: #e15616;
  166. transition: all 0.4s;
  167. }
  168. }
  169. }
  170. </style>