Browse Source

秒杀倒计时

master
Enzo 4 years ago
parent
commit
6e2f295929
  1. 17
      pages/order/confirm/confirm.vue
  2. 126
      pages/shop/seckillList.vue

17
pages/order/confirm/confirm.vue

@ -27,6 +27,23 @@
暂无收货地址,请前往添加 暂无收货地址,请前往添加
</view> </view>
</view> </view>
<view class="card address" v-else>
<view @click="$url('/pages/address/list/list?is_select=1')">
<text class="lf-font-28 lf-color-primary lf-m-r-10">店铺地址</text>
</view>
<view v-if="address">
<view class="lf-m-t-20">
<text class="lf-font-28 lf-color-222 lf-font-bold">{{ order_detail.order.brand.name }}</text>
<text class="lf-font-28 lf-color-777 lf-m-l-20">{{ order_detail.order.brand.tel }}</text>
</view>
<view class="lf-font-28 lf-color-333 lf-m-t-10">
<text>{{ order_detail.order.brand.floor }}</text>
</view>
</view>
<view v-else class="lf-font-28 lf-color-777">
暂无收货地址,请前往添加
</view>
</view>
<view class="card goods"> <view class="card goods">
<view @click="$url('/pages/shop/shopdetail?id='+ order_detail.order.brand.id)"> <view @click="$url('/pages/shop/shopdetail?id='+ order_detail.order.brand.id)">
<text class="lf-iconfont icon-Group- lf-font-30"></text> <text class="lf-iconfont icon-Group- lf-font-30"></text>

126
pages/shop/seckillList.vue

