templateE.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <template>
  2. <view class="section_page_main clearfix">
  3. <view class="recommend-list">
  4. <swiper
  5. class="tui-banner-swiper"
  6. :autoplay="true"
  7. :interval="5000"
  8. :duration="500"
  9. :circular="true"
  10. @change="swiperChange"
  11. >
  12. <swiper-item class="clearfix">
  13. <view class="img-box">
  14. <image :src="testImgUrl" mode="aspectFill"></image>
  15. </view>
  16. <view class="img-box">
  17. <image :src="testImgUrl" mode="aspectFill"></image>
  18. </view>
  19. <view class="img-box">
  20. <image :src="testImgUrl" mode="aspectFill"></image>
  21. </view>
  22. <view class="img-box">
  23. <image :src="testImgUrl" mode="aspectFill"></image>
  24. </view>
  25. </swiper-item>
  26. <swiper-item class="clearfix">
  27. <view class="img-box">
  28. <image :src="testImgUrl" mode="aspectFill"></image>
  29. </view>
  30. <view class="img-box">
  31. <image :src="testImgUrl" mode="aspectFill"></image>
  32. </view>
  33. <view class="img-box">
  34. <image :src="testImgUrl" mode="aspectFill"></image>
  35. </view>
  36. <view class="img-box">
  37. <image :src="testImgUrl" mode="aspectFill"></image>
  38. </view>
  39. </swiper-item>
  40. </swiper>
  41. <view class="swiper__recommenddots-box" v-if="productList.length > 1">
  42. <view
  43. v-for="(item, idx) in productList"
  44. :key="idx"
  45. :class="[idx === swiperCurrent ? 'swiper__dots-long' : 'none']"
  46. :data-index="swiperCurrent"
  47. class="swiper__dots-item"
  48. >
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. import { mapState, mapMutations } from 'vuex'
  56. import uniGrader from '@/components/uni-grade/uni-grade.vue'
  57. export default {
  58. name: 'templateH',
  59. components: {
  60. uniGrader
  61. },
  62. props: {
  63. pageData: {
  64. type: Object
  65. },
  66. userIdentity: {
  67. type: Number
  68. }
  69. },
  70. data() {
  71. return {
  72. shopId: 0,
  73. productList: [1, 2],
  74. current: 100,
  75. swiperCurrent: 0,
  76. pageSize: 4,
  77. testImgUrl:
  78. 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-3ad36ff8-4f90-4748-8ad3-ca265841c862/8df647e0-69c4-4ea5-ac2f-648218096656.jpg'
  79. }
  80. },
  81. filters: {
  82. NumFormat: function(text) {
  83. //处理金额
  84. return Number(text).toFixed(2)
  85. }
  86. },
  87. created() {
  88. // this.initData(this.pageData)
  89. },
  90. watch: {
  91. pageData: {
  92. handler: function(el) {
  93. //监听对象的变换使用 function,箭头函数容易出现this指向不正确
  94. this.pageData = el
  95. this.initData(this.pageData)
  96. },
  97. deep: true
  98. }
  99. },
  100. methods: {
  101. initData(data) {
  102. this.$api.getStorage().then(resolve => {
  103. this.shopId = resolve.shopId ? resolve.shopId : 0
  104. })
  105. if (data.floorImageList.length > 0) {
  106. this.productList.splice(0, this.productList.length)
  107. for (var i = 0, j = data.floorImageList.length; i < j; i += this.pageSize) {
  108. this.productList.push(data.floorImageList.slice(i, i + this.pageSize))
  109. }
  110. }
  111. },
  112. PromotionsFormat(promo) {
  113. //促销活动类型数据处理
  114. if (promo != null) {
  115. if (promo.type == 1 && promo.mode == 1) {
  116. return true
  117. } else {
  118. return false
  119. }
  120. }
  121. return false
  122. },
  123. tabClick(index) {
  124. //轮播图切换
  125. this.current = index
  126. },
  127. swiperChange(e) {
  128. //轮播切换
  129. const index = e.detail.current
  130. this.swiperCurrent = index
  131. },
  132. navToDetailPage(pros) {
  133. //跳转商品详情页
  134. this.$api.FlooryNavigateTo(pros)
  135. }
  136. }
  137. }
  138. </script>
  139. <style lang="scss">
  140. .section_page_main {
  141. width: 100%;
  142. height: auto;
  143. box-sizing: border-box;
  144. .recommend-list {
  145. width: 100%;
  146. height: 500rpx;
  147. position: relative;
  148. padding-bottom: 20rpx;
  149. .tui-banner-swiper {
  150. width: 100%;
  151. margin: 0 auto;
  152. background: #f7f7f7;
  153. height: 445rpx;
  154. overflow: hidden;
  155. transform: translateY(0);
  156. .img-box {
  157. width: 339rpx;
  158. height: 210rpx;
  159. float: left;
  160. margin: 24rpx 24rpx 0 0;
  161. overflow: hidden;
  162. border-radius: 16rpx;
  163. image {
  164. width: 339rpx;
  165. height: 210rpx;
  166. }
  167. &:nth-child(2n) {
  168. margin-right: 0;
  169. }
  170. &:nth-child(1),
  171. &:nth-child(2) {
  172. margin-top: 0;
  173. }
  174. }
  175. }
  176. }
  177. .swiper__recommenddots-box {
  178. position: absolute;
  179. bottom: 0;
  180. left: 0;
  181. right: 0;
  182. /* #ifndef APP-NVUE */
  183. display: flex;
  184. /* #endif */
  185. flex: 1;
  186. flex-direction: row;
  187. justify-content: center;
  188. align-items: center;
  189. height: 60rpx;
  190. .swiper__dots-item {
  191. width: 8rpx;
  192. height: 8rpx;
  193. border-radius: 100%;
  194. margin-left: 6px;
  195. background-color: rgba(225, 86, 22, 0.3);
  196. }
  197. .swiper__dots-long {
  198. width: 32rpx;
  199. height: 8rpx;
  200. border-radius: 4rpx;
  201. background-color: #e15616;
  202. transition: all 0.4s;
  203. }
  204. }
  205. }
  206. </style>