templateL.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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. console.log('==========',this.productList)
  87. // if (this.productCount > 0) {
  88. // this.productList.splice(0, this.productList.length)
  89. // for (var i = 0, j = data.floorImageList4.length; i < j; i += this.pageSize) {
  90. // this.productList.push(data.floorImageList4.slice(i, i + this.pageSize))
  91. // }
  92. // }
  93. },
  94. onChange(e) {
  95. this.current = e.current
  96. },
  97. }
  98. }
  99. </script>
  100. <style lang="scss">
  101. .section_hot {
  102. width: 100%;
  103. height: 1290rpx;
  104. background: url(https://static.caimei365.com/app/img/hot/hot-bg.png);
  105. background-size: cover;
  106. box-sizing: border-box;
  107. padding: 0 24rpx;
  108. float: left;
  109. }
  110. .tui-group-name {
  111. width: 100%;
  112. height: 165rpx;
  113. box-sizing: border-box;
  114. padding: 40rpx 0 20rpx 0;
  115. position: relative;
  116. .tui-group-r {
  117. width: 144rpx;
  118. height: 54rpx;
  119. background: url(https://static.caimei365.com/app/img/hot/hot-bt@2x.png);
  120. background-size: cover;
  121. position: absolute;
  122. right: 16rpx;
  123. top: 69rpx;
  124. }
  125. }
  126. .tui-group-title {
  127. width: 100%;
  128. height: 50rpx;
  129. line-height: 50rpx;
  130. float: left;
  131. .tui-group-l {
  132. float: left;
  133. font-size: 38rpx;
  134. font-weight: bold;
  135. text-align: left;
  136. color: #ffffff;
  137. }
  138. }
  139. .tui-sub__desc {
  140. width: 100%;
  141. float: left;
  142. line-height: 50rpx;
  143. color: #ffffff;
  144. font-size: $font-size-28;
  145. }
  146. .section_page_main {
  147. width: 100%;
  148. height: auto;
  149. box-sizing: border-box;
  150. .recommend-list {
  151. width: 100%;
  152. height: 1100rpx;
  153. position: relative;
  154. padding-bottom: 20rpx;
  155. .tui-banner-swiper {
  156. width: 100%;
  157. margin: 0 auto;
  158. height: 1100rpx;
  159. overflow: hidden;
  160. transform: translateY(0);
  161. }
  162. }
  163. .swiper__recommenddots-box {
  164. position: absolute;
  165. bottom: 0;
  166. left: 0;
  167. right: 0;
  168. /* #ifndef APP-NVUE */
  169. display: flex;
  170. /* #endif */
  171. flex: 1;
  172. flex-direction: row;
  173. justify-content: center;
  174. align-items: center;
  175. height: 60rpx;
  176. .swiper__dots-item {
  177. width: 8rpx;
  178. height: 8rpx;
  179. border-radius: 100%;
  180. margin-left: 6px;
  181. background-color: #ffffff;
  182. }
  183. .swiper__dots-long {
  184. width: 32rpx;
  185. height: 8rpx;
  186. border-radius: 4rpx;
  187. background-color: #ffffff;
  188. transition: all 0.4s;
  189. }
  190. }
  191. }
  192. </style>