优化管理师登录与预约客户选择
This commit is contained in:
+2
-1
@@ -1897,7 +1897,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
||||
if (StringUtils.hasText(keyword)) {
|
||||
wrapper.and(w -> w.like(UserDO::getAccount, keyword)
|
||||
.or().like(UserDO::getNickname, keyword)
|
||||
.or().like(UserDO::getPhone, keyword));
|
||||
.or().like(UserDO::getPhone, keyword)
|
||||
.or().like(UserDO::getContactPhone, keyword));
|
||||
}
|
||||
if (shopId != null && shopId > 0) {
|
||||
List<Long> userIds = userShopBindingSupport.listUserIdsByShopId(shopId, true);
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 284 KiB After Width: | Height: | Size: 995 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 284 KiB After Width: | Height: | Size: 995 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 373 KiB After Width: | Height: | Size: 1.4 MiB |
@@ -1,5 +1,6 @@
|
||||
const planningApi = require('../../api/planning')
|
||||
const productsApi = require('../../api/products')
|
||||
const customersApi = require('../../api/customers')
|
||||
const dateUtil = require('../../utils/date')
|
||||
|
||||
function buildClientRequestId(prefix) {
|
||||
@@ -65,9 +66,22 @@ function isScheduleCoveringTime(schedule, form, startMinute, endMinute) {
|
||||
return scheduleStartMinute <= startMinute && scheduleEndMinute >= endMinute
|
||||
}
|
||||
|
||||
function normalizeCustomer(customer) {
|
||||
const name = customer.nickname || customer.name || customer.account || ''
|
||||
const phone = customer.contactPhone || customer.phone || ''
|
||||
return {
|
||||
id: customer.id,
|
||||
name,
|
||||
phone,
|
||||
displayName: name || phone || '客户',
|
||||
displayPhone: phone || '未填写手机号'
|
||||
}
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
form: {
|
||||
customerUserId: '',
|
||||
customerName: '',
|
||||
phone: '',
|
||||
appointmentDate: dateUtil.formatDate(new Date()),
|
||||
@@ -79,6 +93,10 @@ Page({
|
||||
artistId: '',
|
||||
remark: ''
|
||||
},
|
||||
customerOptions: [],
|
||||
customerDropdownVisible: false,
|
||||
customerLoading: false,
|
||||
customerError: '',
|
||||
products: [],
|
||||
filteredProducts: [],
|
||||
artists: [],
|
||||
@@ -107,6 +125,7 @@ Page({
|
||||
return
|
||||
}
|
||||
this.loadOptions()
|
||||
this.searchCustomers()
|
||||
},
|
||||
|
||||
async loadOptions() {
|
||||
@@ -148,11 +167,81 @@ Page({
|
||||
},
|
||||
|
||||
onInput(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
const patch = {
|
||||
[`form.${field}`]: event.detail.value
|
||||
}
|
||||
if (field === 'customerName' || field === 'phone') {
|
||||
patch['form.customerUserId'] = ''
|
||||
patch.customerDropdownVisible = true
|
||||
}
|
||||
this.setData(patch)
|
||||
if (field === 'customerName' || field === 'phone') {
|
||||
this.scheduleCustomerSearch(field)
|
||||
}
|
||||
},
|
||||
|
||||
onCustomerFocus(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
this.setData({ customerDropdownVisible: true })
|
||||
this.searchCustomers(field)
|
||||
},
|
||||
|
||||
scheduleCustomerSearch(field) {
|
||||
clearTimeout(this._customerTimer)
|
||||
this._customerTimer = setTimeout(() => this.searchCustomers(field), 250)
|
||||
},
|
||||
|
||||
async searchCustomers(preferredField) {
|
||||
if (!this.data.canCreateAppointment) {
|
||||
return
|
||||
}
|
||||
const form = this.data.form
|
||||
const sourceValue = preferredField === 'phone' ? form.phone : form.customerName || form.phone
|
||||
const keyword = String(sourceValue || '').trim()
|
||||
this.setData({ customerLoading: true })
|
||||
try {
|
||||
const data = await customersApi.list({ keyword, page: 1, size: 20 })
|
||||
const list = data.list || data || []
|
||||
this.setData({
|
||||
customerOptions: list.map(normalizeCustomer),
|
||||
customerError: ''
|
||||
})
|
||||
} catch (error) {
|
||||
this.setData({
|
||||
customerOptions: [],
|
||||
customerError: error.message || '客户列表加载失败'
|
||||
})
|
||||
} finally {
|
||||
this.setData({ customerLoading: false })
|
||||
}
|
||||
},
|
||||
|
||||
selectCustomer(event) {
|
||||
const customer = this.data.customerOptions.find(item => String(item.id) === String(event.currentTarget.dataset.id))
|
||||
if (!customer) {
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
[`form.${event.currentTarget.dataset.field}`]: event.detail.value
|
||||
'form.customerUserId': customer.id,
|
||||
'form.customerName': customer.name,
|
||||
'form.phone': customer.phone,
|
||||
customerDropdownVisible: false
|
||||
})
|
||||
},
|
||||
|
||||
hideCustomerDropdown() {
|
||||
setTimeout(() => {
|
||||
this.setData({ customerDropdownVisible: false })
|
||||
}, 180)
|
||||
},
|
||||
|
||||
onUnload() {
|
||||
if (this._customerTimer) {
|
||||
clearTimeout(this._customerTimer)
|
||||
}
|
||||
},
|
||||
|
||||
async onDateChange(event) {
|
||||
this.setData({ 'form.appointmentDate': event.detail.value })
|
||||
await this.loadArtists()
|
||||
@@ -303,6 +392,7 @@ Page({
|
||||
try {
|
||||
const payload = {
|
||||
...form,
|
||||
customerUserId: form.customerUserId ? String(form.customerUserId) : undefined,
|
||||
artistId: String(form.artistId),
|
||||
durationMinutes: Number(form.durationMinutes || 0) || undefined,
|
||||
clientRequestId: buildClientRequestId('manager-appointment')
|
||||
|
||||
@@ -1,12 +1,28 @@
|
||||
<view class="page no-tab">
|
||||
<view class="card form-card">
|
||||
<view class="field">
|
||||
<text class="field-label required">客户姓名</text>
|
||||
<input value="{{form.customerName}}" data-field="customerName" bindinput="onInput" placeholder="请输入客户姓名" />
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label required">手机号</text>
|
||||
<input value="{{form.phone}}" data-field="phone" bindinput="onInput" placeholder="请输入手机号" />
|
||||
<view class="customer-select">
|
||||
<view class="field">
|
||||
<text class="field-label required">客户姓名</text>
|
||||
<input value="{{form.customerName}}" data-field="customerName" bindinput="onInput" bindfocus="onCustomerFocus" bindblur="hideCustomerDropdown" placeholder="搜索或输入客户姓名" />
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label required">手机号</text>
|
||||
<input value="{{form.phone}}" data-field="phone" bindinput="onInput" bindfocus="onCustomerFocus" bindblur="hideCustomerDropdown" placeholder="搜索或输入手机号" />
|
||||
</view>
|
||||
<view wx:if="{{customerDropdownVisible}}" class="customer-dropdown">
|
||||
<view wx:if="{{customerLoading}}" class="customer-option muted-option">正在搜索客户...</view>
|
||||
<view wx:elif="{{customerError}}" class="customer-option muted-option">{{customerError}},可继续手动输入</view>
|
||||
<view wx:else>
|
||||
<view wx:for="{{customerOptions}}" wx:key="id" class="customer-option" data-id="{{item.id}}" bindtap="selectCustomer">
|
||||
<view class="customer-copy">
|
||||
<text class="customer-name">{{item.displayName}}</text>
|
||||
<text class="customer-phone">{{item.displayPhone}}</text>
|
||||
</view>
|
||||
<text class="customer-select-tag">选择</text>
|
||||
</view>
|
||||
<view wx:if="{{customerOptions.length === 0}}" class="customer-option muted-option">暂无匹配客户,可继续手动输入</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label required">预约日期</text>
|
||||
|
||||
@@ -3,6 +3,77 @@
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.customer-select {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.customer-dropdown {
|
||||
position: absolute;
|
||||
top: 214rpx;
|
||||
right: 0;
|
||||
left: 180rpx;
|
||||
z-index: 30;
|
||||
max-height: 360rpx;
|
||||
overflow-y: auto;
|
||||
border: 1rpx solid #e5ded4;
|
||||
border-radius: 18rpx;
|
||||
background: #fffdf8;
|
||||
box-shadow: 0 18rpx 40rpx rgba(58, 48, 34, 0.14);
|
||||
}
|
||||
|
||||
.customer-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16rpx;
|
||||
min-height: 76rpx;
|
||||
padding: 0 20rpx;
|
||||
border-bottom: 1rpx solid #f0e9df;
|
||||
}
|
||||
|
||||
.customer-option:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.customer-copy {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
gap: 6rpx;
|
||||
}
|
||||
|
||||
.customer-name {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
color: #2a2521;
|
||||
font-size: 26rpx;
|
||||
font-weight: 800;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.customer-phone {
|
||||
color: #8c8177;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.customer-select-tag {
|
||||
flex: 0 0 auto;
|
||||
padding: 4rpx 12rpx;
|
||||
border-radius: 999rpx;
|
||||
background: #e5eee9;
|
||||
color: #55786d;
|
||||
font-size: 22rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.muted-option {
|
||||
justify-content: center;
|
||||
color: #9a9288;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.product-value {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -91,6 +91,10 @@ Page({
|
||||
countdown: 0,
|
||||
countdownTimer: null,
|
||||
agreementAccepted: false,
|
||||
agreementLoading: false,
|
||||
agreementError: '',
|
||||
agreementModalVisible: false,
|
||||
selectedAgreement: null,
|
||||
rememberMe: false,
|
||||
agreements: [],
|
||||
appName: BRAND_CONFIG.appName,
|
||||
@@ -102,15 +106,15 @@ Page({
|
||||
|
||||
onLoad() {
|
||||
const preference = getLoginPreference()
|
||||
if (!preference.rememberMe) {
|
||||
return
|
||||
if (preference.rememberMe) {
|
||||
this.setData({
|
||||
loginMode: preference.loginMode === 'password' ? 'password' : 'phone',
|
||||
rememberMe: true,
|
||||
'form.account': preference.account || '',
|
||||
'form.phone': preference.phone || ''
|
||||
})
|
||||
}
|
||||
this.setData({
|
||||
loginMode: preference.loginMode === 'password' ? 'password' : 'phone',
|
||||
rememberMe: true,
|
||||
'form.account': preference.account || '',
|
||||
'form.phone': preference.phone || ''
|
||||
})
|
||||
this.loadAgreements()
|
||||
},
|
||||
|
||||
onInput(event) {
|
||||
@@ -151,13 +155,23 @@ Page({
|
||||
|
||||
async loadAgreements() {
|
||||
if (this.data.agreements.length) {
|
||||
return
|
||||
return this.data.agreements
|
||||
}
|
||||
if (this.data.agreementLoading) {
|
||||
return this.data.agreements
|
||||
}
|
||||
this.setData({ agreementLoading: true, agreementError: '' })
|
||||
try {
|
||||
const agreements = await authApi.getCurrentAgreements()
|
||||
this.setData({ agreements: Array.isArray(agreements) ? agreements : [] })
|
||||
const normalizedAgreements = Array.isArray(agreements) ? agreements : []
|
||||
this.setData({ agreements: normalizedAgreements })
|
||||
return normalizedAgreements
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '协议加载失败', icon: 'none' })
|
||||
const agreementError = error.message || '协议内容加载失败,请稍后重试'
|
||||
this.setData({ agreementError })
|
||||
return []
|
||||
} finally {
|
||||
this.setData({ agreementLoading: false })
|
||||
}
|
||||
},
|
||||
|
||||
@@ -167,6 +181,30 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
async openAgreement(event) {
|
||||
const type = event.currentTarget.dataset.type
|
||||
const agreements = await this.loadAgreements()
|
||||
const selectedAgreement = agreements.find(item => item.agreementType === type)
|
||||
if (!selectedAgreement) {
|
||||
wx.showToast({ title: this.data.agreementError || '协议内容暂不可用', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
selectedAgreement,
|
||||
agreementModalVisible: true
|
||||
})
|
||||
},
|
||||
|
||||
closeAgreementModal() {
|
||||
this.setData({
|
||||
agreementModalVisible: false,
|
||||
selectedAgreement: null
|
||||
})
|
||||
},
|
||||
|
||||
stopTap() {
|
||||
},
|
||||
|
||||
toggleRememberMe() {
|
||||
const rememberMe = !this.data.rememberMe
|
||||
this.setData({ rememberMe })
|
||||
@@ -210,7 +248,7 @@ Page({
|
||||
}
|
||||
const versions = this.buildAgreementPayload().agreementVersions
|
||||
if (!versions.USER_TERMS || !versions.PRIVACY_POLICY) {
|
||||
wx.showToast({ title: '协议版本加载中,请稍后再试', icon: 'none' })
|
||||
wx.showToast({ title: this.data.agreementError || '协议版本加载中,请稍后再试', icon: 'none' })
|
||||
return false
|
||||
}
|
||||
return true
|
||||
@@ -252,6 +290,7 @@ Page({
|
||||
account: form.account,
|
||||
password: form.password,
|
||||
rememberMe: !!this.data.rememberMe,
|
||||
...this.buildAgreementPayload(),
|
||||
...(shopId ? { shopId } : {})
|
||||
}
|
||||
},
|
||||
@@ -369,6 +408,9 @@ Page({
|
||||
},
|
||||
|
||||
async submit() {
|
||||
if (this.data.loading) {
|
||||
return
|
||||
}
|
||||
const form = this.data.form
|
||||
if (this.data.loginMode === 'password' && (!form.account || !form.password)) {
|
||||
wx.showToast({ title: '请填写账号和密码', icon: 'none' })
|
||||
@@ -378,10 +420,8 @@ Page({
|
||||
wx.showToast({ title: '请输入正确手机号和验证码', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (this.data.loginMode === 'phone') {
|
||||
await this.loadAgreements()
|
||||
}
|
||||
if (this.data.loginMode === 'phone' && !this.ensureAgreementAccepted()) {
|
||||
await this.loadAgreements()
|
||||
if (!this.ensureAgreementAccepted()) {
|
||||
return
|
||||
}
|
||||
this.setData({ loading: true })
|
||||
|
||||
@@ -32,15 +32,21 @@
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{loginMode === 'phone'}}" class="agreement-row" bindtap="toggleAgreement">
|
||||
<view class="agreement-row" bindtap="toggleAgreement">
|
||||
<view class="agreement-check {{agreementAccepted ? 'checked' : ''}}">{{agreementAccepted ? '✓' : ''}}</view>
|
||||
<view class="agreement-copy">我已阅读并同意用户协议和隐私政策</view>
|
||||
<view class="agreement-copy">
|
||||
<text>我已阅读并同意</text>
|
||||
<text class="agreement-link" data-type="USER_TERMS" catchtap="openAgreement">《用户协议》</text>
|
||||
<text>和</text>
|
||||
<text class="agreement-link" data-type="PRIVACY_POLICY" catchtap="openAgreement">《隐私政策》</text>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{agreementError}}" class="agreement-error" bindtap="loadAgreements">{{agreementError}},点此重试</view>
|
||||
<view class="remember-row" bindtap="toggleRememberMe">
|
||||
<view class="agreement-check {{rememberMe ? 'checked' : ''}}">{{rememberMe ? '✓' : ''}}</view>
|
||||
<view class="agreement-copy">记住我</view>
|
||||
<view class="agreement-copy">记住我,保持登录更久</view>
|
||||
</view>
|
||||
<button class="primary-btn login-btn" loading="{{loading}}" bindtap="submit">登录</button>
|
||||
<button class="primary-btn login-btn {{agreementAccepted ? '' : 'disabled'}}" loading="{{loading}}" disabled="{{loading || agreementLoading}}" bindtap="submit">{{agreementLoading ? '协议加载中...' : '登录'}}</button>
|
||||
<view class="auth-links">
|
||||
<button class="text-btn">忘记密码</button>
|
||||
<button class="text-btn" bindtap="goRegister">注册账号</button>
|
||||
@@ -73,4 +79,15 @@
|
||||
<view wx:if="{{switchingShop}}" class="shop-switching">正在进入店铺...</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{agreementModalVisible}}" class="agreement-mask" catchtouchmove="stopTap">
|
||||
<view class="agreement-modal">
|
||||
<view class="agreement-modal-title">{{selectedAgreement.title || '协议详情'}}</view>
|
||||
<view class="agreement-modal-meta">版本:{{selectedAgreement.version || '-'}}</view>
|
||||
<scroll-view class="agreement-modal-body" scroll-y>
|
||||
<text>{{selectedAgreement.content || '暂无协议内容'}}</text>
|
||||
</scroll-view>
|
||||
<button class="primary-btn agreement-modal-close" bindtap="closeAgreementModal">我知道了</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
padding-top: 40rpx;
|
||||
padding-top: 12rpx;
|
||||
}
|
||||
|
||||
.brand {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
margin-bottom: 34rpx;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.logo {
|
||||
@@ -125,10 +125,26 @@
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.agreement-link {
|
||||
color: #55786d;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.agreement-error {
|
||||
margin-top: 16rpx;
|
||||
color: #c36a6a;
|
||||
font-size: 23rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
margin-top: 28rpx;
|
||||
}
|
||||
|
||||
.login-btn.disabled {
|
||||
opacity: 0.56;
|
||||
}
|
||||
|
||||
.auth-links {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
@@ -240,3 +256,52 @@
|
||||
font-weight: 700;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.agreement-mask {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 90;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 28rpx;
|
||||
background: rgba(36, 33, 29, 0.42);
|
||||
}
|
||||
|
||||
.agreement-modal {
|
||||
width: 100%;
|
||||
max-height: 82vh;
|
||||
padding: 30rpx 28rpx;
|
||||
border-radius: 24rpx;
|
||||
background: #fffdf8;
|
||||
box-shadow: 0 24rpx 64rpx rgba(58, 48, 34, 0.18);
|
||||
}
|
||||
|
||||
.agreement-modal-title {
|
||||
color: #24211d;
|
||||
font-size: 32rpx;
|
||||
font-weight: 900;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.agreement-modal-meta {
|
||||
margin-top: 10rpx;
|
||||
color: #928a80;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.agreement-modal-body {
|
||||
height: 640rpx;
|
||||
max-height: 56vh;
|
||||
margin-top: 22rpx;
|
||||
padding: 20rpx;
|
||||
border-radius: 18rpx;
|
||||
background: #f3eee7;
|
||||
color: #2f2a25;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.85;
|
||||
}
|
||||
|
||||
.agreement-modal-close {
|
||||
margin-top: 22rpx;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
}
|
||||
},
|
||||
"condition": {},
|
||||
"projectname": "指尖管理师",
|
||||
"projectname": "甲屿店务",
|
||||
"simulatorType": "wechat",
|
||||
"simulatorPluginLibVersion": {},
|
||||
"editorSetting": {},
|
||||
|
||||
Reference in New Issue
Block a user