templateB.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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: 6,
  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. this.$api.getStorage().then(resolve => {
  71. this.shopId = resolve.shopId ? resolve.shopId : 0
  72. })
  73. while(data.floorImageList.length > 0){
  74. this.productList.push(data.floorImageList.splice(0,this.pageSize))
  75. }
  76. },
  77. swiperChange(e) {
  78. //轮播切换
  79. const index = e.detail.current
  80. this.swiperCurrent = index
  81. },
  82. navigaitionTo(item){
  83. if (item.adsImage === '' && item.linkType === -1) {
  84. return
  85. }else if(item.linkType === -1){
  86. uni.navigateTo({
  87. url:`/h5/pages/activity/activity-detail?adsImage=${item.adsImage}&title=${item.name}`
  88. })
  89. }else{
  90. caimeiApi.FlooryNavigateTo(item)
  91. }
  92. }
  93. }
  94. }
  95. </script>
  96. <style lang="scss">
  97. .section_page_main {
  98. width: 100%;
  99. height: auto;
  100. box-sizing: border-box;
  101. .recommend-list {
  102. width: 100%;
  103. height: 380rpx;
  104. position: relative;
  105. padding-bottom: 20rpx;
  106. .tui-banner-swiper {
  107. width: 100%;
  108. margin: 0 auto;
  109. background: #f7f7f7;
  110. height: 330rpx;
  111. overflow: hidden;
  112. transform: translateY(0);
  113. .img-box {
  114. width: 224rpx;
  115. height: 156rpx;
  116. float: left;
  117. margin: 15rpx 15rpx 0 0;
  118. overflow: hidden;
  119. border-radius: 8rpx;
  120. image {
  121. width: 224rpx;
  122. height: 156rpx;
  123. }
  124. &:nth-child(3n) {
  125. margin-right: 0;
  126. }
  127. &:nth-child(1),
  128. &:nth-child(2),
  129. &:nth-child(3) {
  130. margin-top: 0;
  131. }
  132. }
  133. }
  134. }
  135. .swiper__recommenddots-box {
  136. position: absolute;
  137. bottom: 0;
  138. left: 0;
  139. right: 0;
  140. /* #ifndef APP-NVUE */
  141. display: flex;
  142. /* #endif */
  143. flex: 1;
  144. flex-direction: row;
  145. justify-content: center;
  146. align-items: center;
  147. height: 60rpx;
  148. .swiper__dots-item {
  149. width: 8rpx;
  150. height: 8rpx;
  151. border-radius: 100%;
  152. margin-left: 6px;
  153. background-color: rgba(225, 86, 22, 0.3);
  154. }
  155. .swiper__dots-long {
  156. width: 32rpx;
  157. height: 8rpx;
  158. border-radius: 4rpx;
  159. background-color: #e15616;
  160. transition: all 0.4s;
  161. }
  162. }
  163. }
  164. </style>