refactor: 重构组件逻辑与样式优化

- 在 App.vue 中重构站点信息的获取与应用逻辑,提升代码可读性与维护性。
- 更新 Search.vue 组件,优化搜索框的样式与结构,增强用户体验。
- 在 element.scss 中注释掉不再使用的样式,并新增确认收货按钮的样式。
- 改进多个页面的布局与样式,确保响应式设计的一致性与美观性。
- 更新订单相关组件的按钮样式,提升视觉一致性与可用性。
This commit is contained in:
田香琪
2026-06-30 21:09:28 +08:00
parent ec948b5496
commit 28a857249a
121 changed files with 5122 additions and 2182 deletions

View File

@@ -1,47 +1,60 @@
<template>
<div class="navbar" :class="{'small-search-box':useClass == 'fixed-show'}">
<div class="container width_1200_auto flex flex-a-c">
<img
:src="$store.state.logoImg"
v-if="showLogo"
class="logo-img"
alt=""
@click="$router.push('/')"
/>
<div :class="{'small-search-box':useClass == 'fixed-show'}" class="search-box">
<div class="navbar" :class="{'small-search-box': useClass == 'fixed-show'}">
<template v-if="useClass == 'fixed-show'">
<div class="search search-embedded">
<el-input
v-model="searchData"
size="large"
class="search "
class="search-input"
placeholder="输入你想查找的商品"
@keyup.enter="search"
>
<template #append>
<div class="search-icon" @click="search">
/>
<div class="search-btn" @click="search">
<el-icon :size="21"><SearchIcon /></el-icon>
</div>
</div>
</template>
<template v-else>
<div class="container width_1200_auto flex flex-a-c">
<img
:src="$store.state.logoImg"
v-if="showLogo"
class="logo-img"
alt=""
@click="$router.push('/')"
/>
<div class="search-box">
<div class="search">
<el-input
v-model="searchData"
size="large"
class="search-input"
placeholder="输入你想查找的商品"
@keyup.enter="search"
/>
<div class="search-btn" @click="search">
<el-icon :size="21"><SearchIcon /></el-icon>
</div>
</template>
</el-input>
<template v-if="showTag">
<div class="only-store" v-if="storeId" @click="research()">
切换为{{!onlyStore ? '店铺内' : '平台'}}搜索
</div>
<div v-if="promotionTags.length === 0"></div>
<div v-else class="history-list flex">
<div
v-for="(item, index) in promotionTags"
:key="index"
class="mr_10"
>
<span class="history-item" @click="selectTags(item)">{{ item }}</span>
<template v-if="showTag">
<div class="only-store" v-if="storeId" @click="research()">
切换为{{!onlyStore ? '店铺内' : '平台'}}搜索
</div>
</div>
</template>
<div v-if="promotionTags.length === 0"></div>
<div v-else class="history-list flex">
<div
v-for="(item, index) in promotionTags"
:key="index"
class="mr_10"
>
<span class="history-item" @click="selectTags(item)">{{ item }}</span>
</div>
</div>
</template>
</div>
</div>
</div>
</template>
</div>
</template>
@@ -154,14 +167,19 @@ export default {
height: 113px;
background: #fff;
}
.search-icon{
width: 100%;
height: 100%;
}
.small-search-box{
height: 60px;
margin: 0 !important;
.navbar.small-search-box {
height: 60px;
width: 100%;
margin: 0;
display: flex;
align-items: center;
background: transparent;
}
.search-embedded {
width: 100%;
margin: 0;
}
.container {
@@ -171,47 +189,47 @@ export default {
}
.search {
$btn-gap: 4px;
$btn-width: 60px;
$input-height: 37.8px;
position: relative;
width: 778.4px;
height: $input-height;
margin: 10px 0px 5px 0;
border-radius: 18.9px;
.search-input {
width: 100%;
:deep(.el-input--large .el-input__wrapper) {
border: 1.4px solid $theme_color;
box-sizing: border-box;
border-radius: 19.6px;
position: relative;
padding-left: 26px;
font-size: 14px;
font-weight: normal;
height: 37.8px;
color: #999;
box-shadow: none;
:deep(.el-input__wrapper) {
border: 1.4px solid $theme_color;
box-sizing: border-box;
border-radius: 19.6px;
padding-left: 26px;
padding-right: calc(#{$btn-gap * 2} + #{$btn-width});
font-size: 14px;
font-weight: normal;
height: $input-height;
color: #999;
box-shadow: none;
}
}
:deep(.el-input-group__append) {
border-radius: 19.6px !important;
.search-btn {
position: absolute;
right: $btn-gap;
top: $btn-gap;
bottom: $btn-gap;
width: $btn-width;
border-radius: calc((#{$input-height} - #{$btn-gap * 2}) / 2);
cursor: pointer;
box-sizing: border-box;
border: 1.4px solid $theme_color;
width: 67.2px;
height: 37.8px;
position: absolute;
right: 0;
display: flex;
align-items: center;
justify-content: center;
top: 0;
z-index: 99;
z-index: 1;
background-color: $theme_color;
color: #ffffff;
button {
font-size: 14px;
font-weight: 600;
line-height: 1;
}
}
}
.search-box{

View File

@@ -278,7 +278,7 @@
>加入购物车</el-button
>
<el-button
type="warning"
class="confirm-receipt-btn"
:loading="loading1"
:disabled="skuDetail.quantity === 0"
@click="buyNow"

View File

@@ -1,8 +1,12 @@
<template>
<div class="scroll-show">
<div class="content clearfix">
<cateNav class="cate" :hover="true" :showNavBar="false"
useClass="fixed-show"></cateNav>
<div class="content">
<cateNav
class="cate"
:hover="true"
:showNavBar="false"
useClass="fixed-show"
/>
<Search
class="search-con"
:hover="true"
@@ -10,97 +14,113 @@
:showLogo="false"
:showTag="false"
useClass="fixed-show"
></Search>
<div class="flex flex-a-c cart">
/>
<div class="cart">
<span @mouseenter="getCartList">
<el-icon class="cart-icon" :size="20" @click="goCartList"><ShoppingCart /></el-icon>
</span>
<i class="cart-badge">{{ cartNum < 100 ? cartNum : "99" }}</i>
</div>
</div>
</div>
</template>
<script>
import { cartCount } from "@/api/cart.js";
import storage from "@/plugins/storage.js";
import { ShoppingCart } from "@element-plus/icons-vue";
import Search from '@/components/Search.vue'
import cateNav from '@/components/nav/CateNav.vue'
import { cartCount } from '@/api/cart.js'
import storage from '@/plugins/storage.js'
import { ShoppingCart } from '@element-plus/icons-vue'
export default {
components: { ShoppingCart },
components: { ShoppingCart, Search, cateNav },
data() {
return {
userInfo: {}, // 用户信息
};
userInfo: {}
}
},
computed: {
cartNum() {
// 购物车商品数量
return this.$store.state.cartNum;
},
return this.$store.state.cartNum
}
},
methods: {
goCartList() {
// 跳转购物车页面
let routerUrl = this.$router.resolve({
path: "/cart",
});
window.open(routerUrl.href, "_blank");
const routerUrl = this.$router.resolve({ path: '/cart' })
window.open(routerUrl.href, '_blank')
},
getCartList() {
// 获取购物车列表
if (storage.getItem("userInfo")) {
if (storage.getItem('userInfo')) {
cartCount().then((res) => {
this.$store.commit("SET_CARTNUM", res.result);
this.Cookies.setItem("cartNum", res.result);
});
this.$store.commit('SET_CARTNUM', res.result)
this.Cookies.setItem('cartNum', res.result)
})
}
},
},
mounted() {
if (storage.getItem("userInfo")) {
this.userInfo = JSON.parse(storage.getItem("userInfo"));
}
},
};
mounted() {
if (storage.getItem('userInfo')) {
this.userInfo = JSON.parse(storage.getItem('userInfo'))
}
}
}
</script>
<style lang="scss" scoped>
$side-col-width: 263.2px;
$col-gap: 10px;
$cart-col-width: 40px;
.scroll-show {
height: 60px;
overflow: hidden;
}
.content {
width: 1200px;
height: 40px;
margin: 0 auto;
position: relative;
}
.cate {
float: left;
width: 200px !important;
}
.search-con {
float: left;
width: 800px;
overflow: hidden;
margin-top: -27px;
}
.cart{
height: 60px;
margin: 0 auto;
display: grid;
grid-template-columns: $side-col-width 1fr $cart-col-width;
column-gap: $col-gap;
align-items: center;
}
.cart-icon {
width: 30px;
float: left;
font-size: 25px;
color: $theme_color;
z-index: 1;
position: relative;
&:hover {
cursor: pointer;
.cate {
min-width: 0;
:deep(.cate-nav) {
width: 100%;
margin: 0;
}
:deep(.nav-con) {
height: 60px;
}
}
.search-con {
min-width: 0;
width: 100%;
}
.cart {
display: flex;
align-items: center;
justify-content: center;
height: 60px;
position: relative;
}
.cart-icon {
font-size: 25px;
color: $theme_color;
cursor: pointer;
}
.cart-badge {
position: absolute;
font-style: normal;
right: 165px;
top: 12px;
right: -2px;
display: block;
background-color: $theme_color;
color: #fff;
@@ -111,6 +131,5 @@ export default {
line-height: 17px;
text-align: center;
z-index: 5;
top: 10px;
}
</style>

View File

@@ -45,6 +45,7 @@ export default {
width: 100%;
min-height: 1200px;
box-sizing: border-box;
overflow-x: hidden;
/* 勿设 overflow-x: hidden会裁切 discountAdvert 的 margin-left: -100px 左溢背景 */
overflow-x: visible;
}
</style>

View File

@@ -17,30 +17,30 @@
</template>
<!-- 热门广告 -->
<template v-if="element.type == 'hotAdvert'">
<div class="mb_20 width_1200_auto">
<img
style="display: block; width: 100%; max-width: 1200px; height: auto"
class="hover-pointer"
:src="element.options.list[0].img"
@click="linkTo(element.options.list[0].url)"
width="1200"
alt=""
/>
</div>
<ul class="advert-list width_1200_auto">
<template v-for="(item, index) in element.options.list" :key="index">
<li
v-if="index !== 0"
@click="linkTo(item.url)"
<div class="hot-advert mb_20 width_1200_auto">
<div class="hot-advert-banner">
<img
class="hover-pointer"
>
<img :src="item.img" width="230" height="190" alt="" />
</li>
</template>
</ul>
:src="element.options.list[0].img"
@click="linkTo(element.options.list[0].url)"
alt=""
/>
</div>
<ul class="advert-list">
<template v-for="(item, index) in element.options.list" :key="index">
<li
v-if="index !== 0"
@click="linkTo(item.url)"
class="hover-pointer"
>
<img :src="item.img" alt="" />
</li>
</template>
</ul>
</div>
</template>
<!-- 限时秒杀 待完善 -->
<template v-if="element.type == 'seckill' && element.options.list.length">
<template v-if="element.type == 'seckill' && element.options?.list?.length">
<seckill :data="element" class="mb_20 width_1200_auto"></seckill>
</template>
<!-- 折扣广告 -->
@@ -121,15 +121,12 @@
></first-page-advert>
</template>
<!-- 横幅广告 -->
<template v-if="element.type == 'bannerAdvert'">
<div style="width: 100%; text-align: center">
<img
width="1200"
class="hover-pointer mb_20 bannerAd"
@click="linkTo(element.options.url)"
:src="element.options.img"
alt=""
/>
<template v-if="element.type == 'bannerAdvert' && element.options.img">
<div
class="horizontal-advert width_1200_auto mb_20 hover-pointer"
@click="linkTo(element.options.url)"
>
<img class="bannerAd" :src="element.options.img" alt="" />
</div>
</template>
<template v-if="element.type == 'notEnough'"
@@ -198,22 +195,55 @@ export default {
box-sizing: border-box;
overflow: hidden;
}
.bannerAd{
/** 横幅广告 */
.horizontal-advert {
width: 100%;
height: 166.6px;
max-width: 1200px;
overflow: hidden;
border-radius: 10px;
box-sizing: border-box;
line-height: 0;
}
.bannerAd {
display: block;
width: 100%;
height: auto;
max-height: 166px;
object-fit: cover;
}
/** 热门广告 */
.hot-advert {
width: 1200px;
max-width: 100%;
overflow: hidden;
.hot-advert-banner {
line-height: 0;
img {
display: block;
width: 100%;
height: auto;
}
}
}
.advert-list {
width: 100%;
margin: 0;
padding: 5px 0;
list-style: none;
box-sizing: border-box;
background: $theme_color;
height: 200px;
display: flex;
justify-content: space-around;
padding: 3px 10px;
box-sizing: border-box;
gap: 10px;
align-items: center;
> li {
flex: 1 1 0;
min-width: 0;
img {
display: block;
width: 100%;
height: 190px;
cursor: pointer;
border-radius: 10px;
transition: all 150ms ease-in-out;
@@ -227,40 +257,43 @@ export default {
/** 折扣广告 */
.discountAdvert-wrap {
width: 1200px;
position: relative;
overflow: hidden;
overflow: visible;
}
.discountAdvert {
width: 100%;
max-width: 1200px;
height: 520px;
margin: 0 auto;
width: 1300px;
height: 585px;
margin-left: -100px;
box-sizing: border-box;
background-repeat: no-repeat;
background-size: 1200px 520px;
background-position: center top;
background-size: 1300px 585px;
background-position: left top;
position: relative;
padding: 10px 0 0 330px;
overflow: hidden;
> div {
padding-left: 295px;
display: flex;
flex-wrap: wrap;
align-items: flex-start;
align-content: flex-start;
box-sizing: border-box;
width: 100%;
img {
display: block;
flex-shrink: 0;
margin-top: 10px;
margin-right: 10px;
margin-bottom: 10px;
&:nth-child(1) img {
margin: 10px 10px 0 0;
transition: all 150ms ease-in-out;
&:hover {
box-shadow: 0 5px 12px 0 rgba(0, 0, 0, 0.4);
transform: translateY(-2px);
}
}
&:nth-child(2) {
margin-top: 10px;
img {
margin: 0 10px 0 0;
transition: all 150ms ease-in-out;
&:hover {
box-shadow: 0 5px 12px 0 rgba(0, 0, 0, 0.4);
transform: translateY(-2px);
}
}
}
}
}

View File

@@ -1,17 +1,19 @@
<template>
<div class="not-enough" ref="obtain" id="demo">
<el-affix :offset-top="62" @change="change">
<ul class="nav-bar" v-show="topSearchShow">
<li
v-for="(item, index) in conData.options.navList"
:class="currentIndex === index ? 'curr' : ''"
@click="changeCurr(index)"
:key="index"
>
<p @click="gotoDemo">{{ item.title }}</p>
<p @click="gotoDemo">{{ item.desc }}</p>
</li>
</ul>
<el-affix :offset-top="62" @change="change" class="nav-affix">
<div class="nav-bar" v-show="topSearchShow">
<ul class="nav-list">
<li
v-for="(item, index) in conData.options.navList"
:class="currentIndex === index ? 'curr' : ''"
@click="changeCurr(index)"
:key="index"
>
<p @click="gotoDemo">{{ item.title }}</p>
<p @click="gotoDemo">{{ item.desc }}</p>
</li>
</ul>
</div>
</el-affix>
<div class="content" v-if="showContent">
<div
@@ -95,18 +97,34 @@ export default {
};
</script>
<style lang="scss" scoped>
.not-enough {
width: 100%;
box-sizing: border-box;
}
:deep(.nav-affix.el-affix) {
width: 100%;
}
.nav-bar {
display: flex;
justify-content: center;
width: 100%;
margin-bottom: 10px;
background-color: #f8f8f8;
height: 60px;
box-sizing: border-box;
}
.nav-list {
display: flex;
justify-content: center;
align-items: center;
position: relative;
position: sticky;
position: -webkit-sticky;
top: 0;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
list-style: none;
box-sizing: border-box;
li {
padding: 0 30px;
text-align: center;
@@ -114,11 +132,15 @@ export default {
font-size: 16px;
border-radius: 50px;
padding: 0 7px;
margin: 0;
line-height: 1.2;
}
p:nth-child(2) {
font-size: 14px;
color: #999;
margin: 2px 0 0;
line-height: 1.2;
}
&:hover {
@@ -129,6 +151,7 @@ export default {
}
border-right: 1px solid #eee;
}
li:last-of-type {
border: none;
}
@@ -136,7 +159,6 @@ export default {
.curr {
p:nth-child(1) {
background-color: $theme_color;
color: #fff;
}
p:nth-child(2) {
@@ -146,6 +168,8 @@ export default {
}
.content {
width: 100%;
box-sizing: border-box;
display: flex;
flex-wrap: wrap;
justify-content: space-between;

View File

@@ -1,5 +1,5 @@
<template>
<div class="seckill" v-if="goodsList.length">
<div class="seckill" v-if="goodsList && goodsList.length">
<div class="aside hover-pointer" @click="goToSeckill">
<div class="title">{{ actName }}</div>
<div class="hour">
@@ -54,7 +54,7 @@ export default {
clearInterval(this.interval);
this.interval = null;
this.countDown(val);
this.goodsList = this.list[val].seckillGoodsList;
this.goodsList = this.list[val]?.seckillGoodsList || [];
},
diffSeconds(val) {
const hours = Math.floor(val / 3600);
@@ -106,9 +106,15 @@ export default {
}, 1000);
},
getListByDay() {
this.list = this.data.options.list;
this.goodsList = this.list[0].seckillGoodsList;
this.countDown(this.currIndex);
this.list = this.data?.options?.list || [];
if (!this.list.length) {
this.goodsList = [];
return;
}
this.goodsList = this.list[0]?.seckillGoodsList || [];
if (this.goodsList.length) {
this.countDown(this.currIndex);
}
},
},
};

View File

@@ -241,8 +241,10 @@ export default {
}
.fixed-show{
margin-top: 0 !important;
width: 100%;
>.nav-con{
>.all-categories{
width: 100%;
align-items: center !important;
height: 60px;
display: inherit;