templateE.vue 5.5 KB

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