templateL.vue 3.7 KB

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