new.vue 3.8 KB

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