Commit f824ec8c authored by Xuguangxing's avatar Xuguangxing

feat: 倒计时组件进行二次封装

parent 6d9a94bc
<template>
<cr-count-down :time="time">
<template #default="timeData">
<template v-if="timeData.d != 0">
<span class="block">{{ timeData.d }}</span>
<span class="colon">:</span>
</template>
<span class="block">{{ fillZero(timeData.h) }}</span>
<span class="colon">:</span>
<span class="block">{{ fillZero(timeData.m) }}</span>
<span class="colon">:</span>
<span class="block">{{ fillZero(timeData.s) }}</span>
</template>
</cr-count-down>
</template>
<script>
export default {
props: {
endTime: {
type: Number,
default: 0
}
},
computed: {
time() {
return this.endTime - new Date().getTime();
}
},
methods: {
fillZero(t) {
t = t.toString();
if (t.length == 1) {
return `0${t}`;
}
return t;
}
}
};
</script>
<style lang="less" scoped>
.colon {
display: inline-block;
margin: 0 @padding-unit;
color: @red-dark;
}
.block {
display: inline-block;
width: 18px;
// height: 22px;
color: #fff;
.text-11();
text-align: center;
background-color: @red-dark;
border-radius: @padding-unit;
line-height: 18px;
}
</style>
...@@ -143,6 +143,33 @@ ...@@ -143,6 +143,33 @@
padding-bottom: @padding-x; padding-bottom: @padding-x;
} }
} }
&-group-buy-info{
display: flex;
background-image: url("../../assets/images/info-bg.png");
background-color: #FFE8E8;
background-size: cover;
width: 100%;
height: 51px;
&-price{
width: 253px;
flex-shrink: 0;
display: flex;
align-items: center;
}
&-time{
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
&-desc{
.text-12();
// margin-bottom: @padding-unit;
color: @font-color-dark;
text-align: center;
}
}
}
&-sale { &-sale {
padding: 5px 10px; padding: 5px 10px;
background: @white; background: @white;
......
...@@ -14,6 +14,13 @@ ...@@ -14,6 +14,13 @@
</cr-swipe> </cr-swipe>
<swipe-customer-info v-model="showInfo" /> <swipe-customer-info v-model="showInfo" />
</div> </div>
<div class="goods-group-buy-info">
<div class="goods-group-buy-info-price" />
<div class="goods-group-buy-info-time">
<p class="goods-group-buy-info-time-desc">距成团结束</p>
<count-down :end-time="endTime" />
</div>
</div>
<!-- 商品名称/价格 --> <!-- 商品名称/价格 -->
<div class="goods-info"> <div class="goods-info">
<div class="goods-info-price"> <div class="goods-info-price">
...@@ -162,6 +169,8 @@ import detailInfoArea from './components/detailInfo.vue'; ...@@ -162,6 +169,8 @@ import detailInfoArea from './components/detailInfo.vue';
import Img2Thumb from '@/filters/img2Thumb.filter'; import Img2Thumb from '@/filters/img2Thumb.filter';
import bottomNav from './components/bottomNav'; import bottomNav from './components/bottomNav';
import swipeCustomerInfo from '@/components/swipeCustomerInfo'; import swipeCustomerInfo from '@/components/swipeCustomerInfo';
import countDown from '@/components/countDown';
import CountDown from '@/components/countDown.vue';
export default { export default {
// eslint-disable-next-line vue/name-property-casing // eslint-disable-next-line vue/name-property-casing
name: 'goodDetail', name: 'goodDetail',
...@@ -169,14 +178,18 @@ export default { ...@@ -169,14 +178,18 @@ export default {
detailInfoArea, detailInfoArea,
goodsCell, goodsCell,
bottomNav, bottomNav,
swipeCustomerInfo swipeCustomerInfo,
countDown,
// tipModal // tipModal
CountDown
}, },
filters: { filters: {
Img2Thumb Img2Thumb
}, },
data() { data() {
return { return {
endTime: 1631203200000,
// 以下是原有的data
flag: false, flag: false,
showInfo: false, showInfo: false,
detailParam: { detailParam: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment