综述: 优化福利专区积分购物车功能
- 修复积分购物车在页面切换时的显示逻辑,只在积分专区显示购物车悬浮按钮 - 新增页面加载时的初始化逻辑,确保积分购物车正确显示状态 - 移除重复的购物车计数器变量声明,优化代码结构 - 提升用户体验,避免在其他页面显示不相关的购物车功能
This commit is contained in:
parent
1264aa6d46
commit
398f815a18
|
|
@ -1056,6 +1056,9 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
// 积分购物车功能
|
||||||
|
let pointsCartCount = 0;
|
||||||
|
|
||||||
// 页面切换功能
|
// 页面切换功能
|
||||||
function switchTab(tabName) {
|
function switchTab(tabName) {
|
||||||
// 隐藏所有内容
|
// 隐藏所有内容
|
||||||
|
|
@ -1075,6 +1078,14 @@
|
||||||
|
|
||||||
// 激活选中的标签
|
// 激活选中的标签
|
||||||
event.target.classList.add('active');
|
event.target.classList.add('active');
|
||||||
|
|
||||||
|
// 只在积分专区显示购物车
|
||||||
|
const floatingCart = document.getElementById('floatingCart');
|
||||||
|
if (tabName === 'points') {
|
||||||
|
floatingCart.style.display = 'flex';
|
||||||
|
} else {
|
||||||
|
floatingCart.style.display = 'none';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 积分专区tab切换功能
|
// 积分专区tab切换功能
|
||||||
|
|
@ -1121,8 +1132,12 @@
|
||||||
window.location.href = '电商首页.html';
|
window.location.href = '电商首页.html';
|
||||||
});
|
});
|
||||||
|
|
||||||
// 积分购物车功能
|
// 页面加载时初始化积分购物车显示状态
|
||||||
let pointsCartCount = 0;
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
// 页面加载时默认在积分专区,显示购物车
|
||||||
|
const floatingCart = document.getElementById('floatingCart');
|
||||||
|
floatingCart.style.display = 'flex';
|
||||||
|
});
|
||||||
|
|
||||||
function addToPointsCart(button) {
|
function addToPointsCart(button) {
|
||||||
// 获取商品名称
|
// 获取商品名称
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue