金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

211 lines
5.4 KiB

4 years ago
  1. <template>
  2. <view>
  3. <lf-nav title="秒杀专场" :showIcon="true" bgColor="#fff"></lf-nav>
  4. <scroll-view :style="{height: autoHeight}" :scroll-y="true" :refresher-enabled="true" :refresher-triggered="isRefresher"
  5. @scrolltolower="onScrolltolower" @refresherrefresh="onRefresherrefresh">
  6. <view class="content">
  7. <view class="card" v-for="(item, index) in list" :key="index"
  8. @click="$url('/pages/shop/goodsdetail?type=seckill&id='+ item.goods.id)">
  9. <view class="goods-img">
  10. <image class="img" :src="item.goods.img"></image>
  11. <view class="tips lf-line-1">已有{{item.sell_num}}人购买</view>
  12. </view>
  13. <view class="goods-info">
  14. <view>
  15. <view class="lf-line-2 title lf-m-b-16">{{ item.goods.name }}</view>
  16. <view class="desc" v-if="item.seckill.end_left_time.length==0">距离开始还剩余 {{item.seckill.start_left_time[0]}}{{item.seckill.start_left_time[1]}}{{item.seckill.start_left_time[2]}}{{item.seckill.start_left_time[3]}}</view>
  17. <view class="desc" v-if="item.seckill.start_left_time.length==0">距离结束还剩余 {{item.seckill.end_left_time[0]}}{{item.seckill.end_left_time[1]}}{{item.seckill.end_left_time[2]}}{{item.seckill.end_left_time[3]}}</view>
  18. </view>
  19. <view class="lf-row-between">
  20. <view class="price">
  21. <text>¥{{ item.goods.max_price }}</text>
  22. <text>¥{{ item.goods.market_price }}</text>
  23. </view>
  24. <view class="btn" hover-class="lf-opacity">立即秒杀</view>
  25. </view>
  26. </view>
  27. </view>
  28. <!-- 空数据的情况 -->
  29. <view class="loading-more">
  30. <text v-if="list.length != 0"
  31. :class="{'loading-more-text': loadingClass}">{{ loadingText }}</text>
  32. <lf-nocontent src="/static/images/empty.png" v-else></lf-nocontent>
  33. </view>
  34. </view>
  35. </scroll-view>
  36. <u-back-top :scrollTop="pageScrollTop"></u-back-top>
  37. </view>
  38. </template>
  39. <script>
  40. export default {
  41. data(){
  42. return {
  43. list: [],
  44. page: 1,
  45. isPage: true,
  46. loadingClass: true,
  47. loadingText: '正在加载中',
  48. scrollH: 0,
  49. nav_height: 0,
  50. isRefresher: true,
  51. pageSize: 10
  52. }
  53. },
  54. computed: {
  55. autoHeight(){
  56. return `calc(${this.scrollH}px - ${this.nav_height}px - 180rpx)`;
  57. }
  58. },
  59. onLoad(){
  60. let info = uni.getSystemInfoSync();
  61. this.scrollH = info.screenHeight;
  62. this.getSeckillList();
  63. },
  64. methods: {
  65. // 页面触底,加载下一页
  66. onScrolltolower(){
  67. if(this.isPage){
  68. this.page = this.page + 1;
  69. this.getSeckillList();
  70. }
  71. },
  72. // 下拉刷新处理
  73. refreshFn(options){
  74. this.page = 1;
  75. this.isPage = true;
  76. this.loadingClass = true;
  77. this.list = []
  78. this.loadingText = '正在加载中';
  79. this.getSeckillList(options);
  80. },
  81. // scroll-view 下拉刷新
  82. onRefresherrefresh(){
  83. this.isRefresher = true;
  84. this.refreshFn({type: 'scrollRefresh'});
  85. },
  86. getSeckillList(options = {}){
  87. this.$http.get({
  88. api: 'api/seckill/all'
  89. }).then(res => {
  90. console.log("----", res);
  91. let isPage = this.page < res.data.meta.pagination.total_pages?true:false;
  92. this.isPage = isPage;
  93. if(!isPage) {
  94. this.loadingClass = false;
  95. this.loadingText = '没有更多数据啦~';
  96. }
  97. if(options.type == 'pageRefresh') {
  98. uni.stopPullDownRefresh();
  99. }else if(options.type == 'scrollRefresh') {
  100. this.isRefresher = false;
  101. }
  102. if(this.page == 1) {
  103. this.list = res.data.data;
  104. }else {
  105. this.list.push(...res.data.data);
  106. }
  107. })
  108. }
  109. }
  110. }
  111. </script>
  112. <style>
  113. page{
  114. background-color: #F8F8F8;
  115. }
  116. </style>
  117. <style lang="scss" scoped="scoped">
  118. .content{
  119. padding: 30rpx 32rpx;
  120. width: 750rpx;
  121. height: max-content;
  122. box-sizing: border-box;
  123. .card{
  124. width: 686rpx;
  125. height: 260rpx;
  126. background: #FFFFFF;
  127. border-radius: 20rpx;
  128. box-sizing: border-box;
  129. padding: 30rpx;
  130. display: flex;
  131. &:nth-child(n+2){
  132. margin-top: 30rpx;
  133. }
  134. .goods-img{
  135. width: 200rpx;
  136. height: 200rpx;
  137. border-radius: 10rpx;
  138. overflow: hidden;
  139. position: relative;
  140. margin-right: 15rpx;
  141. .img{
  142. width: 100%;
  143. height: 100%;
  144. background-color: #EEEEEE;
  145. }
  146. .tips{
  147. position: absolute;
  148. bottom: 0;
  149. left: 0;
  150. width: 100%;
  151. height: 37rpx;
  152. background-color: rgba(0,0,0,0.5);
  153. color: #FFFFFF;
  154. font-size: 22rpx;
  155. display: flex;
  156. justify-content: center;
  157. align-items: center;
  158. }
  159. }
  160. .goods-info{
  161. width: 410rpx;
  162. height: 200rpx;
  163. display: flex;
  164. flex-direction: column;
  165. justify-content: space-between;
  166. .title{
  167. font-size: 28rpx;
  168. color: #222222;
  169. font-weight: bold;
  170. }
  171. .desc{
  172. width: 281rpx;
  173. height: max-content;
  174. border-radius: 3rpx;
  175. background-color: #E9F2F2;
  176. font-size: 24rpx;
  177. color: #15716E;
  178. display: flex;
  179. justify-content: center;
  180. align-items: center;
  181. }
  182. .price>text:nth-child(1){
  183. font-size: 36rpx;
  184. color: #F63434;
  185. font-weight: bold;
  186. }
  187. .price>text:nth-child(2){
  188. font-size: 24rpx;
  189. color: #777777;
  190. margin-left: 20rpx;
  191. text-decoration: line-through;
  192. }
  193. .btn{
  194. width: 142rpx;
  195. height: 60rpx;
  196. background: rgba(21, 113, 110, 0.05);
  197. border-radius: 36rpx;
  198. border: 2rpx solid #15716E;
  199. font-size: 26rpx;
  200. color: #15716E;
  201. display: flex;
  202. justify-content: center;
  203. align-items: center;
  204. }
  205. }
  206. }
  207. }
  208. </style>