美甲师选择ui优化
This commit is contained in:
+305
-26
@@ -196,22 +196,51 @@
|
||||
width="90%"
|
||||
@ok="selectArtistAndCheckout"
|
||||
@cancel="closeArtistModal"
|
||||
|
||||
>
|
||||
<div class="artist-modal-content">
|
||||
<a-empty v-if="availableArtists.length === 0" description="暂无可用美甲师" />
|
||||
<div v-else class="artist-list">
|
||||
<a-radio-group v-model:value="selectedArtist" name="artist">
|
||||
<a-radio
|
||||
<div class="artist-list-container">
|
||||
<div
|
||||
v-for="artist in availableArtists"
|
||||
:key="artist.id"
|
||||
:value="artist"
|
||||
class="artist-item"
|
||||
:class="{ 'selected': selectedArtist && selectedArtist.id === artist.id }"
|
||||
@click="toggleArtistSelection(artist)"
|
||||
>
|
||||
<div class="artist-info">
|
||||
<span class="artist-name">{{ artist.name }}</span>
|
||||
<div class="artist-card">
|
||||
<div class="artist-avatar">
|
||||
<img
|
||||
:src="getArtistAvatar(artist)"
|
||||
:alt="artist.name"
|
||||
class="avatar-image"
|
||||
/>
|
||||
</div>
|
||||
<div class="artist-details">
|
||||
<div class="artist-header">
|
||||
<h3 class="artist-name">{{ artist.name }}</h3>
|
||||
<div class="artist-rating">
|
||||
<span class="rating-star">⭐</span>
|
||||
<span class="rating-score">{{ getRandomRating() }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="artist-info">
|
||||
<span class="artist-experience">经验: {{ getRandomExperience() }}年</span>
|
||||
<span class="artist-status" :class="{ 'available': artist.status === 1 }">
|
||||
{{ artist.status === 1 ? '可预约' : '不可预约' }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="artist-skills">
|
||||
<span class="skill-tag" v-for="skill in getRandomSkills()" :key="skill">{{ skill }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="artist-selection-indicator" v-if="selectedArtist && selectedArtist.id === artist.id">
|
||||
<CheckCircleOutlined style="color: #1890ff; font-size: 20px;" />
|
||||
</div>
|
||||
</div>
|
||||
</a-radio>
|
||||
</a-radio-group>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a-modal>
|
||||
@@ -243,6 +272,7 @@ interface CartItem {
|
||||
productId: number
|
||||
productTitle: string
|
||||
productImage: string
|
||||
originalProductImage?: string
|
||||
price: number
|
||||
quantity: number
|
||||
totalPrice: number
|
||||
@@ -269,7 +299,10 @@ const loadCartItems = async () => {
|
||||
const response = await cartApi.getCartList() as any
|
||||
cartItems.value = response.map((item: any) => ({
|
||||
...item,
|
||||
selected: true
|
||||
selected: true,
|
||||
// 临时将productImage设为空,避免浏览器直接加载本地API路径
|
||||
originalProductImage: item.productImage,
|
||||
productImage: ''
|
||||
}))
|
||||
|
||||
await loadProductImages(cartItems.value)
|
||||
@@ -282,20 +315,29 @@ const loadCartItems = async () => {
|
||||
// 加载商品图片
|
||||
const loadProductImages = async (items: CartItem[]) => {
|
||||
for (const item of items) {
|
||||
if (item.productImage) {
|
||||
const cleanImageUrl = item.productImage.replace(/<[^>]*>/g, '')
|
||||
if (item.originalProductImage) {
|
||||
const cleanImageUrl = item.originalProductImage.replace(/<[^>]*>/g, '')
|
||||
|
||||
const match = cleanImageUrl.match(/\/api\/file\/get\/(\d+)/)
|
||||
if (match && match[1]) {
|
||||
const imageId = match[1]
|
||||
try {
|
||||
if (!imageIdCache.value[imageId]) {
|
||||
const response = await fileApi.getSignedUrl(Number(imageId)) as any
|
||||
imageIdCache.value[imageId] = response
|
||||
// 尝试获取签名URL
|
||||
try {
|
||||
const response = await fileApi.getSignedUrl(Number(imageId)) as any
|
||||
imageIdCache.value[imageId] = response
|
||||
item.productImage = imageIdCache.value[imageId]
|
||||
} catch (error) {
|
||||
// 静默处理404错误,不显示错误信息
|
||||
console.log('图片不存在或无法获取签名URL:', imageId)
|
||||
item.productImage = ''
|
||||
}
|
||||
} else {
|
||||
item.productImage = imageIdCache.value[imageId]
|
||||
}
|
||||
item.productImage = imageIdCache.value[imageId]
|
||||
} catch (error) {
|
||||
console.error('获取图片签名链接失败:', error)
|
||||
console.error('处理图片时出错:', error)
|
||||
item.productImage = ''
|
||||
}
|
||||
} else {
|
||||
@@ -469,8 +511,8 @@ const cancelCouponSelection = () => {
|
||||
|
||||
// 美甲师选择相关状态
|
||||
const showArtistModal = ref(false)
|
||||
const selectedArtist = ref<{id: number, name: string} | null>(null)
|
||||
const availableArtists = ref<{id: number, name: string}[]>([])
|
||||
const selectedArtist = ref<{id: number, name: string, avatar?: string, signature?: string, shopName?: string, status?: number} | null>(null)
|
||||
const availableArtists = ref<{id: number, name: string, avatar?: string, signature?: string, shopName?: string, status?: number}[]>([])
|
||||
|
||||
// 加载可用美甲师
|
||||
const loadAvailableArtists = async () => {
|
||||
@@ -478,7 +520,11 @@ const loadAvailableArtists = async () => {
|
||||
const response = await userApi.listUsersByType(3) as any
|
||||
availableArtists.value = response.map((artist: any) => ({
|
||||
id: artist.id,
|
||||
name: artist.nickname
|
||||
name: artist.nickname,
|
||||
avatar: artist.avatar,
|
||||
signature: artist.signature,
|
||||
shopName: artist.shopName,
|
||||
status: artist.status
|
||||
}))
|
||||
} catch (error) {
|
||||
console.error('获取美甲师列表失败:', error)
|
||||
@@ -529,6 +575,47 @@ const closeArtistModal = () => {
|
||||
selectedArtist.value = null
|
||||
}
|
||||
|
||||
// 获取美甲师头像
|
||||
const getArtistAvatar = (artist: any) => {
|
||||
// 优先使用用户表中的真实头像
|
||||
if (artist.avatar) {
|
||||
return artist.avatar
|
||||
}
|
||||
// 生成基于ID的随机头像
|
||||
const colors = ['#FF6B6B', '#4ECDC4', '#45B7D1', '#96CEB4', '#FFEAA7', '#DDA0DD']
|
||||
const color = colors[artist.id % colors.length]
|
||||
return `https://api.dicebear.com/7.x/avataaars/svg?seed=${artist.id}&backgroundColor=${color.replace('#', '')}`
|
||||
}
|
||||
|
||||
// 获取随机评分
|
||||
const getRandomRating = () => {
|
||||
return (4 + Math.random()).toFixed(1)
|
||||
}
|
||||
|
||||
// 获取随机经验
|
||||
const getRandomExperience = () => {
|
||||
return Math.floor(1 + Math.random() * 5)
|
||||
}
|
||||
|
||||
// 获取随机技能标签
|
||||
const getRandomSkills = () => {
|
||||
const allSkills = ['手绘', '雕花', '水晶甲', '光疗甲', '渐变', '法式', '钻饰', '创意美甲']
|
||||
const skillsCount = 2 + Math.floor(Math.random() * 3)
|
||||
const shuffled = allSkills.sort(() => 0.5 - Math.random())
|
||||
return shuffled.slice(0, skillsCount)
|
||||
}
|
||||
|
||||
// 切换美甲师选择状态
|
||||
const toggleArtistSelection = (artist: any) => {
|
||||
if (selectedArtist.value && selectedArtist.value.id === artist.id) {
|
||||
// 取消选择
|
||||
selectedArtist.value = null
|
||||
} else {
|
||||
// 选择新的美甲师
|
||||
selectedArtist.value = artist
|
||||
}
|
||||
}
|
||||
|
||||
// 监听选中商品变化,重新加载可用优惠券
|
||||
watch(
|
||||
() => cartItems.value.map(item => ({ id: item.id, selected: item.selected, quantity: item.quantity })),
|
||||
@@ -907,34 +994,226 @@ onMounted(() => {
|
||||
|
||||
/* 美甲师选择弹窗样式 */
|
||||
.artist-modal-content {
|
||||
max-height: 400px;
|
||||
max-height: 500px;
|
||||
overflow-y: auto;
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
.artist-list {
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
.artist-list-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.artist-item {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: 12px 0;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
border-radius: 12px;
|
||||
overflow: hidden;
|
||||
transition: all 0.3s ease;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.artist-item:last-child {
|
||||
border-bottom: none;
|
||||
.artist-item:hover {
|
||||
background-color: #f5f9ff;
|
||||
}
|
||||
|
||||
.artist-item.selected {
|
||||
background-color: #e6f7ff;
|
||||
}
|
||||
|
||||
.artist-card {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 16px;
|
||||
padding: 16px;
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
|
||||
transition: all 0.3s ease;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.artist-item:hover .artist-card {
|
||||
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.artist-item.selected .artist-card {
|
||||
border: 2px solid #1890ff;
|
||||
box-shadow: 0 0 0 4px rgba(24, 144, 255, 0.1);
|
||||
}
|
||||
|
||||
.artist-selection-indicator {
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
right: 12px;
|
||||
background: white;
|
||||
border-radius: 50%;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.artist-avatar {
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.avatar-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 50%;
|
||||
object-fit: cover;
|
||||
border: 3px solid #f0f0f0;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.artist-item:hover .avatar-image {
|
||||
border-color: #1890ff;
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.artist-details {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.artist-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.artist-name {
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
color: #333;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.artist-rating {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
background: linear-gradient(135deg, #ffd700, #ffed4e);
|
||||
padding: 4px 12px;
|
||||
border-radius: 16px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
box-shadow: 0 2px 4px rgba(255, 215, 0, 0.3);
|
||||
}
|
||||
|
||||
.rating-star {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.rating-score {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.artist-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
gap: 16px;
|
||||
margin-bottom: 10px;
|
||||
font-size: 14px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.artist-name {
|
||||
font-size: 15px;
|
||||
.artist-experience {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.artist-status {
|
||||
padding: 2px 10px;
|
||||
border-radius: 12px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.artist-status.available {
|
||||
background: #f6ffed;
|
||||
color: #52c41a;
|
||||
border: 1px solid #b7eb8f;
|
||||
}
|
||||
|
||||
.artist-skills {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.skill-tag {
|
||||
padding: 4px 12px;
|
||||
background: #f0f9ff;
|
||||
color: #1890ff;
|
||||
border: 1px solid #e6f7ff;
|
||||
border-radius: 16px;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.skill-tag:hover {
|
||||
background: #e6f7ff;
|
||||
transform: scale(1.05);
|
||||
box-shadow: 0 2px 4px rgba(24, 144, 255, 0.2);
|
||||
}
|
||||
|
||||
/* 弹窗按钮样式 */
|
||||
.artist-modal-cancel {
|
||||
border-radius: 20px !important;
|
||||
padding: 0 24px !important;
|
||||
}
|
||||
|
||||
:deep(.ant-modal-footer .ant-btn-primary) {
|
||||
border-radius: 20px !important;
|
||||
padding: 0 24px !important;
|
||||
font-weight: 600 !important;
|
||||
}
|
||||
|
||||
:deep(.ant-modal-header) {
|
||||
border-bottom: none !important;
|
||||
padding: 24px 24px 0 !important;
|
||||
}
|
||||
|
||||
:deep(.ant-modal-title) {
|
||||
font-size: 20px !important;
|
||||
font-weight: 700 !important;
|
||||
color: #333 !important;
|
||||
text-align: center !important;
|
||||
}
|
||||
|
||||
:deep(.ant-modal-body) {
|
||||
padding: 24px !important;
|
||||
}
|
||||
|
||||
|
||||
|
||||
:deep(.ant-empty) {
|
||||
padding: 40px 0 !important;
|
||||
}
|
||||
|
||||
:deep(.ant-empty-image) {
|
||||
font-size: 60px !important;
|
||||
}
|
||||
|
||||
:deep(.ant-empty-description) {
|
||||
font-size: 16px !important;
|
||||
color: #999 !important;
|
||||
margin-top: 16px !important;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user