new.vue 3.7 KB

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