统一甲屿云命名体系

This commit is contained in:
2026-06-29 23:26:43 +08:00
parent 48c47fe3ff
commit bc8a7d8d4c
1268 changed files with 3477 additions and 3511 deletions
+101
View File
@@ -0,0 +1,101 @@
const customersApi = require('../../api/customers')
Page({
data: {
keyword: '',
customers: [],
loadError: '',
createModalVisible: false,
creating: false,
createForm: {
nickname: '',
phone: ''
}
},
onLoad() {
this.loadCustomers()
},
onSearchInput(event) {
this.setData({ keyword: event.detail.value })
clearTimeout(this._timer)
this._timer = setTimeout(() => this.loadCustomers(), 300)
},
async loadCustomers() {
try {
const data = await customersApi.list({ keyword: this.data.keyword, page: 1, size: 30 })
const list = data.list || data || []
this.setData({
loadError: '',
customers: list.map(item => ({
id: item.id,
name: item.nickname || item.name || item.account || '客户',
phone: item.contactPhone || item.phone || '未填写',
lastTime: item.lastOrderTime || item.lastConsumeTime || '-'
}))
})
} catch (error) {
this.setData({
customers: [],
loadError: error.message || '客户列表加载失败'
})
}
},
openDetail(event) {
wx.navigateTo({ url: `/pages/customer-detail/index?id=${event.currentTarget.dataset.id}` })
},
addCustomer() {
this.setData({ createModalVisible: true })
},
closeCreateModal() {
if (this.data.creating) {
return
}
this.setData({ createModalVisible: false })
},
stopTap() {
},
onCreateInput(event) {
this.setData({
[`createForm.${event.currentTarget.dataset.field}`]: event.detail.value
})
},
resetCreateForm() {
this.setData({
createForm: {
nickname: '',
phone: ''
}
})
},
async submitCustomer() {
const form = this.data.createForm
const nickname = String(form.nickname || '').trim()
const phone = String(form.phone || '').trim()
if (!nickname || !phone) {
wx.showToast({ title: '请填写客户姓名和手机号', icon: 'none' })
return
}
this.setData({ creating: true })
try {
await customersApi.create({ nickname, phone })
wx.showToast({ title: '客户已新增', icon: 'success' })
this.resetCreateForm()
this.setData({ createModalVisible: false })
await this.loadCustomers()
} catch (error) {
wx.showToast({ title: error.message || '新增失败', icon: 'none' })
} finally {
this.setData({ creating: false })
}
}
})
@@ -0,0 +1,3 @@
{
"navigationBarTitleText": "客户"
}
@@ -0,0 +1,44 @@
<view class="page">
<view class="customer-toolbar">
<view class="search-card card">
<input value="{{keyword}}" bindinput="onSearchInput" placeholder="搜索客户姓名或手机号" />
</view>
<button class="compact-btn" bindtap="addCustomer">新增</button>
</view>
<view class="list section">
<view wx:if="{{loadError}}" class="empty card">
<text>{{loadError}}</text>
<button class="secondary-btn retry-btn" bindtap="loadCustomers">重试</button>
</view>
<view wx:elif="{{customers.length === 0}}" class="empty card">暂无客户</view>
<view wx:for="{{customers}}" wx:key="id" class="card list-card customer-card" data-id="{{item.id}}" bindtap="openDetail">
<view>
<text class="name">{{item.name}}</text>
<text class="meta">{{item.phone}}</text>
<text class="meta">最近消费 {{item.lastTime}}</text>
</view>
<text class="arrow">›</text>
</view>
</view>
<view wx:if="{{createModalVisible}}" class="modal-mask" bindtap="closeCreateModal">
<view class="customer-modal" catchtap="stopTap">
<view class="modal-head">
<text class="modal-title">新增客户</text>
<view class="modal-close" bindtap="closeCreateModal">×</view>
</view>
<view class="form-grid">
<view class="modal-field">
<text class="required-label">客户姓名</text>
<input value="{{createForm.nickname}}" data-field="nickname" bindinput="onCreateInput" placeholder="请输入客户姓名" />
</view>
<view class="modal-field">
<text class="required-label">手机号</text>
<input value="{{createForm.phone}}" data-field="phone" bindinput="onCreateInput" type="number" placeholder="请输入手机号" />
</view>
</view>
<button class="primary-btn modal-submit" loading="{{creating}}" bindtap="submitCustomer">保存客户</button>
</view>
</view>
</view>
+149
View File
@@ -0,0 +1,149 @@
.customer-toolbar {
display: flex;
align-items: center;
gap: 14rpx;
}
.search-card {
flex: 1;
padding: 0 24rpx;
height: 84rpx;
display: flex;
align-items: center;
}
.search-card input {
width: 100%;
font-size: 26rpx;
}
.customer-card {
display: flex;
align-items: center;
justify-content: space-between;
}
.name,
.meta {
display: block;
}
.name {
color: #292520;
font-size: 30rpx;
font-weight: 800;
}
.meta {
margin-top: 8rpx;
color: #928a81;
font-size: 24rpx;
}
.arrow {
color: #b0a79e;
font-size: 48rpx;
}
.retry-btn {
width: 180rpx;
min-width: 180rpx;
max-width: 180rpx;
margin: 24rpx auto 0;
}
.modal-mask {
position: fixed;
inset: 0;
z-index: 80;
display: flex;
align-items: flex-end;
justify-content: center;
background: rgba(18, 15, 12, 0.48);
}
.customer-modal {
width: 100%;
padding: 28rpx 28rpx calc(28rpx + env(safe-area-inset-bottom));
border-radius: 28rpx 28rpx 0 0;
background: #fffaf4;
box-shadow: 0 -18rpx 40rpx rgba(41, 31, 23, 0.16);
}
.modal-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 20rpx;
margin-bottom: 20rpx;
}
.modal-title {
color: #27211d;
font-size: 34rpx;
font-weight: 900;
}
.modal-close {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 48rpx;
min-width: 48rpx;
height: 48rpx;
border: 1rpx solid #e4d8ca;
border-radius: 50%;
background: #fffaf4;
color: transparent;
font-size: 0;
line-height: 0;
}
.modal-close::before,
.modal-close::after {
content: "";
position: absolute;
width: 22rpx;
height: 3rpx;
border-radius: 999rpx;
background: #61554c;
}
.modal-close::before {
transform: rotate(45deg);
}
.modal-close::after {
transform: rotate(-45deg);
}
.form-grid {
display: grid;
grid-template-columns: 1fr;
gap: 16rpx;
}
.modal-field {
padding: 16rpx 18rpx;
border-radius: 18rpx;
background: #f7efe7;
}
.modal-field text {
display: block;
margin-bottom: 8rpx;
color: #6c5f54;
font-size: 24rpx;
font-weight: 800;
}
.modal-field input {
height: 58rpx;
color: #2c2722;
font-size: 28rpx;
}
.modal-submit {
margin-top: 22rpx;
}