修复管理师端预约与登录体验
This commit is contained in:
@@ -3,7 +3,14 @@ const customersApi = require('../../api/customers')
|
||||
Page({
|
||||
data: {
|
||||
keyword: '',
|
||||
customers: []
|
||||
customers: [],
|
||||
loadError: '',
|
||||
createModalVisible: false,
|
||||
creating: false,
|
||||
createForm: {
|
||||
nickname: '',
|
||||
phone: ''
|
||||
}
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
@@ -17,15 +24,11 @@ Page({
|
||||
},
|
||||
|
||||
async loadCustomers() {
|
||||
const fallback = [
|
||||
{ id: 1, name: '王女士', phone: '138****1201', lastTime: '2026-06-01' },
|
||||
{ id: 2, name: '陈女士', phone: '136****8842', lastTime: '2026-05-29' },
|
||||
{ id: 3, name: '林女士', phone: '159****6671', lastTime: '2026-05-27' }
|
||||
]
|
||||
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 || '客户',
|
||||
@@ -34,11 +37,65 @@ Page({
|
||||
}))
|
||||
})
|
||||
} catch (error) {
|
||||
this.setData({ customers: fallback })
|
||||
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 })
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
<view class="page">
|
||||
<view class="search-card card">
|
||||
<input value="{{keyword}}" bindinput="onSearchInput" placeholder="搜索客户姓名或手机号" />
|
||||
<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>
|
||||
@@ -13,4 +21,24 @@
|
||||
<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>
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
.customer-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14rpx;
|
||||
}
|
||||
|
||||
.search-card {
|
||||
flex: 1;
|
||||
padding: 0 24rpx;
|
||||
height: 84rpx;
|
||||
display: flex;
|
||||
@@ -37,3 +44,106 @@
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user