添加登录和后端校验

完成后端设计(未在本仓库体现),通过安全的手段完成了登录鉴权
This commit is contained in:
2026-08-06 16:27:36 +08:00
commit b19a56003f
286 changed files with 51650 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
export default definePageConfig({
navigationStyle: 'custom',
navigationBarTitleText: '商品详情'
})
+1
View File
@@ -0,0 +1 @@
{}
+237
View File
@@ -0,0 +1,237 @@
.product-page {
padding: 0 24px 24px;
padding-bottom: calc(24px + 160px); /* 为底部 action-bar 留空 */
}
/* 返回按钮 */
.back-btn {
font-size: 40px;
padding: 10px;
}
/* Hero 轮播 */
.hero-section {
margin-top: 20px;
}
.hero-swiper {
height: 400rpx;
}
.hero-card {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
box-sizing: border-box;
}
.hero-icon {
font-size: 100px;
margin-bottom: 16px;
}
.hero-icon-img {
width: 100px;
height: 100px;
margin-bottom: 16px;
}
.hero-name {
font-size: 36px;
font-weight: 700;
color: var(--text-primary);
}
.hero-image {
width: 100%;
height: 100%;
object-fit: contain;
}
/* 基本信息 */
.info-section {
padding: 24px;
}
.info-row {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20px 0;
border-bottom: 1px dashed rgba(0,0,0,0.06);
}
.info-row:last-child {
border-bottom: none;
}
.info-label {
font-size: 28px;
color: var(--text-secondary);
}
.info-price {
font-size: 40px;
font-weight: 800;
color: var(--accent-pink);
}
.info-value {
font-size: 28px;
color: var(--text-primary);
}
/* 详细介绍 */
.detail-section {
padding: 24px;
}
.detail-text {
font-size: 28px;
color: var(--text-secondary);
line-height: 1.8;
}
/* 底部操作栏 */
.action-bar .price-summary {
flex-shrink: 0;
}
.summary-label {
font-size: 22px;
color: var(--text-secondary);
display: block;
}
.summary-price {
font-size: 36px;
font-weight: 700;
color: var(--accent-pink);
}
/* 弹窗 */
.modal-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
display: flex;
align-items: center;
justify-content: center;
z-index: 1000;
padding: 48px;
}
.modal-card {
width: 100%;
max-width: 600px;
padding: 40px;
}
.modal-title {
font-size: 36px;
font-weight: 700;
color: var(--text-primary);
text-align: center;
margin-bottom: 24px;
display: block;
}
.modal-product {
display: flex;
align-items: center;
justify-content: center;
gap: 16px;
margin-bottom: 32px;
}
.modal-icon {
font-size: 48px;
}
.modal-icon-img {
width: 48px;
height: 48px;
}
.modal-name {
font-size: 32px;
color: var(--text-primary);
font-weight: 600;
}
.quantity-row {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 32px;
}
.qty-label {
font-size: 28px;
color: var(--text-secondary);
}
.qty-control {
display: flex;
align-items: center;
gap: 24px;
}
.qty-btn {
width: 60px;
height: 60px;
border-radius: 12px;
background: var(--bg-input);
border: var(--line-card);
display: flex;
align-items: center;
justify-content: center;
font-size: 32px;
color: var(--text-primary);
font-weight: 600;
}
.qty-num {
font-size: 32px;
font-weight: 700;
color: var(--text-primary);
min-width: 48px;
text-align: center;
}
.modal-total {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 32px;
padding-top: 24px;
border-top: 1px dashed rgba(0,0,0,0.06);
}
.total-label {
font-size: 28px;
color: var(--text-secondary);
}
.total-price {
font-size: 36px;
font-weight: 800;
color: var(--accent-pink);
}
.modal-actions {
display: flex;
gap: 20px;
}
.modal-actions .btn-outline,
.modal-actions .btn-gradient {
flex: 1;
padding: 20px 0;
}
+184
View File
@@ -0,0 +1,184 @@
import { View, Text, Image, Swiper, SwiperItem } from '@tarojs/components'
import Taro from '@tarojs/taro'
import { useState } from 'react'
import './index.scss'
import { getProductById } from '../../utils/productConfig'
import { addDesign } from '../../utils/store'
import { useThemeContext } from '../../context/ThemeContext'
import { useSafeArea } from '../../hooks/useSafeArea'
import { useStatusBar } from '../../hooks/useStatusBar'
import { getProductIconImg } from '../../utils/productConfig'
const HERO_COLORS = ['#FFE4EC', '#FFF0F5', '#FCE4EC']
export default function ProductPage() {
const { theme, resolvedTheme } = useThemeContext()
const safe = useSafeArea()
useStatusBar(resolvedTheme)
const [showModal, setShowModal] = useState(false)
const [quantity, setQuantity] = useState(1)
const params = Taro.getCurrentInstance().router?.params
const productId = params?.id || ''
const product = getProductById(productId)
if (!product) {
return (
<View className={`theme-${resolvedTheme}`}>
<View className='product-page'>
<View className='page-header dashed-card mt-20' style={{ marginTop: `${safe.headerPaddingTop}px` }}>
<Text className='page-title'></Text>
</View>
</View>
</View>
)
}
const handleAddToList = () => {
setQuantity(1)
setShowModal(true)
}
const confirmAdd = () => {
addDesign(product, quantity)
setShowModal(false)
Taro.showToast({ title: `已加入设计清单 x${quantity}`, icon: 'success' })
setTimeout(() => Taro.navigateBack(), 1200)
}
const goToDIY = () => {
Taro.navigateTo({
url: `/pages/diy/index?source=product&productId=${product.id}&quantity=1`
})
}
const modQty = (delta: number) => {
setQuantity(q => Math.max(1, Math.min(99, q + delta)))
}
return (
<View className={`theme-${resolvedTheme}`}>
<View className='product-page'>
<View className='page-header dashed-card mt-20' style={{ marginTop: `${safe.headerPaddingTop}px` }}>
<View className='star-badge' />
<View className='flex-between'>
<Text className='back-btn' onTap={() => Taro.navigateBack()}></Text>
<Text className='page-title'></Text>
<View style={{ width: '60px' }} />
</View>
</View>
{/* 轮播 Hero */}
<View className='hero-section mt-20'>
<Swiper
className='hero-swiper'
circular
autoplay
interval={3000}
duration={500}
indicatorDots
indicatorColor='rgba(0,0,0,0.2)'
indicatorActiveColor='#ff9a9e'
>
{product.images && product.images.length > 0 ? (
product.images.map((img, idx) => (
<SwiperItem key={idx}>
<View className='hero-card dashed-card'>
<View className='star-badge' />
<Image className='hero-image' src={img} mode='aspectFit' />
</View>
</SwiperItem>
))
) : (
HERO_COLORS.map((color, idx) => (
<SwiperItem key={idx}>
<View className='hero-card dashed-card' style={{ background: color }}>
<View className='star-badge' />
<Image className='hero-icon-img' src={getProductIconImg(product)} mode='aspectFit' />
<Text className='hero-name'>{product.name}</Text>
</View>
</SwiperItem>
))
)}
</Swiper>
</View>
{/* 基本信息 */}
<View className='info-section dashed-card mt-20'>
<View className='star-badge' />
<View className='info-row'>
<Text className='info-label'></Text>
<Text className='info-price'>¥{product.price}</Text>
</View>
<View className='info-row'>
<Text className='info-label'></Text>
<Text className='info-value'>{product.leadTime}</Text>
</View>
<View className='info-row'>
<Text className='info-label'></Text>
<Text className='info-value'>{product.mask.width} × {product.mask.height} px</Text>
</View>
</View>
{/* 详细介绍 */}
<View className='detail-section dashed-card mt-20'>
<View className='star-badge' />
<Text className='section-title'></Text>
<Text className='detail-text'>{product.description}</Text>
</View>
{/* 底部操作栏 */}
<View className='action-bar'>
<View className='price-summary'>
<Text className='summary-label'></Text>
<Text className='summary-price'>¥{product.price}</Text>
</View>
<View className='btn-outline' onTap={handleAddToList}>
<Text></Text>
</View>
<View className='btn-gradient' onTap={goToDIY}>
<Text></Text>
</View>
</View>
{/* 安全区占位(防止内容被 action-bar 遮挡) */}
<View className='safe-bottom-placeholder' />
{/* 数量选择弹窗 */}
{showModal && (
<View className='modal-overlay'>
<View className='modal-card dashed-card'>
<View className='star-badge' />
<Text className='modal-title'></Text>
<View className='modal-product'>
<Image className='modal-icon-img' src={getProductIconImg(product)} mode='aspectFit' />
<Text className='modal-name'>{product.name}</Text>
</View>
<View className='quantity-row'>
<Text className='qty-label'></Text>
<View className='qty-control'>
<View className='qty-btn' onTap={() => modQty(-1)}></View>
<Text className='qty-num'>{quantity}</Text>
<View className='qty-btn' onTap={() => modQty(1)}></View>
</View>
</View>
<View className='modal-total'>
<Text className='total-label'></Text>
<Text className='total-price'>¥{(product.price * quantity).toFixed(2)}</Text>
</View>
<View className='modal-actions'>
<View className='btn-outline' onTap={() => setShowModal(false)}>
<Text></Text>
</View>
<View className='btn-gradient' onTap={confirmAdd}>
<Text></Text>
</View>
</View>
</View>
</View>
)}
</View>
</View>
)
}