重构项目文件夹目录
This commit is contained in:
@@ -0,0 +1,136 @@
|
||||
const nailArtistApi = require('../../api/nail-artist')
|
||||
const navigation = require('../../utils/navigation')
|
||||
const { DEFAULT_PRODUCT_IMAGE } = require('../../utils/config')
|
||||
|
||||
function formatPrice(price) {
|
||||
const value = Number(price || 0)
|
||||
return value > 0 ? `¥${value.toFixed(2)}` : '到店确认'
|
||||
}
|
||||
|
||||
function formatDateTime(value) {
|
||||
if (!value) {
|
||||
return ''
|
||||
}
|
||||
return String(value).replace('T', ' ').slice(0, 16)
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
loading: true,
|
||||
loadError: '',
|
||||
artistId: '',
|
||||
profile: null,
|
||||
works: [],
|
||||
reviews: [],
|
||||
availability: [],
|
||||
heroImage: DEFAULT_PRODUCT_IMAGE,
|
||||
artistName: '美甲师',
|
||||
artistDesc: '专注细节与稳定出品',
|
||||
shopName: '门店待确认',
|
||||
styleTags: [],
|
||||
ratingText: '0.0',
|
||||
serviceCountText: '0',
|
||||
workTimeText: '到店确认'
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
this.setData({
|
||||
artistId: options && options.id ? options.id : ''
|
||||
})
|
||||
this.loadArtistProfile()
|
||||
},
|
||||
|
||||
async onPullDownRefresh() {
|
||||
await this.loadArtistProfile()
|
||||
wx.stopPullDownRefresh()
|
||||
},
|
||||
|
||||
async loadArtistProfile() {
|
||||
if (!this.data.artistId) {
|
||||
this.setData({
|
||||
loading: false,
|
||||
loadError: '缺少美甲师信息'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
this.setData({
|
||||
loading: true,
|
||||
loadError: ''
|
||||
})
|
||||
|
||||
try {
|
||||
const [profile, availability, reviews] = await Promise.all([
|
||||
nailArtistApi.getPublicProfile(this.data.artistId),
|
||||
nailArtistApi.getAvailability(this.data.artistId),
|
||||
nailArtistApi.listReviews(this.data.artistId)
|
||||
])
|
||||
const works = (profile.works || []).map(work => ({
|
||||
...work,
|
||||
title: work.title || '美甲作品',
|
||||
coverImageUrl: work.coverImageUrl || DEFAULT_PRODUCT_IMAGE,
|
||||
priceText: formatPrice(work.price)
|
||||
}))
|
||||
const formattedReviews = (reviews || profile.reviews || []).map(review => ({
|
||||
...review,
|
||||
customerName: review.customerName || '匿名用户',
|
||||
content: review.content || '这位用户没有填写文字评价',
|
||||
submittedAtText: formatDateTime(review.submittedAt),
|
||||
ratingText: Number(review.rating || 0).toFixed(1)
|
||||
}))
|
||||
const start = profile.workStartTime ? String(profile.workStartTime).slice(0, 5) : ''
|
||||
const end = profile.workEndTime ? String(profile.workEndTime).slice(0, 5) : ''
|
||||
|
||||
this.setData({
|
||||
profile,
|
||||
works,
|
||||
reviews: formattedReviews,
|
||||
availability: availability || profile.availability || [],
|
||||
heroImage: (works.find(work => work.coverImageUrl) || {}).coverImageUrl || DEFAULT_PRODUCT_IMAGE,
|
||||
artistName: profile.artistName || '美甲师',
|
||||
artistDesc: profile.identity || profile.signature || '专注细节与稳定出品',
|
||||
shopName: profile.shopName || '门店待确认',
|
||||
styleTags: (profile.styleTags || []).filter(Boolean),
|
||||
ratingText: Number(profile.rating || 0).toFixed(1),
|
||||
serviceCountText: String(profile.serviceCount || 0),
|
||||
workTimeText: start && end ? `${start}-${end}` : '到店确认'
|
||||
})
|
||||
} catch (error) {
|
||||
this.setData({
|
||||
loadError: error.message || '美甲师个人页加载失败'
|
||||
})
|
||||
} finally {
|
||||
this.setData({
|
||||
loading: false
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
handleBack() {
|
||||
navigation.goBack('/pages/home/index')
|
||||
},
|
||||
|
||||
handleRetry() {
|
||||
this.loadArtistProfile()
|
||||
},
|
||||
|
||||
handleOpenShop() {
|
||||
const profile = this.data.profile
|
||||
if (!profile || !profile.shopId) {
|
||||
return
|
||||
}
|
||||
wx.navigateTo({
|
||||
url: `/pages/shop-detail/index?id=${profile.shopId}`
|
||||
})
|
||||
},
|
||||
|
||||
handleOpenWork(event) {
|
||||
const id = event.currentTarget.dataset.id
|
||||
if (!id) {
|
||||
return
|
||||
}
|
||||
wx.navigateTo({
|
||||
url: `/pages/product-detail/index?id=${id}`
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"navigationStyle": "custom",
|
||||
"usingComponents": {}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<view class="artist-page">
|
||||
<view class="page-header">
|
||||
<view class="back-btn" bindtap="handleBack">‹</view>
|
||||
<text class="page-title">{{artistName}}</text>
|
||||
<view class="header-spacer"></view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{loading}}" class="state-box">
|
||||
<text>加载中...</text>
|
||||
</view>
|
||||
|
||||
<view wx:elif="{{loadError}}" class="state-box">
|
||||
<text class="state-title">暂时无法查看个人页</text>
|
||||
<text class="state-desc">{{loadError}}</text>
|
||||
<view class="primary-btn" bindtap="handleRetry">重试</view>
|
||||
</view>
|
||||
|
||||
<scroll-view wx:else scroll-y class="content-scroll">
|
||||
<view class="hero">
|
||||
<image class="hero-image" src="{{heroImage}}" mode="aspectFill"></image>
|
||||
<view class="hero-mask"></view>
|
||||
<view class="artist-card">
|
||||
<image wx:if="{{profile.avatar}}" class="avatar" src="{{profile.avatar}}" mode="aspectFill"></image>
|
||||
<view wx:else class="avatar placeholder">艺</view>
|
||||
<view class="artist-main">
|
||||
<text class="artist-name">{{artistName}}</text>
|
||||
<text class="artist-desc">{{artistDesc}}</text>
|
||||
<view class="shop-link" bindtap="handleOpenShop">{{shopName}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="metrics">
|
||||
<view class="metric-item">
|
||||
<text>评分</text>
|
||||
<text class="metric-value">{{ratingText}}</text>
|
||||
</view>
|
||||
<view class="metric-item">
|
||||
<text>服务</text>
|
||||
<text class="metric-value">{{serviceCountText}}</text>
|
||||
</view>
|
||||
<view class="metric-item">
|
||||
<text>工时</text>
|
||||
<text class="metric-value">{{workTimeText}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="section">
|
||||
<view class="section-head">擅长风格</view>
|
||||
<view class="tag-list" wx:if="{{styleTags.length}}">
|
||||
<text class="tag" wx:for="{{styleTags}}" wx:key="*this">{{item}}</text>
|
||||
</view>
|
||||
<text wx:else class="empty-text">暂未设置风格标签</text>
|
||||
</view>
|
||||
|
||||
<view class="section">
|
||||
<view class="section-head">近期可预约</view>
|
||||
<view class="slot-grid" wx:if="{{availability.length}}">
|
||||
<view class="slot" wx:for="{{availability}}" wx:key="startTime">
|
||||
<text>{{item.dateText}}</text>
|
||||
<text class="slot-time">{{item.timeText}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<text wx:else class="empty-text">近期暂未放出可预约时间</text>
|
||||
</view>
|
||||
|
||||
<view class="section">
|
||||
<view class="section-head">作品</view>
|
||||
<view class="work-grid" wx:if="{{works.length}}">
|
||||
<view class="work-card" wx:for="{{works}}" wx:key="id" data-id="{{item.id}}" bindtap="handleOpenWork">
|
||||
<image src="{{item.coverImageUrl}}" mode="aspectFill"></image>
|
||||
<text class="work-title">{{item.title}}</text>
|
||||
<text class="work-price">{{item.priceText}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<text wx:else class="empty-text">作品正在整理中</text>
|
||||
</view>
|
||||
|
||||
<view class="section">
|
||||
<view class="section-head">评价 {{reviews.length}}</view>
|
||||
<view class="review-list" wx:if="{{reviews.length}}">
|
||||
<view class="review-card" wx:for="{{reviews}}" wx:key="id">
|
||||
<view class="review-top">
|
||||
<image wx:if="{{item.customerAvatar}}" class="review-avatar" src="{{item.customerAvatar}}" mode="aspectFill"></image>
|
||||
<view wx:else class="review-avatar placeholder">客</view>
|
||||
<view class="review-meta">
|
||||
<text>{{item.customerName}}</text>
|
||||
<text>{{item.submittedAtText}}</text>
|
||||
</view>
|
||||
<text class="review-score">{{item.ratingText}}</text>
|
||||
</view>
|
||||
<text class="review-content">{{item.content}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<text wx:else class="empty-text">还没有公开评价</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
@@ -0,0 +1,336 @@
|
||||
.artist-page {
|
||||
min-height: 100vh;
|
||||
background: #f6f7fb;
|
||||
color: #1f2933;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
height: 96rpx;
|
||||
padding: 0 24rpx;
|
||||
background: rgba(255, 255, 255, 0.95);
|
||||
border-bottom: 1rpx solid #e6e9ef;
|
||||
}
|
||||
|
||||
.back-btn,
|
||||
.header-spacer {
|
||||
width: 64rpx;
|
||||
height: 64rpx;
|
||||
line-height: 58rpx;
|
||||
text-align: center;
|
||||
font-size: 48rpx;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
text-align: center;
|
||||
font-size: 32rpx;
|
||||
font-weight: 700;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.content-scroll {
|
||||
height: calc(100vh - 96rpx);
|
||||
}
|
||||
|
||||
.state-box {
|
||||
display: flex;
|
||||
min-height: 60vh;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 20rpx;
|
||||
padding: 40rpx;
|
||||
color: #65717f;
|
||||
}
|
||||
|
||||
.state-title {
|
||||
color: #1f2933;
|
||||
font-size: 34rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.state-desc {
|
||||
text-align: center;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.primary-btn {
|
||||
padding: 18rpx 36rpx;
|
||||
color: #fff;
|
||||
background: var(--theme-primary-action);
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.hero {
|
||||
position: relative;
|
||||
height: 520rpx;
|
||||
margin: 20rpx;
|
||||
overflow: hidden;
|
||||
background: #222831;
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
|
||||
.hero-image,
|
||||
.hero-mask {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.hero-mask {
|
||||
background: linear-gradient(180deg, rgba(10, 14, 20, 0.08), rgba(10, 14, 20, 0.72));
|
||||
}
|
||||
|
||||
.artist-card {
|
||||
position: absolute;
|
||||
right: 28rpx;
|
||||
bottom: 28rpx;
|
||||
left: 28rpx;
|
||||
display: flex;
|
||||
gap: 22rpx;
|
||||
align-items: center;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 112rpx;
|
||||
height: 112rpx;
|
||||
flex: 0 0 auto;
|
||||
overflow: hidden;
|
||||
border: 3rpx solid rgba(255, 255, 255, 0.8);
|
||||
border-radius: 56rpx;
|
||||
}
|
||||
|
||||
.placeholder {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: #d8dde6;
|
||||
color: #5f6b7a;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.artist-main {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.artist-name,
|
||||
.artist-desc,
|
||||
.shop-link {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.artist-name {
|
||||
font-size: 44rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.artist-desc {
|
||||
margin-top: 10rpx;
|
||||
color: rgba(255, 255, 255, 0.88);
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.shop-link {
|
||||
max-width: 440rpx;
|
||||
margin-top: 16rpx;
|
||||
padding: 12rpx 18rpx;
|
||||
background: rgba(255, 255, 255, 0.18);
|
||||
border: 1rpx solid rgba(255, 255, 255, 0.28);
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.metrics {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 16rpx;
|
||||
margin: 0 20rpx 20rpx;
|
||||
}
|
||||
|
||||
.metric-item {
|
||||
display: flex;
|
||||
min-height: 132rpx;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
gap: 10rpx;
|
||||
padding: 20rpx;
|
||||
background: #fff;
|
||||
border: 1rpx solid #e6e9ef;
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
|
||||
.metric-item text:first-child {
|
||||
color: #65717f;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.metric-value {
|
||||
overflow-wrap: anywhere;
|
||||
font-size: 34rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.section {
|
||||
margin: 20rpx;
|
||||
padding: 28rpx;
|
||||
background: #fff;
|
||||
border: 1rpx solid #e6e9ef;
|
||||
border-radius: 16rpx;
|
||||
}
|
||||
|
||||
.section-head {
|
||||
margin-bottom: 20rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.tag-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 14rpx;
|
||||
}
|
||||
|
||||
.tag {
|
||||
padding: 10rpx 18rpx;
|
||||
color: #394554;
|
||||
background: #eef1f5;
|
||||
border-radius: 999rpx;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
color: #7b8794;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.slot-grid,
|
||||
.work-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.slot {
|
||||
display: flex;
|
||||
min-height: 104rpx;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
gap: 8rpx;
|
||||
padding: 18rpx;
|
||||
background: #f6f7fb;
|
||||
border: 1rpx solid #dfe4ea;
|
||||
border-radius: 14rpx;
|
||||
}
|
||||
|
||||
.slot text:first-child {
|
||||
color: #65717f;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.slot-time {
|
||||
font-size: 32rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.work-card {
|
||||
overflow: hidden;
|
||||
background: #fff;
|
||||
border: 1rpx solid #e6e9ef;
|
||||
border-radius: 14rpx;
|
||||
}
|
||||
|
||||
.work-card image {
|
||||
width: 100%;
|
||||
height: 210rpx;
|
||||
background: #eef1f5;
|
||||
}
|
||||
|
||||
.work-title,
|
||||
.work-price {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
padding: 0 16rpx;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.work-title {
|
||||
margin-top: 14rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.work-price {
|
||||
margin: 8rpx 0 16rpx;
|
||||
color: var(--theme-primary-action);
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.review-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 18rpx;
|
||||
}
|
||||
|
||||
.review-card {
|
||||
padding: 22rpx;
|
||||
background: #f8fafc;
|
||||
border: 1rpx solid #e6e9ef;
|
||||
border-radius: 14rpx;
|
||||
}
|
||||
|
||||
.review-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.review-avatar {
|
||||
width: 72rpx;
|
||||
height: 72rpx;
|
||||
border-radius: 36rpx;
|
||||
}
|
||||
|
||||
.review-meta {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.review-meta text {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.review-meta text:last-child {
|
||||
margin-top: 4rpx;
|
||||
color: #7b8794;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.review-score {
|
||||
color: var(--theme-primary-action);
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.review-content {
|
||||
display: block;
|
||||
margin-top: 18rpx;
|
||||
color: #3f4a56;
|
||||
line-height: 1.7;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
Reference in New Issue
Block a user