重构项目文件夹目录
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
const employeesApi = require('../../api/employees')
|
||||
const mock = require('../../utils/mock')
|
||||
|
||||
Page({
|
||||
data: {
|
||||
employees: []
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.loadEmployees()
|
||||
},
|
||||
|
||||
async loadEmployees() {
|
||||
const fallback = mock.artists.map((item, index) => ({
|
||||
...item,
|
||||
monthOrders: 32 - index * 5,
|
||||
monthAmount: 5800 - index * 760
|
||||
}))
|
||||
try {
|
||||
const data = await employeesApi.list({ page: 1, size: 50 })
|
||||
const list = data.list || data || []
|
||||
this.setData({
|
||||
employees: list.map((item, index) => ({
|
||||
id: item.userId || item.id,
|
||||
name: item.nickname || item.name || item.artistName || `美甲师${index + 1}`,
|
||||
shortName: (item.nickname || item.name || '师').slice(-1),
|
||||
color: mock.artists[index % mock.artists.length].color,
|
||||
monthOrders: item.monthOrders || item.orderCount || 0,
|
||||
monthAmount: item.monthAmount || item.turnover || 0
|
||||
}))
|
||||
})
|
||||
} catch (error) {
|
||||
this.setData({ employees: fallback })
|
||||
}
|
||||
},
|
||||
|
||||
openDetail(event) {
|
||||
wx.navigateTo({ url: `/pages/employee-detail/index?id=${event.currentTarget.dataset.id}` })
|
||||
},
|
||||
|
||||
addEmployee() {
|
||||
wx.showToast({ title: '员工创建沿用后台账号', icon: 'none' })
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"navigationBarTitleText": "员工"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<view class="page">
|
||||
<view class="list-heading">
|
||||
<text>美甲师</text>
|
||||
<button class="compact-btn" bindtap="addEmployee">新增</button>
|
||||
</view>
|
||||
|
||||
<view class="list">
|
||||
<view wx:for="{{employees}}" wx:key="id" class="card employee-card" data-id="{{item.id}}" bindtap="openDetail">
|
||||
<view class="employee-left">
|
||||
<view class="avatar" style="background: {{item.color}};">{{item.shortName}}</view>
|
||||
<view>
|
||||
<text class="employee-name">{{item.name}}</text>
|
||||
<text class="employee-meta">本月 {{item.monthOrders}} 单 · ¥{{item.monthAmount}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="color-pill" style="background: {{item.color}};"></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,66 @@
|
||||
.list-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
width: 100%;
|
||||
margin-bottom: 16rpx;
|
||||
color: #4c4740;
|
||||
font-size: 28rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.list-heading text {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.list-heading .compact-btn {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.employee-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 22rpx;
|
||||
}
|
||||
|
||||
.employee-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 18rpx;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 78rpx;
|
||||
height: 78rpx;
|
||||
border-radius: 50%;
|
||||
color: #fff;
|
||||
font-size: 28rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.employee-name,
|
||||
.employee-meta {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.employee-name {
|
||||
color: #25211d;
|
||||
font-size: 28rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.employee-meta {
|
||||
margin-top: 8rpx;
|
||||
color: #91897f;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.color-pill {
|
||||
width: 44rpx;
|
||||
height: 18rpx;
|
||||
border-radius: 999rpx;
|
||||
}
|
||||
Reference in New Issue
Block a user