templateB.vue 4.8 KB

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