针对个人主页与照片显示做了修改

This commit is contained in:
2026-07-27 21:47:14 +08:00
parent 4d086758e8
commit fa781cc6a6
60 changed files with 2770 additions and 683 deletions
+3
View File
@@ -0,0 +1,3 @@
export default definePageConfig({
navigationBarTitleText: '收货地址'
})
+181
View File
@@ -0,0 +1,181 @@
.address-page {
padding: 0 24px 24px;
}
.back-btn {
font-size: 40px;
padding: 10px;
}
.address-list {
margin-top: 20px;
}
.address-card {
padding: 24px;
margin-bottom: 20px;
}
.address-header {
margin-bottom: 20px;
}
.address-user {
display: flex;
align-items: center;
margin-bottom: 12px;
}
.address-name {
font-size: 32px;
font-weight: 700;
color: var(--text-primary);
margin-right: 16px;
}
.address-phone {
font-size: 28px;
color: var(--text-secondary);
}
.default-tag {
margin-left: 12px;
background: var(--accent-pink);
color: #fff;
font-size: 20px;
padding: 2px 10px;
border-radius: 8px;
}
.address-full {
font-size: 28px;
color: var(--text-secondary);
line-height: 1.5;
}
.address-actions {
display: flex;
justify-content: flex-end;
gap: 24px;
padding-top: 16px;
border-top: 1px dashed rgba(0,0,0,0.06);
}
.address-act {
font-size: 26px;
color: var(--accent-blue);
}
.address-act.delete {
color: #ff6b6b;
}
/* 表单弹窗 */
.address-form {
width: 100%;
max-width: 600px;
padding: 40px;
}
.form-input {
width: 100%;
height: 80px;
background: var(--bg-input);
border: 3px dashed var(--line-star);
border-radius: 16px;
padding: 0 24px;
font-size: 28px;
color: var(--text-primary);
margin-bottom: 20px;
box-sizing: border-box;
}
.form-picker {
width: 100%;
height: 80px;
background: var(--bg-input);
border: 3px dashed var(--line-star);
border-radius: 16px;
display: flex;
align-items: center;
padding: 0 24px;
margin-bottom: 20px;
box-sizing: border-box;
}
.form-picker-val {
font-size: 28px;
color: var(--text-primary);
}
.form-picker-ph {
font-size: 28px;
color: var(--text-secondary);
}
.form-row {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 32px;
}
.form-label {
font-size: 28px;
color: var(--text-primary);
}
.checkbox {
width: 44px;
height: 44px;
border: 3px dashed var(--line-star);
border-radius: 10px;
}
.checkbox.checked {
background: var(--accent-pink);
border-color: var(--accent-pink);
}
.form-actions {
display: flex;
gap: 20px;
}
.form-actions .btn-outline,
.form-actions .btn-gradient {
flex: 1;
padding: 20px 0;
text-align: center;
}
/* 空状态统一的在 app.scss */
.login-guard {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 120px 40px;
}
.login-guard-icon {
font-size: 80px;
margin-bottom: 24px;
}
.login-guard-title {
font-size: 36px;
font-weight: 700;
color: var(--text-primary);
margin-bottom: 12px;
}
.login-guard-desc {
font-size: 28px;
color: var(--text-secondary);
margin-bottom: 32px;
}
.login-guard-btn {
padding: 20px 48px;
}
+189
View File
@@ -0,0 +1,189 @@
import { View, Text, Input, Picker } from '@tarojs/components'
import Taro from '@tarojs/taro'
import { useState, useEffect } from 'react'
import './index.scss'
import { getAddressList, addAddress, updateAddress, deleteAddress } from '../../utils/store'
import type { AddressItem } from '../../types'
import ThemeToggle from '../../components/ThemeToggle'
import { useThemeContext } from '../../context/ThemeContext'
export default function AddressPage() {
const { theme } = useThemeContext()
const [list, setList] = useState<AddressItem[]>([])
const [editing, setEditing] = useState<AddressItem | null>(null)
const [showForm, setShowForm] = useState(false)
const [name, setName] = useState('')
const [phone, setPhone] = useState('')
const [region, setRegion] = useState<string[]>([])
const [detail, setDetail] = useState('')
const [isDefault, setIsDefault] = useState(false)
const load = () => setList(getAddressList())
useEffect(() => {
load()
}, [])
const resetForm = () => {
setName('')
setPhone('')
setRegion([])
setDetail('')
setIsDefault(false)
setEditing(null)
}
const openAdd = () => {
resetForm()
setShowForm(true)
}
const openEdit = (item: AddressItem) => {
setEditing(item)
setName(item.name)
setPhone(item.phone)
setRegion(item.region)
setDetail(item.detail)
setIsDefault(item.isDefault)
setShowForm(true)
}
const handleDelete = (id: string) => {
Taro.showModal({
title: '确认删除',
content: '删除后将无法恢复该地址',
success: (res) => {
if (res.confirm) {
deleteAddress(id)
load()
}
}
})
}
const handleCopy = (item: AddressItem) => {
const text = `${item.name} ${item.phone}\n${item.region.join(' ')} ${item.detail}`
Taro.setClipboardData({ data: text })
}
const handleSave = () => {
if (!name.trim() || !phone.trim() || region.length === 0 || !detail.trim()) {
Taro.showToast({ title: '请填写完整信息', icon: 'none' })
return
}
const payload = { name, phone, region, detail, isDefault }
if (editing) {
updateAddress(editing.id, payload)
} else {
addAddress(payload)
}
Taro.showToast({ title: '保存成功', icon: 'success' })
setShowForm(false)
resetForm()
load()
}
const onRegionChange = (e: any) => {
setRegion(e.detail.value || [])
}
return (
<View className={`theme-${theme}`}>
<View className='address-page'>
<ThemeToggle />
<View className='page-header dashed-card mt-20'>
<View className='star-badge' />
<View className='flex-between' style={{ width: '100%' }}>
<Text className='back-btn' onClick={() => Taro.navigateBack()}></Text>
<Text className='page-title'></Text>
<View style={{ width: '60px' }} />
</View>
</View>
{/* 地址列表 */}
<View className='address-list'>
{list.map(item => (
<View key={item.id} className='address-card dashed-card'>
<View className='address-header'>
<View className='address-user'>
<Text className='address-name'>{item.name}</Text>
<Text className='address-phone'>{item.phone}</Text>
{item.isDefault && (
<View className='default-tag'><Text></Text></View>
)}
</View>
<Text className='address-full'>
{item.region.join(' ')} {item.detail}
</Text>
</View>
<View className='address-actions'>
<Text className='address-act' onClick={() => openEdit(item)}> </Text>
<Text className='address-act' onClick={() => handleCopy(item)}>📋 </Text>
<Text className='address-act delete' onClick={() => handleDelete(item.id)}>🗑 </Text>
</View>
</View>
))}
{list.length === 0 && (
<View className='empty-state'>
<Text className='empty-icon'>📍</Text>
<Text className='empty-text'></Text>
<Text className='empty-sub'></Text>
</View>
)}
</View>
<View className='safe-bottom-placeholder' />
{/* 底部添加按钮 */}
<View className='action-bar'>
<View className='btn-gradient' onClick={openAdd}>
<Text></Text>
</View>
</View>
{/* 新增/编辑弹窗 */}
{showForm && (
<View className='modal-overlay'>
<View className='modal-card dashed-card address-form'>
<View className='star-badge' />
<Text className='modal-title'>{editing ? '编辑地址' : '新增地址'}</Text>
<Input className='form-input' placeholder='收货人姓名'
value={name} onInput={(e: any) => setName(e.detail.value)} />
<Input className='form-input' placeholder='手机号码' type='number'
value={phone} onInput={(e: any) => setPhone(e.detail.value)} />
<Picker mode='region' value={region} onChange={onRegionChange}>
<View className='form-picker'>
<Text className={region.length ? 'form-picker-val' : 'form-picker-ph'}>
{region.length ? region.join(' / ') : '选择省 / 市 / 区'}
</Text>
</View>
</Picker>
<Input className='form-input' placeholder='详细地址:街道、门牌号'
value={detail} onInput={(e: any) => setDetail(e.detail.value)} />
<View className='form-row' onClick={() => setIsDefault(!isDefault)}>
<Text className='form-label'></Text>
<View className={`checkbox ${isDefault ? 'checked' : ''}`} />
</View>
<View className='form-actions'>
<View className='btn-outline' onClick={() => { setShowForm(false); resetForm() }}>
<Text></Text>
</View>
<View className='btn-gradient' onClick={handleSave}>
<Text></Text>
</View>
</View>
</View>
</View>
)}
</View>
</View>
)
}