templateB.vue 4.1 KB

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