new.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <view class="center">
  3. <view class="top">
  4. <image class="top-bg" src="../../static/img/top-bg.png" mode=""></image>
  5. <view class="title">
  6. 新品
  7. </view>
  8. </view>
  9. <swiper class="carousel" autoplay="true" duration="400" interval="5000" @change="swiperChange">
  10. <swiper-item class="carousel-item" @click="bannerNavToUrl(item)">
  11. <image src="../../static/img/new.png" />
  12. </swiper-item>
  13. </swiper>
  14. <view class="hotgoods" v-if="firstList.length != 0">
  15. <view class="hotgoods-item" v-for="item in firstList" :key="item.id" @click="navToDetailPage(item)">
  16. <view class="image-wrapper">
  17. <image :src="item.image" mode="scaleToFill"></image>
  18. </view>
  19. <view class="title clamp margin-c-20">{{ item.store_name }}</view>
  20. <view class="hot-price">
  21. <view class="price">
  22. <text class="font-size-sm">¥</text>
  23. {{ item.price }}
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <u-tabbar activeColor="#f42b4e" v-model="current" :list="tabbar"></u-tabbar>
  29. </view>
  30. </template>
  31. <script>
  32. import {
  33. tabbar1
  34. } from '@/utils/tabbar.js';
  35. import {
  36. groomList
  37. } from '@/api/product.js';
  38. export default {
  39. data() {
  40. return {
  41. current: 3,
  42. tabbar: tabbar1,
  43. firstList: [],
  44. type: 2,
  45. page: 1,
  46. limit: 20,
  47. loaded: false,
  48. loadingType: 'more'
  49. }
  50. },
  51. onLoad() {
  52. this.loadData()
  53. },
  54. methods: {
  55. loadData() {
  56. let obj = this
  57. if (obj.loadingType == 'loading' || obj.loadingType == 'noMore') {
  58. return
  59. }
  60. obj.loadingType = 'loading'
  61. groomList({
  62. page: obj.page,
  63. limit: obj.limit
  64. }, this.type)
  65. .then(({
  66. data
  67. }) => {
  68. // 保存轮播图
  69. obj.bannerImg = data.banner;
  70. // 保存商品信息
  71. obj.firstList = this.firstList.concat(data.list)
  72. obj.loaded = true
  73. obj.page++
  74. if (obj.limit == data.list.length) {
  75. obj.loadingType = 'more'
  76. } else {
  77. obj.loadingType = 'noMore'
  78. }
  79. })
  80. .catch(e => {
  81. console.log(e);
  82. });
  83. },
  84. navToDetailPage(e) {
  85. uni.navigateTo({
  86. url: '/pages/product/product?id=' + e.id
  87. })
  88. }
  89. }
  90. }
  91. </script>
  92. <style lang="scss">
  93. page,
  94. .center {
  95. min-height: 100%;
  96. height: auto;
  97. background: #FFFFFF;
  98. }
  99. .top {
  100. position: relative;
  101. width: 100%;
  102. height: 400rpx;
  103. .top-bg {
  104. position: absolute;
  105. top: 0;
  106. left: 0;
  107. right: 0;
  108. width: 100%;
  109. height: 100%;
  110. }
  111. .title {
  112. position: relative;
  113. z-index: 2;
  114. padding: 30rpx 0;
  115. font-size: 34rpx;
  116. font-family: PingFang SC;
  117. font-weight: bold;
  118. color: #FFFFFF;
  119. text-align: center;
  120. }
  121. }
  122. .carousel {
  123. width: 700rpx;
  124. height: 300rpx;
  125. margin: -280rpx auto 0;
  126. image {
  127. width: 700rpx;
  128. height: 300rpx;
  129. }
  130. }
  131. .hotgoods {
  132. margin-top: 38rpx;
  133. width: 100%;
  134. display: flex;
  135. flex-wrap: wrap;
  136. padding: 0 32rpx;
  137. .hotgoods-item {
  138. width: 48%;
  139. background-color: #ffffff;
  140. border-radius: 12rpx;
  141. margin-bottom: 24rpx;
  142. &:nth-child(2n + 1) {
  143. margin-right: 24rpx;
  144. }
  145. .image-wrapper {
  146. width: 100%;
  147. height: 330rpx;
  148. // background: red;
  149. border-radius: 3px;
  150. overflow: hidden;
  151. image {
  152. width: 100%;
  153. height: 100%;
  154. opacity: 1;
  155. border-radius: 12rpx 12rpx 0 0;
  156. }
  157. }
  158. .title {
  159. font-size: $font-base;
  160. color: $font-color-dark;
  161. font-weight: bold;
  162. line-height: 80rpx;
  163. }
  164. .hot-price {
  165. display: flex;
  166. justify-content: space-between;
  167. padding: 0 16rpx 12rpx;
  168. .price {
  169. font-size: 36rpx;
  170. font-weight: bold;
  171. color: #FD3B39;
  172. }
  173. .cart-icon {
  174. image {
  175. width: 44rpx;
  176. height: 44rpx;
  177. }
  178. }
  179. }
  180. }
  181. }
  182. </style>