templateL.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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="true"
  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. },
  46. data() {
  47. return {
  48. shopId: 0,
  49. productList: [],
  50. current: 0,
  51. swiperCurrent: 0,
  52. pageSize: 4,
  53. productCount: 0
  54. }
  55. },
  56. created() {
  57. this.initData(this.pageData)
  58. },
  59. computed: {
  60. swiperRows() {
  61. return this.productList.length === 1 ? 1 : 2
  62. },
  63. swiperHeight() {
  64. return 516 * this.swiperRows
  65. }
  66. },
  67. watch: {
  68. pageData: {
  69. handler: function(el) {
  70. //监听对象的变换使用 function,箭头函数容易出现this指向不正确
  71. this.pageData = el
  72. this.initData(this.pageData)
  73. },
  74. deep: true
  75. }
  76. },
  77. methods: {
  78. async initData(data) {
  79. const userInfo = await this.$api.getStorage()
  80. this.shopId = userInfo.shopId ? userInfo.shopId : 0
  81. this.productList = data.floorImageList4
  82. // if (this.productCount > 0) {
  83. // this.productList.splice(0, this.productList.length)
  84. // for (var i = 0, j = data.floorImageList4.length; i < j; i += this.pageSize) {
  85. // this.productList.push(data.floorImageList4.slice(i, i + this.pageSize))
  86. // }
  87. // }
  88. },
  89. onChange(e) {
  90. this.current = e.current
  91. },
  92. }
  93. }
  94. </script>
  95. <style lang="scss">
  96. .section_hot {
  97. width: 100%;
  98. height: 1290rpx;
  99. background: url(https://static.caimei365.com/app/img/hot/hot-bg.png);
  100. background-size: cover;
  101. box-sizing: border-box;
  102. padding: 0 24rpx;
  103. float: left;
  104. }
  105. .tui-group-name {
  106. width: 100%;
  107. height: 165rpx;
  108. box-sizing: border-box;
  109. padding: 40rpx 0 20rpx 0;
  110. position: relative;
  111. .tui-group-r {
  112. width: 144rpx;
  113. height: 54rpx;
  114. background: url(https://static.caimei365.com/app/img/hot/hot-bt@2x.png);
  115. background-size: cover;
  116. position: absolute;
  117. right: 16rpx;
  118. top: 69rpx;
  119. }
  120. }
  121. .tui-group-title {
  122. width: 100%;
  123. height: 50rpx;
  124. line-height: 50rpx;
  125. float: left;
  126. .tui-group-l {
  127. float: left;
  128. font-size: 38rpx;
  129. font-weight: bold;
  130. text-align: left;
  131. color: #ffffff;
  132. }
  133. }
  134. .tui-sub__desc {
  135. width: 100%;
  136. float: left;
  137. line-height: 50rpx;
  138. color: #ffffff;
  139. font-size: $font-size-28;
  140. }
  141. .section_page_main {
  142. width: 100%;
  143. height: auto;
  144. box-sizing: border-box;
  145. .recommend-list {
  146. width: 100%;
  147. height: 1100rpx;
  148. position: relative;
  149. padding-bottom: 20rpx;
  150. .tui-banner-swiper {
  151. width: 100%;
  152. margin: 0 auto;
  153. height: 1100rpx;
  154. overflow: hidden;
  155. transform: translateY(0);
  156. }
  157. }
  158. .swiper__recommenddots-box {
  159. position: absolute;
  160. bottom: 0;
  161. left: 0;
  162. right: 0;
  163. /* #ifndef APP-NVUE */
  164. display: flex;
  165. /* #endif */
  166. flex: 1;
  167. flex-direction: row;
  168. justify-content: center;
  169. align-items: center;
  170. height: 60rpx;
  171. .swiper__dots-item {
  172. width: 8rpx;
  173. height: 8rpx;
  174. border-radius: 100%;
  175. margin-left: 6px;
  176. background-color: #ffffff;
  177. }
  178. .swiper__dots-long {
  179. width: 32rpx;
  180. height: 8rpx;
  181. border-radius: 4rpx;
  182. background-color: #ffffff;
  183. transition: all 0.4s;
  184. }
  185. }
  186. }
  187. </style>