feat(shop): 添加文章详情页面并优化购物车样式
- 新增文章详情页面组件,用于显示文章内容 - 优化购物车页面样式,增加空购物车状态的透明背景 - 添加多个购物相关 API 接口,包括优惠券、订单等 - 更新环境配置,修改 API 基础 URL - 调整发现页面布局,增加文章详情入口
This commit is contained in:
31
src/pages/cart/cart.scss
Normal file
31
src/pages/cart/cart.scss
Normal file
@@ -0,0 +1,31 @@
|
||||
// 购物车页面样式
|
||||
.cart-page {
|
||||
// 当购物车为空时,设置透明背景
|
||||
&.empty {
|
||||
page {
|
||||
background-color: transparent !important;
|
||||
}
|
||||
|
||||
.cart-empty-container {
|
||||
background-color: transparent !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 空购物车容器样式
|
||||
.cart-empty-container {
|
||||
background-color: transparent !important;
|
||||
|
||||
// 确保 Empty 组件及其子元素也是透明的
|
||||
.nut-empty {
|
||||
background-color: transparent !important;
|
||||
}
|
||||
|
||||
.nut-empty__image {
|
||||
background-color: transparent !important;
|
||||
}
|
||||
|
||||
.nut-empty__description {
|
||||
background-color: transparent !important;
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
import {ArrowLeft, Del, Shopping} from '@nutui/icons-react-taro';
|
||||
import {View} from '@tarojs/components';
|
||||
import {CartItem, useCart} from "@/hooks/useCart";
|
||||
import './cart.scss';
|
||||
|
||||
function Cart() {
|
||||
const [statusBarHeight, setStatusBarHeight] = useState<number>(0);
|
||||
@@ -69,6 +70,21 @@ function Cart() {
|
||||
});
|
||||
}, []);
|
||||
|
||||
// 根据购物车状态动态设置页面背景色
|
||||
useEffect(() => {
|
||||
if (cartItems.length === 0) {
|
||||
// 购物车为空时设置透明背景
|
||||
Taro.setBackgroundColor({
|
||||
backgroundColor: 'transparent'
|
||||
});
|
||||
} else {
|
||||
// 有商品时恢复默认背景
|
||||
Taro.setBackgroundColor({
|
||||
backgroundColor: '#f5f5f5'
|
||||
});
|
||||
}
|
||||
}, [cartItems.length]);
|
||||
|
||||
// 处理单个商品选择
|
||||
const handleItemSelect = (goodsId: number, checked: boolean) => {
|
||||
if (checked) {
|
||||
@@ -184,7 +200,10 @@ function Cart() {
|
||||
<Empty
|
||||
description="购物车空空如也"
|
||||
actions={[{ text: '去逛逛' }]}
|
||||
style={{ marginTop: `${statusBarHeight + 50}px` }}
|
||||
style={{
|
||||
marginTop: `${statusBarHeight + 50}px`,
|
||||
backgroundColor: 'transparent'
|
||||
}}
|
||||
onClick={() => Taro.switchTab({ url: '/pages/index/index' })}
|
||||
/>
|
||||
</>
|
||||
@@ -226,13 +245,20 @@ function Cart() {
|
||||
</NavBar>
|
||||
|
||||
{/* 购物车内容 */}
|
||||
<View className="pt-24">
|
||||
<View
|
||||
className="pt-24"
|
||||
style={{ backgroundColor: cartItems.length === 0 ? 'transparent' : undefined }}
|
||||
>
|
||||
{cartItems.length === 0 ? (
|
||||
// 空购物车
|
||||
<View className="flex flex-col items-center justify-center h-96">
|
||||
<View
|
||||
className="cart-empty-container flex flex-col items-center justify-center h-96"
|
||||
style={{ backgroundColor: 'transparent' }}
|
||||
>
|
||||
<Empty
|
||||
image={<Shopping size={80}/>}
|
||||
description="购物车空空如也"
|
||||
style={{ backgroundColor: 'transparent' }}
|
||||
>
|
||||
<Button
|
||||
type="primary"
|
||||
|
||||
@@ -6,6 +6,7 @@ import {NavBar, Cell} from '@nutui/nutui-react-taro';
|
||||
import {Text} from '@tarojs/components';
|
||||
import {ArrowRight, ImageRectangle, Coupon, Follow} from '@nutui/icons-react-taro'
|
||||
import './find.scss'
|
||||
import navTo from "@/utils/common";
|
||||
|
||||
/**
|
||||
* 文章终极列表
|
||||
@@ -52,19 +53,25 @@ const Find = () => {
|
||||
<Cell title={
|
||||
<div style={{display: 'inline-flex', alignItems: 'center'}}>
|
||||
<ImageRectangle size={18}/>
|
||||
<Text className={'pl-3'} style={{ fontSize: '16px'}}>好物推荐</Text>
|
||||
</div>
|
||||
} extra={<ArrowRight color="#cccccc" size={18}/>}/>
|
||||
<Cell title={
|
||||
<div style={{display: 'inline-flex', alignItems: 'center'}}>
|
||||
<Coupon size={18}/>
|
||||
<span className={'pl-3'} style={{ fontSize: '16px'}}>权益中心</span>
|
||||
<Text className={'pl-3'} style={{fontSize: '16px'}}>好物推荐</Text>
|
||||
</div>
|
||||
} extra={<ArrowRight color="#cccccc" size={18}/>}/>
|
||||
<Cell
|
||||
title={
|
||||
<div style={{display: 'inline-flex', alignItems: 'center'}}>
|
||||
<Coupon size={18}/>
|
||||
<span className={'pl-3'} style={{fontSize: '16px'}}>权益中心</span>
|
||||
</div>
|
||||
}
|
||||
extra={<ArrowRight color="#cccccc" size={18}/>}
|
||||
onClick={() => {
|
||||
navTo('/shop/shopArticle/index', true)
|
||||
}}
|
||||
/>
|
||||
<Cell title={
|
||||
<div style={{display: 'inline-flex', alignItems: 'center'}}>
|
||||
<Follow size={18}/>
|
||||
<span className={'pl-3'} style={{ fontSize: '16px'}}>我的收藏</span>
|
||||
<span className={'pl-3'} style={{fontSize: '16px'}}>我的收藏</span>
|
||||
</div>
|
||||
} extra={<ArrowRight color="#cccccc" size={18}/>}/>
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user