支持店务修改客户联系方式和备注
This commit is contained in:
@@ -20,5 +20,13 @@ module.exports = {
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
},
|
||||
|
||||
update(id, data) {
|
||||
return request({
|
||||
url: `/manager/customers/${id}`,
|
||||
method: 'PUT',
|
||||
data
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,13 @@ Page({
|
||||
customer: {},
|
||||
stats: { orderCount: 0, amount: 0, lastTime: '-' },
|
||||
orders: [],
|
||||
loadError: ''
|
||||
loadError: '',
|
||||
editModalVisible: false,
|
||||
saving: false,
|
||||
editForm: {
|
||||
contactPhone: '',
|
||||
remark: ''
|
||||
}
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
@@ -43,10 +49,16 @@ Page({
|
||||
const customer = {
|
||||
id: detail.id,
|
||||
name: detail.nickname || detail.name || detail.account || '客户',
|
||||
phone: detail.contactPhone || detail.phone || '未填写'
|
||||
phone: detail.contactPhone || detail.phone || '未填写',
|
||||
contactPhone: detail.contactPhone || '',
|
||||
remark: detail.signature || ''
|
||||
}
|
||||
this.setData({
|
||||
customer,
|
||||
editForm: {
|
||||
contactPhone: customer.contactPhone || detail.phone || '',
|
||||
remark: customer.remark
|
||||
},
|
||||
avatarText: String(customer.name || '客').slice(-1),
|
||||
stats: {
|
||||
orderCount: detail.orderCount || detail.totalOrderCount || 0,
|
||||
@@ -66,6 +78,51 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
openEditModal() {
|
||||
const customer = this.data.customer || {}
|
||||
this.setData({
|
||||
editModalVisible: true,
|
||||
editForm: {
|
||||
contactPhone: customer.contactPhone || customer.phone || '',
|
||||
remark: customer.remark || ''
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
closeEditModal() {
|
||||
if (this.data.saving) {
|
||||
return
|
||||
}
|
||||
this.setData({ editModalVisible: false })
|
||||
},
|
||||
|
||||
stopTap() {
|
||||
},
|
||||
|
||||
onEditInput(event) {
|
||||
this.setData({
|
||||
[`editForm.${event.currentTarget.dataset.field}`]: event.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
async saveCustomer() {
|
||||
const form = this.data.editForm || {}
|
||||
this.setData({ saving: true })
|
||||
try {
|
||||
await customersApi.update(this.data.id, {
|
||||
contactPhone: String(form.contactPhone || '').trim(),
|
||||
remark: String(form.remark || '').trim()
|
||||
})
|
||||
wx.showToast({ title: '客户信息已保存', icon: 'success' })
|
||||
this.setData({ editModalVisible: false })
|
||||
await this.loadCustomer()
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '保存失败', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ saving: false })
|
||||
}
|
||||
},
|
||||
|
||||
createAppointment() {
|
||||
if (!this.data.canCreateAppointment) {
|
||||
wx.showToast({ title: '美甲师账号只能查看预约', icon: 'none' })
|
||||
|
||||
@@ -13,7 +13,21 @@
|
||||
<text class="customer-phone">{{customer.phone}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<button wx:if="{{canCreateAppointment}}" class="small-action" bindtap="createAppointment">新预约</button>
|
||||
<view class="customer-actions">
|
||||
<button class="small-action" bindtap="openEditModal">编辑</button>
|
||||
<button wx:if="{{canCreateAppointment}}" class="small-action" bindtap="createAppointment">新预约</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="card info-card">
|
||||
<view class="info-row">
|
||||
<text>联系电话</text>
|
||||
<text>{{customer.phone}}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text>备注</text>
|
||||
<text>{{customer.remark || '未填写'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="stats">
|
||||
@@ -44,5 +58,25 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{editModalVisible}}" class="modal-mask" bindtap="closeEditModal">
|
||||
<view class="customer-modal" catchtap="stopTap">
|
||||
<view class="modal-head">
|
||||
<text class="modal-title">编辑客户</text>
|
||||
<view class="modal-close" bindtap="closeEditModal">×</view>
|
||||
</view>
|
||||
<view class="form-grid">
|
||||
<view class="modal-field">
|
||||
<text>联系电话</text>
|
||||
<input value="{{editForm.contactPhone}}" data-field="contactPhone" bindinput="onEditInput" type="text" placeholder="请输入联系电话" />
|
||||
</view>
|
||||
<view class="modal-field">
|
||||
<text>备注</text>
|
||||
<textarea value="{{editForm.remark}}" data-field="remark" bindinput="onEditInput" maxlength="200" placeholder="请输入客户备注" />
|
||||
</view>
|
||||
</view>
|
||||
<button class="primary-btn modal-submit" loading="{{saving}}" bindtap="saveCustomer">保存客户</button>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
@@ -43,6 +43,48 @@
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.customer-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
gap: 12rpx;
|
||||
}
|
||||
|
||||
.info-card {
|
||||
margin-top: 18rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.info-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 24rpx;
|
||||
min-height: 92rpx;
|
||||
padding: 24rpx;
|
||||
border-bottom: 1rpx solid #eee8df;
|
||||
}
|
||||
|
||||
.info-row:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.info-row text:first-child {
|
||||
flex-shrink: 0;
|
||||
color: #625c55;
|
||||
font-size: 26rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.info-row text:last-child {
|
||||
min-width: 0;
|
||||
color: #27231f;
|
||||
font-size: 27rpx;
|
||||
line-height: 1.45;
|
||||
text-align: right;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.stats {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
@@ -94,3 +136,130 @@
|
||||
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);
|
||||
animation: maskIn 180ms ease both;
|
||||
}
|
||||
|
||||
.customer-modal {
|
||||
width: 100%;
|
||||
max-height: 88vh;
|
||||
overflow-y: auto;
|
||||
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);
|
||||
animation: modalUp 220ms ease both;
|
||||
}
|
||||
|
||||
.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,
|
||||
.modal-field textarea {
|
||||
width: 100%;
|
||||
color: #2c2722;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.modal-field input {
|
||||
height: 58rpx;
|
||||
}
|
||||
|
||||
.modal-field textarea {
|
||||
min-height: 140rpx;
|
||||
}
|
||||
|
||||
.modal-submit {
|
||||
margin-top: 22rpx;
|
||||
}
|
||||
|
||||
@keyframes maskIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes modalUp {
|
||||
from {
|
||||
transform: translateY(40rpx);
|
||||
}
|
||||
to {
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user