diff --git a/buyer/src/api/member.js b/buyer/src/api/member.js index 2f1eb240..7465e123 100644 --- a/buyer/src/api/member.js +++ b/buyer/src/api/member.js @@ -205,6 +205,7 @@ export function couponList (params) { url: `/buyer/promotion/coupon`, method: Method.GET, needToken: true, + loading: false, params }); } diff --git a/buyer/src/api/shopentry.js b/buyer/src/api/shopentry.js index b1d178ae..05bdf3d1 100644 --- a/buyer/src/api/shopentry.js +++ b/buyer/src/api/shopentry.js @@ -72,7 +72,8 @@ export function applyStatus () { return request({ url: `/buyer/store/store/apply`, needToken: true, - method: Method.GET + method: Method.GET, + loading: false }) } diff --git a/buyer/src/assets/styles/global-layout.scss b/buyer/src/assets/styles/global-layout.scss new file mode 100644 index 00000000..efd02a2c --- /dev/null +++ b/buyer/src/assets/styles/global-layout.scss @@ -0,0 +1,22 @@ +// 全局布局工具类(非 scoped,避免子组件继承 class 时宽度失效) +.width_1200_auto { + width: 1200px; + max-width: 1200px; + margin-left: auto; + margin-right: auto; + box-sizing: border-box; +} + +// 首页主体:分类导航 + 楼层装修共用同一 1200px 容器,保证列对齐 +.index-main { + width: 1200px; + max-width: 1200px; + margin-left: auto; + margin-right: auto; + box-sizing: border-box; + position: relative; +} + +// 与 CateNav 商品分类栏、Carousel 左占位一致的列宽 +$index-side-col-width: 263.2px; +$index-col-gap: 10px; diff --git a/buyer/src/assets/styles/global.scss b/buyer/src/assets/styles/global.scss index f71ad359..b1b298da 100644 --- a/buyer/src/assets/styles/global.scss +++ b/buyer/src/assets/styles/global.scss @@ -30,6 +30,7 @@ $dark_content_color: #d5d5d5; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; + line-clamp: 2; overflow: hidden; } /***** 封装一些方法可用于 黑暗主题 ,明亮主题 *****/ @@ -305,9 +306,11 @@ li { } .width_1200_auto { - width: 1184px; + width: 1200px; + max-width: 1200px; margin: 0 auto; + box-sizing: border-box; } @@ -325,18 +328,24 @@ li { .goods-list { display: flex; flex-wrap: wrap; - width: 1200px; + width: 100%; margin: 0 auto; + column-gap: 10px; } .goods-show-info { - width: 235px; + width: calc(20% - 8px); padding: 6px; - margin: 10px 0px; - margin-left: 5px; + margin: 10px 0; position: relative; border: 1px solid #fff; cursor: pointer; background-color: #fff; + box-sizing: border-box; + } + .goods-show-img img { + width: 100%; + aspect-ratio: 1; + object-fit: cover; } .goods-show-info:hover { border: 1px solid #ccc; @@ -368,7 +377,12 @@ li { color: $theme_color; } .goods-page { - margin:10px auto ; - text-align: right; - width: 1200px; + margin: 10px 0; + width: 100%; + display: flex; + justify-content: flex-end; + + :deep(.el-pagination) { + justify-content: flex-end; + } } diff --git a/buyer/src/assets/styles/goodsList.scss b/buyer/src/assets/styles/goodsList.scss index 81e4d3a1..30b17b93 100644 --- a/buyer/src/assets/styles/goodsList.scss +++ b/buyer/src/assets/styles/goodsList.scss @@ -9,18 +9,24 @@ .goods-list { display: flex; flex-wrap: wrap; - width: 1200px; + width: 100%; margin: 0 auto; + column-gap: 10px; } .goods-show-info { - width: 235px; + width: calc(20% - 8px); padding: 6px; - margin: 10px 0px; - margin-left: 5px; + margin: 10px 0; position: relative; border: 1px solid #fff; cursor: pointer; background-color: #fff; + box-sizing: border-box; +} +.goods-show-img img { + width: 100%; + aspect-ratio: 1; + object-fit: cover; } .goods-show-info:hover { border: 1px solid #ccc; @@ -37,6 +43,7 @@ text-overflow: ellipsis; display:-webkit-box; -webkit-line-clamp:2; + line-clamp: 2; -webkit-box-orient:vertical; color:#808080; } @@ -62,7 +69,12 @@ color: $theme_color; } .goods-page { - margin:10px auto ; - text-align: right; - width: 1200px; + margin: 10px 0; + width: 100%; + display: flex; + justify-content: flex-end; + + :deep(.el-pagination) { + justify-content: flex-end; + } } \ No newline at end of file diff --git a/buyer/src/components/card/index.vue b/buyer/src/components/card/index.vue index c5228c69..49a0698a 100644 --- a/buyer/src/components/card/index.vue +++ b/buyer/src/components/card/index.vue @@ -136,5 +136,10 @@ export default { :deep(._Card .el-card__body) { padding: 0 !important; + min-height: 0; +} + +:deep(._Card .el-card__body:empty) { + display: none; } diff --git a/buyer/src/components/drawer/Main.vue b/buyer/src/components/drawer/Main.vue index 571ce61f..9d79de37 100644 --- a/buyer/src/components/drawer/Main.vue +++ b/buyer/src/components/drawer/Main.vue @@ -57,7 +57,7 @@ export default { if (!this.userInfo) { this.$Modal.confirm({ title: '请登录', - content: '

请登录后执行此操作

', + content: '请登录后执行此操作', okText: '立即登录', cancelText: '继续浏览', onOk: () => { diff --git a/buyer/src/components/goodsDetail/ShowGoods.vue b/buyer/src/components/goodsDetail/ShowGoods.vue index d15f4d59..14c2264b 100644 --- a/buyer/src/components/goodsDetail/ShowGoods.vue +++ b/buyer/src/components/goodsDetail/ShowGoods.vue @@ -10,7 +10,7 @@ :src="currentImg" :preview-src-list="previewList" fit="contain" - style="width: 100%; height: 400px" + style="width: 100%; height: 350px" /> @@ -220,16 +220,18 @@

数量

-
- - 库存{{ skuDetail.quantity }} +
+
+ + 库存{{ skuDetail.quantity }} +

重量

-
- {{ skuDetail.weight }}kg +
+ {{ skuDetail.weight }}kg
- 积分购买 +
+
+ 积分购买 +
+
- - 加入购物车 - 立即购买 - - - +
+
+ 加入购物车 + 立即购买 + + + +
+
@@ -644,9 +653,7 @@ export default { height: 350px; box-shadow: 0px 0px 8px $border_color; cursor: pointer; - - - + margin-bottom: 24px; } #dplayer{ width: 100%; @@ -657,7 +664,7 @@ export default { } .item-detail-img-row { - margin-top: 15px; + margin-top: 0; display: flex; } @@ -835,6 +842,7 @@ export default { .item-select { display: flex; flex-direction: row; + align-items: center; margin-top: 15px; } @@ -843,15 +851,25 @@ export default { font-size: 14px; margin-right: 15px; width: 60px; + flex-shrink: 0; + display: flex; + align-items: center; + + p { + margin: 0; + } } .item-select-column { display: flex; flex-wrap: wrap; + align-items: center; flex: 1; } .item-select-row { + display: flex; + align-items: center; margin-bottom: 8px; } @@ -890,12 +908,33 @@ export default { border-top: 1px dotted $border_color; } +.add-buy-car-row { + margin-top: 25px; + + &.item-select { + margin-top: 25px; + } + + .item-select-column { + flex: none; + width: 100%; + } +} + .add-buy-car { display: flex; align-items: center; - margin-top: 15px; + flex-wrap: wrap; + margin-top: 0; + padding-left: 0; + margin-left: 0; + > * { - margin: 0 4px; + margin: 0 8px 0 0; + } + + > *:last-child { + margin-right: 0; } } diff --git a/buyer/src/components/goodsDetail/ShowGoodsDetail.vue b/buyer/src/components/goodsDetail/ShowGoodsDetail.vue index 4c80a20f..63909e4a 100644 --- a/buyer/src/components/goodsDetail/ShowGoodsDetail.vue +++ b/buyer/src/components/goodsDetail/ShowGoodsDetail.vue @@ -164,9 +164,13 @@ export default { }, methods: { changeHeight (name) { // 设置商品详情高度 - let heightCss = window.getComputedStyle(this.$refs[name]).height; - heightCss = parseInt(heightCss.substr(0, heightCss.length - 2)) + 89; - this.$refs.itemIntroDetail.style.height = heightCss + 'px'; + const el = this.$refs[name]; + const container = this.$refs.itemIntroDetail; + if (!el || !container) return; + let heightCss = window.getComputedStyle(el).height; + heightCss = parseInt(heightCss, 10) + 89; + if (Number.isNaN(heightCss)) return; + container.style.height = heightCss + 'px'; }, changePageNum (val) { // 修改评论页码 this.commentParams.pageNumber = val; @@ -245,13 +249,18 @@ export default { }, mounted () { this.$nextTick(() => { // 手动设置详情高度,解决无法撑开问题 - setTimeout(this.changeHeight('itemIntroGoods'), 2000); + setTimeout(() => { + this.changeHeight('itemIntroGoods'); + }, 2000); }); window.addEventListener('scroll', this.handleScroll) this.getList(); if (this.skuDetail.grade === null || this.skuDetail.grade === undefined) { this.skuDetail.grade = 100 } + }, + beforeUnmount () { + window.removeEventListener('scroll', this.handleScroll); } }; diff --git a/buyer/src/components/header/Header.vue b/buyer/src/components/header/Header.vue index 5780793a..1a3c8c49 100644 --- a/buyer/src/components/header/Header.vue +++ b/buyer/src/components/header/Header.vue @@ -41,9 +41,9 @@
  • 我的足迹
  • 我的消息
  • - + - + 购物车({{ cartNum < 100 ? cartNum : '99' }}) @@ -107,7 +107,10 @@ export default { return { config: require('@/config'), userInfo: {}, // 用户信息 - shoppingCart: [] // 购物车 + shoppingCart: [], // 购物车 + cartLoading: false, + cartLoadedAt: 0, + cartCacheTime: 5000 }; }, computed: { @@ -146,7 +149,7 @@ export default { } else { this.$Modal.confirm({ title: '请登录', - content: '

    请登录后执行此操作

    ', + content: '请登录后执行此操作', okText: '立即登录', cancelText: '继续浏览', onOk: () => { @@ -173,15 +176,31 @@ export default { this.$router.push('login'); } }, + handleCartDropdownVisible(visible) { + if (visible) { + this.getCartList(); + } + }, getCartList() { // 获取购物车列表 - if (this.userInfo.username) { - cartGoodsAll().then((res) => { - this.shoppingCart = res.result.skuList; + if (!this.userInfo.username || this.cartLoading) { + return; + } + const now = Date.now(); + if (this.cartLoadedAt && now - this.cartLoadedAt < this.cartCacheTime) { + return; + } + this.cartLoadedAt = now; + this.cartLoading = true; + cartGoodsAll().then((res) => { + if (res.success) { + this.shoppingCart = (res.result && res.result.skuList) || []; this.$store.commit('SET_CARTNUM', this.shoppingCart.length); this.Cookies.setItem('cartNum', this.shoppingCart.length); - }); - } + } + }).finally(() => { + this.cartLoading = false; + }); } } }; @@ -192,28 +211,36 @@ export default { .box { width: 100%; font-size: 12px !important; - height: 36px; + height: 36px; background: #333; color: #fff; + display: flex; + align-items: center; } .nav { display: flex; flex-direction: row; + align-items: center; justify-content: space-between; - + height: 100%; } .nav ul { list-style: none; + margin: 0; + padding: 0; + display: flex; + align-items: center; } .nav li { cursor: pointer; - float: left; - line-height: 36px; + float: none; + line-height: 1; margin-right: 15px; - + display: flex; + align-items: center; } .nav a, @@ -221,9 +248,11 @@ export default { font-size: 13px; font-weight: normal; text-decoration: none; - cursor: pointer; color: #fff; + display: inline-flex; + align-items: center; + line-height: 1; } .nav-item { @@ -305,6 +334,8 @@ export default { div { cursor: pointer; + display: flex; + align-items: center; > span { margin-left: 5px; diff --git a/buyer/src/components/indexDecorate/ModelForm.vue b/buyer/src/components/indexDecorate/ModelForm.vue index dcf10abe..c6b0f359 100644 --- a/buyer/src/components/indexDecorate/ModelForm.vue +++ b/buyer/src/components/indexDecorate/ModelForm.vue @@ -1,14 +1,13 @@ @@ -19,12 +18,32 @@ export default { components: { ModelFormItem }, - props: ['data'] + props: ['data'], + computed: { + renderList() { + const list = this.data?.list || []; + return list.filter( + (el) => el && el.key && !this.isBuiltinModule(el.type) + ); + } + }, + methods: { + isBuiltinModule(type) { + // 顶部广告、快捷导航由 Index 页单独渲染 + return type === 'topAdvert' || type === 'navBar'; + } + } }; diff --git a/buyer/src/components/indexDecorate/ModelFormItem.vue b/buyer/src/components/indexDecorate/ModelFormItem.vue index 93f83a1b..bd224102 100644 --- a/buyer/src/components/indexDecorate/ModelFormItem.vue +++ b/buyer/src/components/indexDecorate/ModelFormItem.vue @@ -2,10 +2,9 @@