templateB.vue 3.6 KB

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