金诚优选前端代码
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.

293 lines
8.5 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
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"
  5. :refresher-triggered="isRefresher" @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?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">距离开始还剩余
  17. {{item.seckill.start_left_time[0]}}{{item.seckill.start_left_time[1]}}{{item.seckill.start_left_time[2]}}{{item.seckill.start_left_time[3]}}
  18. </view>
  19. <view class="desc" v-if="item.seckill.start_left_time.length==0">距离结束还剩余
  20. {{item.seckill.end_left_time[0]}}{{item.seckill.end_left_time[1]}}{{item.seckill.end_left_time[2]}}{{item.seckill.end_left_time[3]}}
  21. </view> -->
  22. <!-- <view class="desc" v-if="item.ifStart">距离结束还剩余
  23. <countdown-timer :time="item.countTime" :autoStart="true" @finish="dateFinish">
  24. <template v-slot="{day,hour,minute, second}">
  25. <view class="lf-flex">
  26. <view class="lf-font-24">{{ day >= 10 ? day : "0" + day }}</view>
  27. <view class="lf-font-24"></view>
  28. <view class="lf-font-24">{{ hour >= 10 ? hour : "0" + hour }}</view>
  29. <view class="lf-font-24"></view>
  30. <view class="lf-font-24">{{ minute >= 10 ? minute : "0" + minute }}</view>
  31. <view class="lf-font-24"></view>
  32. <view class="lf-font-24">{{ second >= 10 ? second : "0" + second }}</view>
  33. <view class="lf-font-24"></view>
  34. </view>
  35. </template>
  36. </countdown-timer>
  37. </view>
  38. <view class="desc" v-else>距离开始还剩余
  39. <countdown-timer :time="item.countTime" :autoStart="true" @finish="dateFinish">
  40. <template v-slot="{day,hour,minute, second}">
  41. <view class="lf-flex">
  42. <view class="lf-font-24">{{ day >= 10 ? day : "0" + day }}</view>
  43. <view class="lf-font-24"></view>
  44. <view class="lf-font-24">{{ hour >= 10 ? hour : "0" + hour }}</view>
  45. <view class="lf-font-24"></view>
  46. <view class="lf-font-24">{{ minute >= 10 ? minute : "0" + minute }}</view>
  47. <view class="lf-font-24"></view>
  48. <view class="lf-font-24">{{ second >= 10 ? second : "0" + second }}</view>
  49. <view class="lf-font-24"></view>
  50. </view>
  51. </template>
  52. </countdown-timer>
  53. </view> -->
  54. <view class="desc" v-if="item.seckill.end_left_time.length==0">
  55. 距离开始还剩余
  56. <countdown-time :day="item.seckill.start_left_time[0]" :hour="item.seckill.start_left_time[1]" :minute="item.seckill.start_left_time[2]" :second="item.seckill.start_left_time[3]">
  57. </countdown-time>
  58. </view>
  59. <view class="desc" v-if="item.seckill.start_left_time.length==0">
  60. 距离结束还剩余
  61. <countdown-time :day="item.seckill.end_left_time[0]" :hour="item.seckill.end_left_time[1]" :minute="item.seckill.end_left_time[2]" :second="item.seckill.end_left_time[3]">
  62. </countdown-time>
  63. </view>
  64. </view>
  65. <view class="lf-row-between">
  66. <view class="price">
  67. <text>¥{{ item.seckill_price }}</text>
  68. <text>¥{{ item.goods.sell_price }}</text>
  69. </view>
  70. <view class="btn" hover-class="lf-opacity">立即秒杀</view>
  71. </view>
  72. </view>
  73. </view>
  74. <!-- 空数据的情况 -->
  75. <view class="loading-more">
  76. <text v-if="list.length != 0" :class="{'loading-more-text': loadingClass}">{{ loadingText }}</text>
  77. <lf-nocontent src="/static/images/empty.png" v-else></lf-nocontent>
  78. </view>
  79. </view>
  80. </scroll-view>
  81. <u-back-top :scrollTop="pageScrollTop"></u-back-top>
  82. </view>
  83. </template>
  84. <script>
  85. import countdownTime from '@/components/uni-countdown/uni-countdown.vue';
  86. export default {
  87. data() {
  88. return {
  89. list: [],
  90. page: 1,
  91. isPage: true,
  92. loadingClass: true,
  93. loadingText: '正在加载中',
  94. scrollH: 0,
  95. nav_height: 0,
  96. isRefresher: true,
  97. pageSize: 10,
  98. timer: '',
  99. day: '',
  100. hour: '',
  101. min: '',
  102. second: ''
  103. }
  104. },
  105. components: {
  106. countdownTime
  107. },
  108. computed: {
  109. autoHeight() {
  110. return `calc(${this.scrollH}px - ${this.nav_height}px - 180rpx)`;
  111. }
  112. },
  113. onLoad() {
  114. let info = uni.getSystemInfoSync();
  115. this.scrollH = info.screenHeight;
  116. this.getSeckillList();
  117. },
  118. methods: {
  119. // 页面触底,加载下一页
  120. onScrolltolower() {
  121. if (this.isPage) {
  122. this.page = this.page + 1;
  123. this.getSeckillList();
  124. }
  125. },
  126. // 下拉刷新处理
  127. refreshFn(options) {
  128. this.page = 1;
  129. this.isPage = true;
  130. this.loadingClass = true;
  131. this.list = []
  132. this.loadingText = '正在加载中';
  133. this.getSeckillList(options);
  134. },
  135. // scroll-view 下拉刷新
  136. onRefresherrefresh() {
  137. this.isRefresher = true;
  138. this.refreshFn({
  139. type: 'scrollRefresh'
  140. });
  141. },
  142. getTime(){
  143. var date = new Date(),
  144. year = date.getFullYear(),
  145. month = date.getMonth() + 1,
  146. day = date.getDate(),
  147. hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours(),
  148. minute = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(),
  149. second = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
  150. month >= 1 && month <= 9 ? (month = "0" + month) : "";
  151. day >= 0 && day <= 9 ? (day = "0" + day) : "";
  152. var timer = year + '-' + month + '-' + day + ' ' + hour + ':' + minute + ':' + second;
  153. return timer;
  154. },
  155. getSeckillList(options = {}) {
  156. this.$http.get({
  157. api: 'api/seckill/all'
  158. }).then(res => {
  159. console.log("----", res);
  160. let isPage = this.page < res.data.meta.pagination.total_pages ? true : false;
  161. this.isPage = isPage;
  162. if (!isPage) {
  163. this.loadingClass = false;
  164. this.loadingText = '没有更多数据啦~';
  165. }
  166. if (options.type == 'pageRefresh') {
  167. uni.stopPullDownRefresh();
  168. } else if (options.type == 'scrollRefresh') {
  169. this.isRefresher = false;
  170. }
  171. if (this.page == 1) {
  172. this.list = res.data.data;
  173. } else {
  174. this.list.push(...res.data.data);
  175. }
  176. })
  177. }
  178. }
  179. }
  180. </script>
  181. <style>
  182. page {
  183. background-color: #F8F8F8;
  184. }
  185. </style>
  186. <style lang="scss" scoped="scoped">
  187. .content {
  188. padding: 30rpx 32rpx;
  189. width: 750rpx;
  190. height: max-content;
  191. box-sizing: border-box;
  192. .card {
  193. width: 686rpx;
  194. height: 260rpx;
  195. background: #FFFFFF;
  196. border-radius: 20rpx;
  197. box-sizing: border-box;
  198. padding: 30rpx;
  199. display: flex;
  200. &:nth-child(n+2) {
  201. margin-top: 30rpx;
  202. }
  203. .goods-img {
  204. width: 200rpx;
  205. height: 200rpx;
  206. border-radius: 10rpx;
  207. overflow: hidden;
  208. position: relative;
  209. margin-right: 15rpx;
  210. .img {
  211. width: 100%;
  212. height: 100%;
  213. background-color: #EEEEEE;
  214. }
  215. .tips {
  216. position: absolute;
  217. bottom: 0;
  218. left: 0;
  219. width: 100%;
  220. height: 37rpx;
  221. background-color: rgba(0, 0, 0, 0.5);
  222. color: #FFFFFF;
  223. font-size: 22rpx;
  224. display: flex;
  225. justify-content: center;
  226. align-items: center;
  227. }
  228. }
  229. .goods-info {
  230. width: 410rpx;
  231. height: 200rpx;
  232. display: flex;
  233. flex-direction: column;
  234. justify-content: space-between;
  235. .title {
  236. font-size: 28rpx;
  237. color: #222222;
  238. font-weight: bold;
  239. }
  240. .desc {
  241. // width: 281rpx;
  242. height: max-content;
  243. border-radius: 3rpx;
  244. background-color: #E9F2F2;
  245. font-size: 24rpx;
  246. color: #15716E;
  247. display: flex;
  248. justify-content: center;
  249. align-items: center;
  250. }
  251. .price>text:nth-child(1) {
  252. font-size: 36rpx;
  253. color: #F63434;
  254. font-weight: bold;
  255. }
  256. .price>text:nth-child(2) {
  257. font-size: 24rpx;
  258. color: #777777;
  259. margin-left: 20rpx;
  260. text-decoration: line-through;
  261. }
  262. .btn {
  263. width: 142rpx;
  264. height: 60rpx;
  265. background: rgba(21, 113, 110, 0.05);
  266. border-radius: 36rpx;
  267. border: 2rpx solid #15716E;
  268. font-size: 26rpx;
  269. color: #15716E;
  270. display: flex;
  271. justify-content: center;
  272. align-items: center;
  273. }
  274. }
  275. }
  276. }
  277. </style>