templateE.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. >
  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 class="cm-cover" v-if="pageData.floorContent.templateClassify === 4"></view>
  17. </view>
  18. </swiper-item>
  19. </swiper>
  20. <view class="swiper__recommenddots-box" v-if="productList.length > 1">
  21. <view
  22. v-for="(item, idx) in productList"
  23. :key="idx"
  24. :class="[idx === swiperCurrent ? 'swiper__dots-long' : 'none']"
  25. :data-index="swiperCurrent"
  26. class="swiper__dots-item"
  27. >
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. import { mapState, mapMutations } from 'vuex'
  35. import uniGrader from '@/components/uni-grade/uni-grade.vue'
  36. import caimeiApi from '@/common/config/caimeiApi.js'
  37. export default {
  38. name: 'templateH',
  39. components: {
  40. uniGrader
  41. },
  42. props: {
  43. pageData: {
  44. type: Object
  45. },
  46. userIdentity: {
  47. type: Number
  48. }
  49. },
  50. data() {
  51. return {
  52. productList: [],
  53. swiperCurrent: 0,
  54. pageSize: 4
  55. }
  56. },
  57. created() {
  58. this.initData(this.pageData)
  59. },
  60. computed:{
  61. hasLessImage(){
  62. return this.imageCount <= 2
  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.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:`/pages/h5/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: 500rpx;
  109. position: relative;
  110. padding-bottom: 20rpx;
  111. .tui-banner-swiper {
  112. width: 100%;
  113. margin: 0 auto;
  114. background: #f7f7f7;
  115. height: 445rpx;
  116. overflow: hidden;
  117. transform: translateY(0);
  118. .img-box {
  119. position: relative;
  120. width: 339rpx;
  121. height: 210rpx;
  122. float: left;
  123. margin: 24rpx 24rpx 0 0;
  124. overflow: hidden;
  125. border-radius: 16rpx;
  126. image {
  127. width: 339rpx;
  128. height: 210rpx;
  129. }
  130. &:nth-child(2n) {
  131. margin-right: 0;
  132. }
  133. &:nth-child(1),
  134. &:nth-child(2) {
  135. margin-top: 0;
  136. }
  137. .cm-cover{
  138. z-index: 99;
  139. top: 0;
  140. left: 0;
  141. position: absolute;
  142. width: 100%;
  143. height: 100%;
  144. background: url(https://static.caimei365.com/app/img/icon2/cm_player.png) no-repeat center;
  145. background-size: 40rpx 40rpx;
  146. }
  147. }
  148. }
  149. }
  150. .swiper__recommenddots-box {
  151. position: absolute;
  152. bottom: 0;
  153. left: 0;
  154. right: 0;
  155. /* #ifndef APP-NVUE */
  156. display: flex;
  157. /* #endif */
  158. flex: 1;
  159. flex-direction: row;
  160. justify-content: center;
  161. align-items: center;
  162. height: 60rpx;
  163. .swiper__dots-item {
  164. width: 8rpx;
  165. height: 8rpx;
  166. border-radius: 100%;
  167. margin-left: 6px;
  168. background-color: rgba(225, 86, 22, 0.3);
  169. }
  170. .swiper__dots-long {
  171. width: 32rpx;
  172. height: 8rpx;
  173. border-radius: 4rpx;
  174. background-color: #e15616;
  175. transition: all 0.4s;
  176. }
  177. }
  178. }
  179. </style>