templateL.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <view class="section_page_main clearfix">
  3. <view class="recommend-list">
  4. <cm-simple-swiper
  5. @change="onChange"
  6. :current="current"
  7. :circular="true"
  8. :swiperHeight="1120"
  9. :indicatorDots="true"
  10. :indicatorColor="'rgba(255, 255, 255, 0.39)'"
  11. :indicator-active-color="'#FFFFFF'"
  12. :data="productList"
  13. :columns="2"
  14. :rows="swiperRows"
  15. :gapY="12"
  16. :gapX="12"
  17. :autoFill="true"
  18. :autoplay="autoplay"
  19. padding="0 10rpx"
  20. >
  21. <template v-slot:slide="{ row }">
  22. <template-product :data="row.product"></template-product>
  23. </template>
  24. </cm-simple-swiper>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import { mapState, mapMutations } from 'vuex'
  30. import CmSimpleSwiper from '@/components/cm-simple-swiper/cm-simple-swiper.vue'
  31. import TemplateProduct from '@/components/cm-module/pageTemplate/template-product.vue'
  32. export default {
  33. name: 'templateH',
  34. components: {
  35. CmSimpleSwiper,
  36. TemplateProduct
  37. },
  38. props: {
  39. pageData: {
  40. type: Object
  41. },
  42. userIdentity: {
  43. type: Number
  44. },
  45. autoplay: {
  46. type: Boolean,
  47. default: true
  48. },
  49. },
  50. data() {
  51. return {
  52. shopId: 0,
  53. productList: [],
  54. current: 0,
  55. swiperCurrent: 0,
  56. pageSize: 4,
  57. productCount: 0
  58. }
  59. },
  60. created() {
  61. this.initData(this.pageData)
  62. },
  63. computed: {
  64. swiperRows() {
  65. return this.productList.length === 1 ? 1 : 2
  66. },
  67. swiperHeight() {
  68. return 516 * this.swiperRows
  69. }
  70. },
  71. watch: {
  72. pageData: {
  73. handler: function(el) {
  74. //监听对象的变换使用 function,箭头函数容易出现this指向不正确
  75. this.pageData = el
  76. this.initData(this.pageData)
  77. },
  78. deep: true
  79. }
  80. },
  81. methods: {
  82. async initData(data) {
  83. const userInfo = await this.$api.getStorage()
  84. this.shopId = userInfo.shopId ? userInfo.shopId : 0
  85. this.productList = data.floorImageList4
  86. // if (this.productCount > 0) {
  87. // this.productList.splice(0, this.productList.length)
  88. // for (var i = 0, j = data.floorImageList4.length; i < j; i += this.pageSize) {
  89. // this.productList.push(data.floorImageList4.slice(i, i + this.pageSize))
  90. // }
  91. // }
  92. },
  93. onChange(e) {
  94. this.current = e.current
  95. },
  96. }
  97. }
  98. </script>
  99. <style lang="scss">
  100. .section_hot {
  101. width: 100%;
  102. height: 1290rpx;
  103. background: url(https://static.caimei365.com/app/img/hot/hot-bg.png);
  104. background-size: cover;
  105. box-sizing: border-box;
  106. padding: 0 24rpx;
  107. float: left;
  108. }
  109. .tui-group-name {
  110. width: 100%;
  111. height: 165rpx;
  112. box-sizing: border-box;
  113. padding: 40rpx 0 20rpx 0;
  114. position: relative;
  115. .tui-group-r {
  116. width: 144rpx;
  117. height: 54rpx;
  118. background: url(https://static.caimei365.com/app/img/hot/hot-bt@2x.png);
  119. background-size: cover;
  120. position: absolute;
  121. right: 16rpx;
  122. top: 69rpx;
  123. }
  124. }
  125. .tui-group-title {
  126. width: 100%;
  127. height: 50rpx;
  128. line-height: 50rpx;
  129. float: left;
  130. .tui-group-l {
  131. float: left;
  132. font-size: 38rpx;
  133. font-weight: bold;
  134. text-align: left;
  135. color: #ffffff;
  136. }
  137. }
  138. .tui-sub__desc {
  139. width: 100%;
  140. float: left;
  141. line-height: 50rpx;
  142. color: #ffffff;
  143. font-size: $font-size-28;
  144. }
  145. .section_page_main {
  146. width: 100%;
  147. height: auto;
  148. box-sizing: border-box;
  149. .recommend-list {
  150. width: 100%;
  151. height: 1100rpx;
  152. position: relative;
  153. padding-bottom: 20rpx;
  154. .tui-banner-swiper {
  155. width: 100%;
  156. margin: 0 auto;
  157. height: 1100rpx;
  158. overflow: hidden;
  159. transform: translateY(0);
  160. }
  161. }
  162. .swiper__recommenddots-box {
  163. position: absolute;
  164. bottom: 0;
  165. left: 0;
  166. right: 0;
  167. /* #ifndef APP-NVUE */
  168. display: flex;
  169. /* #endif */
  170. flex: 1;
  171. flex-direction: row;
  172. justify-content: center;
  173. align-items: center;
  174. height: 60rpx;
  175. .swiper__dots-item {
  176. width: 8rpx;
  177. height: 8rpx;
  178. border-radius: 100%;
  179. margin-left: 6px;
  180. background-color: #ffffff;
  181. }
  182. .swiper__dots-long {
  183. width: 32rpx;
  184. height: 8rpx;
  185. border-radius: 4rpx;
  186. background-color: #ffffff;
  187. transition: all 0.4s;
  188. }
  189. }
  190. }
  191. </style>