list.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <!-- 秒杀列表 -->
  2. <template>
  3. <view class="page_box seckill-list-wrap">
  4. <!-- tab栏 -->
  5. <view class="tab-box u-flex">
  6. <view class="tab-item u-flex-col u-row-center u-col-center" @tap="onTab(tab.id)" v-for="tab in tabList" :key="tab.id">
  7. <text class="tab-title u-m-b-20" :class="{ 'tab-active': tabCurrent === tab.id }">{{ tab.title }}</text>
  8. <text v-show="tabCurrent === tab.id" class="tab-line"></text>
  9. </view>
  10. </view>
  11. <!-- 商品列表 -->
  12. <view class="content_box">
  13. <scroll-view scroll-y="true" enable-back-to-top @scrolltolower="loadMore" class="scroll-box">
  14. <view class="goods-item u-m-b-16" v-for="item in goodsList" :key="item.id" @tap="toSeckillDetail(item.id)">
  15. <view class="big-goods u-flex u-p-20 u-col-top ">
  16. <image class="goods-img" lazy-load fade-show :src="item.image" mode="aspectFill"></image>
  17. <view class=" card-right u-m-l-20 u-flex-col u-row-between">
  18. <view class="">
  19. <view class="goods-title u-ellipsis-1 u-m-t-10 u-m-b-10">
  20. <view class="title-tag cu-tag bg-red sm radius u-m-r-10">秒杀</view>
  21. {{ item.title }}
  22. </view>
  23. <view v-show="item.subtitle" class="subtitle-text u-m-b-10 u-ellipsis-1">{{ item.subtitle }}</view>
  24. </view>
  25. <view class="u-flex u-m-y-20">
  26. <view class="cu-progress round sm" style="width:210rpx;"><view :style="[{ width: item.percent + '%',backgroundColor:'#ffbbbb' }]"></view></view>
  27. <view class="progress-text">已售出{{ item.sales }}件</view>
  28. </view>
  29. <view class=" u-flex u-row-between u-col-center">
  30. <view class="u-flex u-col-bottom font-OPPOSANS">
  31. <view class="price u-m-r-10">{{ item.price }}</view>
  32. <view class="origin-price">{{ item.original_price }}</view>
  33. </view>
  34. <button class="u-reset-button buy-btn">去抢购</button>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. <!-- 空白 -->
  40. <shopro-empty v-if="isEmpty" tipText="暂无秒杀商品,敬请期待~" :image="$IMG_URL + '/imgs/empty/empty_goods.png'"></shopro-empty>
  41. <!-- 加载更多 -->
  42. <u-loadmore v-if="!isEmpty" height="80rpx" :status="loadStatus" icon-type="flower" color="#ccc" />
  43. </scroll-view>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. export default {
  49. components: {},
  50. data() {
  51. return {
  52. isEmpty: false, //无数据
  53. loadStatus: 'loadmore', //loadmore-加载前的状态,loading-加载中的状态,nomore-没有更多的状态
  54. lastPage: 1,
  55. currentPage: 1,
  56. tabCurrent: 'ing',
  57. goodsList: [],
  58. tabList: [
  59. {
  60. id: 'ing',
  61. title: '抢购进行中'
  62. },
  63. {
  64. id: 'nostart',
  65. title: '即将开始'
  66. }
  67. ]
  68. };
  69. },
  70. computed: {},
  71. onLoad() {
  72. this.getGoodsList();
  73. },
  74. onPullDownRefresh() {
  75. this.lastPage = 1;
  76. this.currentPage = 1;
  77. this.goodsList = [];
  78. this.getGoodsList();
  79. },
  80. methods: {
  81. onTab(id) {
  82. if (this.tabCurrent !== id) {
  83. this.tabCurrent = id;
  84. this.goodsList = [];
  85. this.currentPage = 1;
  86. this.lastPage = 1;
  87. this.getGoodsList();
  88. }
  89. },
  90. toSeckillDetail(id) {
  91. this.$Router.push({ path: '/pages/goods/detail', query: { id: id } });
  92. },
  93. // 加载更多
  94. loadMore() {
  95. if (this.currentPage < this.lastPage) {
  96. this.currentPage += 1;
  97. this.getGoodsList();
  98. }
  99. },
  100. // 秒杀列表
  101. getGoodsList() {
  102. let that = this;
  103. that.loadStatus = 'loading';
  104. that.$http(
  105. 'goods.seckillList',
  106. {
  107. type: that.tabCurrent,
  108. page: that.currentPage
  109. },
  110. '加载中...'
  111. ).then(res => {
  112. uni.stopPullDownRefresh();
  113. if (res.code === 1) {
  114. that.goodsList = [...that.goodsList, ...res.data.data];
  115. that.goodsList.map(item => {
  116. item.percent = item.stock + item.sales > 0 ? ((item.sales / (item.sales + item.stock)) * 100).toFixed(2) : 0;
  117. });
  118. that.isEmpty = !that.goodsList.length;
  119. that.lastPage = res.data.last_page;
  120. that.loadStatus = that.currentPage < res.data.last_page ? 'loadmore' : 'nomore';
  121. }
  122. });
  123. }
  124. }
  125. };
  126. </script>
  127. <style lang="scss">
  128. .seckill-list-wrap {
  129. background: url($IMG_URL+'/imgs/seckill/sekill_list_head_bg.png') no-repeat;
  130. background-size: 100% auto;
  131. }
  132. // tab
  133. .tab-box {
  134. .tab-item {
  135. flex: 1;
  136. height: 140rpx;
  137. color: rgba(#fff, 0.4);
  138. font-size: 32rpx;
  139. font-weight: 600;
  140. .tab-line {
  141. width: 50rpx;
  142. height: 8rpx;
  143. background: #fff;
  144. border-radius: 4rpx;
  145. }
  146. }
  147. .tab-active {
  148. color: rgba(#fff, 1);
  149. }
  150. }
  151. .scroll-box {
  152. background: linear-gradient(#fff, #f5f5f5);
  153. width: 710rpx;
  154. border-radius: 20rpx;
  155. margin: 0 auto;
  156. }
  157. // 列表
  158. .goods-item {
  159. // 大商品卡片
  160. .big-goods {
  161. width: 710rpx;
  162. height: 260rpx;
  163. background: #ffffff;
  164. box-shadow: 0px 7rpx 8rpx 1rpx rgba(254, 76, 29, 0.05);
  165. border-radius: 20rpx;
  166. .goods-img {
  167. width: 220rpx;
  168. height: 220rpx;
  169. border-radius: 6rpx;
  170. }
  171. .card-right {
  172. width: 430rpx;
  173. height: 220rpx;
  174. }
  175. .goods-title {
  176. font-size: 26rpx;
  177. font-weight: 600;
  178. width: 400rpx;
  179. color: #000000;
  180. }
  181. .subtitle-text {
  182. font-size: 22rpx;
  183. width: 400rpx;
  184. font-weight: 500;
  185. color: #666666;
  186. }
  187. .buy-btn {
  188. width: 120rpx;
  189. line-height: 50rpx;
  190. background: linear-gradient(90deg, #d01325, #ed3c30);
  191. border-radius: 25rpx;
  192. font-size: 24rpx;
  193. font-weight: 500;
  194. color: #ffffff;
  195. }
  196. .progress-text {
  197. color: #c4c4c4;
  198. font-size: 20rpx;
  199. margin-left: 25rpx;
  200. }
  201. // 价格
  202. .price {
  203. color: #ff0000;
  204. font-weight: 600;
  205. &::before {
  206. content: '¥';
  207. font-size: 20rpx;
  208. }
  209. }
  210. .origin-price {
  211. color: #c4c4c4;
  212. font-size: 24rpx;
  213. text-decoration: line-through;
  214. &::before {
  215. content: '¥';
  216. font-size: 20rpx;
  217. }
  218. }
  219. }
  220. .buy-btn {
  221. width: 120rpx;
  222. line-height: 50rpx;
  223. background: linear-gradient(90deg, #d01325, #ed3c30);
  224. border-radius: 25rpx;
  225. font-size: 24rpx;
  226. font-weight: 500;
  227. color: #ffffff;
  228. }
  229. .btn-end,
  230. .btn-nostart {
  231. background: rgba(238, 238, 238, 1);
  232. color: #999999;
  233. }
  234. .btn-ing {
  235. background: linear-gradient(90deg, rgba(233, 180, 97, 1), rgba(238, 204, 137, 1));
  236. box-shadow: 0px 7rpx 6rpx 0px rgba(229, 138, 0, 0.22);
  237. color: rgba(255, 255, 255, 1);
  238. }
  239. }
  240. </style>