templateE.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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: 'templateH',
  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. this.imageCount = data.floorImageList.length
  83. while (data.floorImageList.length > 0) {
  84. this.productList.push(data.floorImageList.splice(0, this.pageSize))
  85. }
  86. },
  87. swiperChange(e) {
  88. //轮播切换
  89. const index = e.detail.current
  90. this.swiperCurrent = index
  91. },
  92. navigaitionTo(item) {
  93. if (item.adsImage === '' && item.linkType === -1) {
  94. return
  95. } else if (item.linkType === -1) {
  96. uni.navigateTo({
  97. url: `/pages/h5/activity/activity-detail?adsImage=${item.adsImage}&title=${item.name}`
  98. })
  99. } else {
  100. caimeiApi.FlooryNavigateTo(item)
  101. }
  102. }
  103. }
  104. }
  105. </script>
  106. <style lang="scss">
  107. .section_page_main {
  108. width: 100%;
  109. height: auto;
  110. box-sizing: border-box;
  111. .recommend-list {
  112. width: 100%;
  113. height: 500rpx;
  114. position: relative;
  115. padding-bottom: 20rpx;
  116. .tui-banner-swiper {
  117. width: 100%;
  118. margin: 0 auto;
  119. background: #f7f7f7;
  120. height: 445rpx;
  121. overflow: hidden;
  122. transform: translateY(0);
  123. .img-box {
  124. position: relative;
  125. width: 339rpx;
  126. height: 210rpx;
  127. float: left;
  128. margin: 24rpx 24rpx 0 0;
  129. overflow: hidden;
  130. border-radius: 16rpx;
  131. image {
  132. width: 339rpx;
  133. height: 210rpx;
  134. }
  135. &:nth-child(2n) {
  136. margin-right: 0;
  137. }
  138. &:nth-child(1) {
  139. margin-top: 0;
  140. }
  141. .cm-cover {
  142. z-index: 99;
  143. top: 0;
  144. left: 0;
  145. position: absolute;
  146. width: 100%;
  147. height: 100%;
  148. background: url(https://static.caimei365.com/app/img/icon2/cm_player.png) no-repeat center;
  149. background-size: 40rpx 40rpx;
  150. }
  151. }
  152. }
  153. }
  154. .swiper__recommenddots-box {
  155. position: absolute;
  156. bottom: 0;
  157. left: 0;
  158. right: 0;
  159. /* #ifndef APP-NVUE */
  160. display: flex;
  161. /* #endif */
  162. flex: 1;
  163. flex-direction: row;
  164. justify-content: center;
  165. align-items: center;
  166. height: 60rpx;
  167. .swiper__dots-item {
  168. width: 8rpx;
  169. height: 8rpx;
  170. border-radius: 100%;
  171. margin-left: 6px;
  172. background-color: rgba(225, 86, 22, 0.3);
  173. }
  174. .swiper__dots-long {
  175. width: 32rpx;
  176. height: 8rpx;
  177. border-radius: 4rpx;
  178. background-color: #e15616;
  179. transition: all 0.4s;
  180. }
  181. }
  182. }
  183. </style>