@ -1,8 +1,8 @@
<template> <template>
<view> <view>
<lf-nav title="秒杀专场" :showIcon="true" bgColor="#fff"></lf-nav> <lf-nav title="秒杀专场" :showIcon="true" bgColor="#fff"></lf-nav>
<scroll-view :style="{height: autoHeight}" :scroll-y="true" :refresher-enabled="true" :refresher-triggered="isRefresher"
@scrolltolower="onScrolltolower" @refresherrefresh="onRefresherrefresh">
<scroll-view :style="{height: autoHeight}" :scroll-y="true" :refresher-enabled="true"
:refresher-triggered="isRefresher" @scrolltolower="onScrolltolower" @refresherrefresh="onRefresherrefresh">
<view class="content"> <view class="content">
<view class="card" v-for="(item, index) in list" :key="index" <view class="card" v-for="(item, index) in list" :key="index"
@click="$url('/pages/shop/goodsdetail?id='+ item.goods.id)"> @click="$url('/pages/shop/goodsdetail?id='+ item.goods.id)">
@ -13,12 +13,20 @@
<view class="goods-info"> <view class="goods-info">
<view> <view>
<view class="lf-line-2 title lf-m-b-16">{{ item.goods.name }}</view> <view class="lf-line-2 title lf-m-b-16">{{ item.goods.name }}</view>
<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>
<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>
<!-- <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>
<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> -->
<view class="desc" v-if="item.seckill.start_left_time.length==0">距离结束还剩余
{{ item.seckill.ends_at | timeStamp }}
</view>
</view> </view>
<view class="lf-row-between"> <view class="lf-row-between">
<view class="price"> <view class="price">
<text>¥{{ item.goods.max_price }}</text>
<text>¥{{ item.seckill_price }}</text>
<text>¥{{ item.goods.market_price }}</text> <text>¥{{ item.goods.market_price }}</text>
</view> </view>
<view class="btn" hover-class="lf-opacity">立即秒杀</view> <view class="btn" hover-class="lf-opacity">立即秒杀</view>
@ -27,8 +35,7 @@
</view> </view>
<!-- 空数据的情况 --> <!-- 空数据的情况 -->
<view class="loading-more"> <view class="loading-more">
<text v-if="list.length != 0"
:class="{'loading-more-text': loadingClass}">{{ loadingText }}</text>
<text v-if="list.length != 0" :class="{'loading-more-text': loadingClass}">{{ loadingText }}</text>
<lf-nocontent src="/static/images/empty.png" v-else></lf-nocontent> <lf-nocontent src="/static/images/empty.png" v-else></lf-nocontent>
</view> </view>
</view> </view>
@ -49,7 +56,12 @@
scrollH: 0, scrollH: 0,
nav_height: 0, nav_height: 0,
isRefresher: true, isRefresher: true,
pageSize: 10
pageSize: 10,
timer: '',
day: '',
hour: '',
min: '',
second: ''
} }
}, },
computed: { computed: {
@ -61,6 +73,89 @@
let info = uni.getSystemInfoSync(); let info = uni.getSystemInfoSync();
this.scrollH = info.screenHeight; this.scrollH = info.screenHeight;
this.getSeckillList(); this.getSeckillList();
// setInterval(() => {
// //
// this.timer = this.timeStamp('2021-09-29 21:27:00')
// }, 1000)
},
filters: {
timeStamp(times) {
// setInterval(() => {
// }, 1000)
//
let timestamp = Date.parse(new Date());
timestamp = timestamp/1000;
let timestap1 = Date.parse(new Date(times));
let letime = (timestap1/1000) - timestamp;
let time = parseInt(letime);
if (parseInt(letime) > 60) {
let second = parseInt(letime) % 60;
let min = parseInt(letime / 60);
//
// time = min + "" + second + "";
//
time = {
min: min,
second: second
};
if (min > 60) {
min = parseInt(letime / 60) % 60;
let hour = parseInt(parseInt(letime / 60) / 60);
//
// time = hour + "" + min + "" + second + "";
//
time = {
hour: hour,
min: min,
second: second
}
if (hour >= 24) {
hour = parseInt(parseInt(letime / 60) / 60) % 24;
let day = parseInt(parseInt(parseInt(letime / 60) / 60) / 24);
//
// time = day + "" + hour + "" + min + "" + second + "";
//
time = {
day: day,
hour: hour,
min: min,
second: second
}
}
}
}
// 1010
if (time.day < 10) {
time.day = '0' + time.day
} else if (time.day == undefined) {
time.day = '00'
}
if (time.hour < 10) {
time.hour = '0' + time.hour
} else if (time.hour == undefined) {
time.hour = '00'
}
if (time.min < 10) {
time.min = '0' + time.min
} else if (time.min == undefined) {
time.min = '00'
}
if (time.second < 10) {
time.second = '0' + time.second
}
console.log(time)
// this.day = time.day
// this.hour = time.hour
// this.min = time.min
// this.second = time.second
//
return time.day+'天'+time.hour+'时'+time.min+'分'+time.second+'秒';
},
}, },
methods: { methods: {
// //
@ -82,7 +177,9 @@
// scroll-view // scroll-view
onRefresherrefresh() { onRefresherrefresh() {
this.isRefresher = true; this.isRefresher = true;
this.refreshFn({type: 'scrollRefresh'});
this.refreshFn({
type: 'scrollRefresh'
});
}, },
getSeckillList(options = {}) { getSeckillList(options = {}) {
this.$http.get({ this.$http.get({
@ -123,6 +220,7 @@
width: 750rpx; width: 750rpx;
height: max-content; height: max-content;
box-sizing: border-box; box-sizing: border-box;
.card { .card {
width: 686rpx; width: 686rpx;
height: 260rpx; height: 260rpx;
@ -131,9 +229,11 @@
box-sizing: border-box; box-sizing: border-box;
padding: 30rpx; padding: 30rpx;
display: flex; display: flex;
&:nth-child(n+2) { &:nth-child(n+2) {
margin-top: 30rpx; margin-top: 30rpx;
} }
.goods-img { .goods-img {
width: 200rpx; width: 200rpx;
height: 200rpx; height: 200rpx;
@ -141,11 +241,13 @@
overflow: hidden; overflow: hidden;
position: relative; position: relative;
margin-right: 15rpx; margin-right: 15rpx;
.img { .img {
width: 100%; width: 100%;
height: 100%; height: 100%;
background-color: #EEEEEE; background-color: #EEEEEE;
} }
.tips { .tips {
position: absolute; position: absolute;
bottom: 0; bottom: 0;
@ -160,17 +262,20 @@
align-items: center; align-items: center;
} }
} }
.goods-info { .goods-info {
width: 410rpx; width: 410rpx;
height: 200rpx; height: 200rpx;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: space-between; justify-content: space-between;
.title { .title {
font-size: 28rpx; font-size: 28rpx;
color: #222222; color: #222222;
font-weight: bold; font-weight: bold;
} }
.desc { .desc {
width: 281rpx; width: 281rpx;
height: max-content; height: max-content;
@ -182,17 +287,20 @@
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
.price>text:nth-child(1) { .price>text:nth-child(1) {
font-size: 36rpx; font-size: 36rpx;
color: #F63434; color: #F63434;
font-weight: bold; font-weight: bold;
} }
.price>text:nth-child(2) { .price>text:nth-child(2) {
font-size: 24rpx; font-size: 24rpx;
color: #777777; color: #777777;
margin-left: 20rpx; margin-left: 20rpx;
text-decoration: line-through; text-decoration: line-through;
} }
.btn { .btn {
width: 142rpx; width: 142rpx;
height: 60rpx; height: 60rpx;

Loading…
Cancel
Save