templateA.vue 5.2 KB

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