Merge branch 'feature/task1.0.0_xg' into 'feature/task1.0.0'

Feature/task1.0.0 xg

See merge request yanxuan-frontend/shop-pc!21
merge-requests/22/head
肖广 3 years ago
commit a638c32ef7

@ -10,7 +10,8 @@
<BsLogin :visible.sync="loginVisible" /> <BsLogin :visible.sync="loginVisible" />
<Header <Header
:is-categroy-open="isHomePage" :is-categroy-open="isHomePage"
:hide-bar-line="isHomePage" :hide-bar-line="isHideBarLinePage"
:hide-sticky-shadow="isHideSeckillPage"
:show-categroy-tab="showCategroyTab" :show-categroy-tab="showCategroyTab"
:is-sticky="isSticky" :is-sticky="isSticky"
/> />
@ -45,6 +46,12 @@ export default {
isHomePage() { isHomePage() {
return this.$route.path === "/"; return this.$route.path === "/";
}, },
isHideBarLinePage() {
return ["/", "/seckill"].includes(this.$route.path);
},
isHideSeckillPage() {
return this.$route.path === "/seckill";
},
showCategroyTab() { showCategroyTab() {
return !CATEGROY_HIDE_PAGES.some((reg) => { return !CATEGROY_HIDE_PAGES.some((reg) => {
return reg.test(this.$route.path); return reg.test(this.$route.path);

@ -2,7 +2,10 @@
<div class="layout-header"> <div class="layout-header">
<!-- 滚动吸顶头部 --> <!-- 滚动吸顶头部 -->
<div v-show="isSticky"> <div v-show="isSticky">
<div class="sticky-bar-header"> <div
class="sticky-bar-header"
:class="{ 'sticky-bar-header--hide-shadow': hideStickyShadow }"
>
<div class="sticky-bar-header__wrap flex flex-middle flex-between"> <div class="sticky-bar-header__wrap flex flex-middle flex-between">
<div class="flex flex-middle"> <div class="flex flex-middle">
<img <img
@ -198,6 +201,12 @@ export default {
type: Boolean, type: Boolean,
default: false, default: false,
}, },
// tab
hideStickyShadow: {
type: Boolean,
default: true,
},
}, },
data() { data() {
return { return {
@ -312,6 +321,14 @@ export default {
z-index: 10; z-index: 10;
background: #ffffff; background: #ffffff;
box-shadow: 0px 4px 10px 1px rgba(0, 0, 0, 0.1); box-shadow: 0px 4px 10px 1px rgba(0, 0, 0, 0.1);
&--hide-shadow {
box-shadow: none;
/deep/.el-menu {
.is-active {
border-bottom: none !important;
}
}
}
.sticky-bar-header__wrap { .sticky-bar-header__wrap {
@include layout-box; @include layout-box;
height: 100%; height: 100%;
@ -364,7 +381,7 @@ export default {
color: #666666; color: #666666;
.is-active { .is-active {
color: #ff7f39; color: #ff7f39;
border-bottom: 2px solid #ff823c; border-bottom: 3px solid #ff823c;
} }
.el-menu-item:hover { .el-menu-item:hover {
color: #ff7f39; color: #ff7f39;
@ -373,7 +390,8 @@ export default {
height: 100%; height: 100%;
line-height: 50px; line-height: 50px;
font-size: 16px; font-size: 16px;
margin: 0 20px; margin: 0 30px;
padding: 0 5px;
} }
} }
} }

@ -12,8 +12,8 @@
<strong class="home-sckill-title">限时秒杀</strong> <strong class="home-sckill-title">限时秒杀</strong>
<div class="home-sckill-wrap"> <div class="home-sckill-wrap">
<div class="home-sckill-wrap__tip"> <div class="home-sckill-wrap__tip">
<strong>10:00</strong> <strong>{{ data.activityTimeVO.timeName }}</strong>
<span>点场 距结束</span> <span>{{ seckillText }}</span>
</div> </div>
<div class="home-sckill-wrap__countdown flex flex-middle flex-center"> <div class="home-sckill-wrap__countdown flex flex-middle flex-center">
<div class="sckill-wrap-countdown__time">{{ countdown.hour }}</div> <div class="sckill-wrap-countdown__time">{{ countdown.hour }}</div>
@ -66,6 +66,7 @@
</template> </template>
<script> <script>
import _ from "lodash"; import _ from "lodash";
import { FormatDate } from "@/plugins/utils";
const CAROUSEL_COUNT = 5; // const CAROUSEL_COUNT = 5; //
@ -81,6 +82,9 @@ export default {
return { return {
bkgUrl: require("~/assets/img/sckill/bkg-small.png"), bkgUrl: require("~/assets/img/sckill/bkg-small.png"),
goodsList: [], goodsList: [],
seckillTime: 0, //
seckillText: "", //
timeInterval: null, //
}; };
}, },
watch: { watch: {
@ -88,22 +92,37 @@ export default {
deep: true, deep: true,
immediate: true, immediate: true,
handler(val) { handler(val) {
const { activityProductListVO: products } = val; const {
currentTime,
activityProductListVO: products,
activityTimeVO: { activityEndTime, activityStartTime },
} = val;
if (products && products.length > 0) { if (products && products.length > 0) {
this.getFormatData(products); this.getFormatData(products);
} }
this.getSeckillData({
currentTime,
startTime: activityStartTime,
endTime: activityEndTime,
});
}, },
}, },
}, },
computed: { computed: {
//
countdown() { countdown() {
const date = FormatDate(this.seckillTime, "hh:mm:ss");
const [hour, minute, second] = date.split(":");
return { return {
hour: "01", hour,
minute: "32", minute,
second: "09", second,
}; };
}, },
}, },
destroyed() {
clearInterval(this.timeInterval);
},
methods: { methods: {
// //
getFormatData(list) { getFormatData(list) {
@ -118,6 +137,32 @@ export default {
this.goodsList.push(goodsListItem); this.goodsList.push(goodsListItem);
} }
}, },
//
getSeckillData({ current, startTime, endTime }) {
current = new Date(current);
startTime = new Date(startTime);
endTime = new Date(endTime);
if (current > startTime && current < endTime) {
//
this.seckillText = "距结束";
this.seckillTime = endTime - current;
} else {
//
this.seckillText = "距开始";
this.seckillTime = startTime - current;
}
this.setCountDownInterval();
},
//
setCountDownInterval() {
this.timeInterval = setInterval(() => {
if (this.seckillTime <= 0) {
clearInterval(this.timeInterval);
}
this.seckillTime -= 1000;
}, 1e3);
},
onJumpSeckill() { onJumpSeckill() {
this.$router.push("/seckill"); this.$router.push("/seckill");
}, },
@ -149,6 +194,7 @@ export default {
font-size: 0; font-size: 0;
strong { strong {
font-size: 18px; font-size: 18px;
margin-right: 4px;
} }
span { span {
font-size: 14px; font-size: 14px;

@ -28,7 +28,7 @@
</div> </div>
</div> </div>
<div class="seckill-bar flex flex-middle flex-center"> <div class="seckill-bar flex flex-middle flex-center">
<p>本场秒杀即将开抢距开始还剩</p> <p>{{ seckillTip }}</p>
<div class="seckill-bar-countdown flex flex-middle"> <div class="seckill-bar-countdown flex flex-middle">
<div class="seckill-bar-countdown__time">{{ countdown.hour }}</div> <div class="seckill-bar-countdown__time">{{ countdown.hour }}</div>
<span class="seckill-bar-countdown--mark">:</span> <span class="seckill-bar-countdown--mark">:</span>
@ -85,6 +85,7 @@
</template> </template>
<script> <script>
import { ApiGetSeckillTimes, ApiGetSeckillGoods } from "@/plugins/api/seckill"; import { ApiGetSeckillTimes, ApiGetSeckillGoods } from "@/plugins/api/seckill";
import { FormatDate } from "@/plugins/utils";
import TabBar from "./module/TabBar.vue"; import TabBar from "./module/TabBar.vue";
export default { export default {
@ -115,7 +116,26 @@ export default {
second: "09", second: "09",
}; };
}, },
//
currentTabItem() {
const tabItem = this.tabList.find(
(item) => item.id === this.query.activityTimeId
);
return tabItem || null;
},
//
seckillTip() {
if (this.currentTabItem) {
return this.currentTabItem.isInProgress
? "本场正在秒杀中,好物转瞬即逝,不要错过哦~距结束仅剩"
: "本场秒杀即将开抢,距开始还剩";
}
return "";
},
}, },
created() { created() {
this.getSeckillTimes(); this.getSeckillTimes();
}, },
@ -142,7 +162,9 @@ export default {
const { result } = await ApiGetSeckillTimes(); const { result } = await ApiGetSeckillTimes();
if (result && result.length > 0) { if (result && result.length > 0) {
this.tabList = result; this.tabList = result;
this.query.activityTimeId = result[0].id; const inProgressItem = result.find((item) => item.isInProgress);
this.query.activityTimeId =
(inProgressItem && inProgressItem.id) || result[0].id;
this.getGoodsList(); this.getGoodsList();
} }
}, },

@ -9,8 +9,10 @@
'sckill-header-tabbar__item--active': item.id === value, 'sckill-header-tabbar__item--active': item.id === value,
}" }"
> >
<strong class="header-tabbar-item__time">18:00</strong> <strong class="header-tabbar-item__time">{{ item.timeName }}</strong>
<div class="header-tabbar-item__tip">抢购中</div> <div class="header-tabbar-item__tip">
{{ item.isInProgress ? "抢购中" : "即将开抢" }}
</div>
</div> </div>
</div> </div>
</template> </template>

Loading…
Cancel
Save