Salon 侧全场景脱敏与拨号单次取号改造:收掉预约选择客户的完整手机号出口,新增按门店与订单上下文授权的拨号取号端点及隐私号占位渠道,前端改为脱敏展示加呼叫取号,并同步更新协议条款
自动发布开发环境 Nacos 配置 / publish (push) Successful in 24s

This commit is contained in:
2026-11-04 22:02:51 +08:00
parent bbe1473b70
commit 05493923e4
33 changed files with 697 additions and 28 deletions
+12
View File
@@ -46,6 +46,18 @@ module.exports = {
})
},
/**
* 后台按预约/订单上下文单次取号,号码不入库、不缓存。
*/
dialCustomer(customerId, orderId) {
return request({
url: `/manager/customers/${customerId}/dial`,
method: 'POST',
data: {},
params: { orderId }
})
},
create(data) {
return request({
url: '/manager/customers',
@@ -1,4 +1,5 @@
const planningApi = require('../../api/planning')
const customersApi = require('../../api/customers')
const { markPlanningRefresh } = require('../../utils/planning-refresh')
function displayValue(value, fallback) {
@@ -24,6 +25,7 @@ Page({
showComplete: false,
showCancel: false,
updating: false,
dialing: false,
loadError: ''
},
@@ -130,6 +132,27 @@ Page({
})
},
async dialCustomer() {
const appointment = this.data.appointment || {}
if (this.data.dialing) return
if (!appointment.customerPhoneAvailable || !appointment.customerId || !appointment.orderId) {
wx.showToast({ title: '该客户暂无可拨打的手机号', icon: 'none' })
return
}
this.setData({ dialing: true })
try {
const result = await customersApi.dialCustomer(appointment.customerId, appointment.orderId)
if (!result || !result.dialNumber) {
throw new Error('未获取到可拨打号码')
}
wx.makePhoneCall({ phoneNumber: result.dialNumber })
} catch (error) {
wx.showToast({ title: error.message || '取号失败', icon: 'none' })
} finally {
this.setData({ dialing: false })
}
},
goTransfer() {
if (!this.data.showTransfer) return
wx.navigateTo({ url: `/pages/artist-transfer/index?id=${this.data.id}` })
@@ -10,7 +10,16 @@
<view class="avatar">{{avatarText}}</view>
<view>
<text class="customer">{{appointment.customerNameText}}</text>
<text class="phone">{{appointment.customerPhoneText}}</text>
<view class="phone-row">
<text class="phone">{{appointment.customerPhoneText}}</text>
<button
wx:if="{{appointment.customerPhoneAvailable && appointment.customerId && appointment.orderId}}"
class="call-btn"
size="mini"
loading="{{dialing}}"
bindtap="dialCustomer"
>呼叫</button>
</view>
</view>
</view>
<text class="status-tag {{appointment.status === 2 ? 'completed' : appointment.status === 3 ? 'cancelled' : ''}}">{{appointment.historicalBackfill ? '历史补单 · ' : ''}}{{appointment.statusText}}</text>
@@ -67,6 +67,24 @@
font-size: 24rpx;
}
.phone-row {
display: flex;
align-items: center;
gap: 12rpx;
}
.call-btn {
flex-shrink: 0;
margin: 0;
padding: 0 18rpx;
border-radius: 999rpx;
background: #edf6ef;
color: #247b63;
font-size: 22rpx;
font-weight: 800;
line-height: 44rpx;
}
.status-tag {
flex-shrink: 0;
padding: 8rpx 14rpx;
@@ -36,17 +36,17 @@ function createPage() {
async function run() {
const page = createPage()
page.selectCustomer({ detail: { item: { id: 18, name: '小周', phone: '13800138000' } } })
page.selectCustomer({ detail: { item: { id: 18, name: '小周', phone: '138****8000' } } })
assert.strictEqual(page.data.form.customerUserId, 18)
assert.strictEqual(page.data.form.customerName, '小周')
assert.strictEqual(page.data.form.phone, '13800138000')
assert.strictEqual(page.data.form.phone, '')
assert.strictEqual(page.data.customerSheetVisible, false)
page.data.form.customerUserId = 18
page.onCustomerInput({ currentTarget: { dataset: { field: 'customerName' } }, detail: { value: '新客户' } })
assert.strictEqual(page.data.form.customerUserId, '')
assert.strictEqual(page.data.form.customerName, '新客户')
assert.strictEqual(page.data.form.phone, '13800138000')
assert.strictEqual(page.data.form.phone, '')
customersApi.matchIdentityForAppointment = async () => []
customersApi.create = async () => { throw new Error('预约客户建档应随预约请求提交') }
@@ -61,10 +61,11 @@ async function run() {
assert.strictEqual(name, '小周')
assert.strictEqual(wechatId, undefined)
assert.strictEqual(phone, '13800138000')
return [{ id: '18', name: '小周', phone: '13800138000' }]
return [{ id: '18', name: '小周', phone: '138****8000' }]
}
assert.strictEqual(await page.ensureCustomerBeforeSubmit(), true)
assert.strictEqual(page.data.form.customerUserId, '18')
assert.strictEqual(page.data.form.phone, '13800138000')
page.data.artists = [{ id: 1, name: '小周' }, { id: 2, name: '小李' }]
page.onArtistSearch({ detail: { value: '李' } })
+28 -13
View File
@@ -520,6 +520,7 @@ function normalizeCustomer(customer) {
id: customer.id,
name,
phone,
phoneAvailable: customer.phoneAvailable === true || (Boolean(phone) && !String(phone).includes('*')),
displayName: name || phone || '客户',
displayPhone: phone || '未填写手机号',
createdAt: customerCreatedAt(customer)
@@ -952,7 +953,7 @@ Page({
if (requestSeq !== this._customerSuggestionSeq) return
const rows = Array.isArray(result) ? result : (result.list || [])
const remoteSuggestions = rows.map(normalizeCustomer)
.filter(customer => (!name || customer.name.toLowerCase().includes(name)) && (!phone || customer.phone.toLowerCase().includes(phone)))
.filter(customer => !name || customer.name.toLowerCase().includes(name))
.slice(0, 3)
.map(buildCustomerSelectorItem)
this.setData({ customerSuggestions: remoteSuggestions })
@@ -971,7 +972,8 @@ Page({
this.setData({
'form.customerUserId': customer.id,
'form.customerName': customer.name,
'form.phone': customer.phone || '',
// 后端仅返回脱敏号码,不回填到表单,避免把脱敏值当真实号码提交
'form.phone': '',
'form.createCustomerRecord': false,
customerSuggestions: [],
customerSheetVisible: false,
@@ -1000,11 +1002,25 @@ Page({
return
}
const keyword = String(keywordValue === undefined ? this.data.customerKeyword : keywordValue || '').trim()
if (keyword) {
// 号码已全场景脱敏,按手机号检索必须交给后端精确匹配
try {
const result = await customersApi.listForAppointment({ page: 1, size: 100, keyword })
const rows = Array.isArray(result) ? result : (result.list || [])
this.setData({
customerOptions: this.sortCustomerOptions(rows.map(normalizeCustomer)),
customerError: ''
})
} catch (error) {
this.setData({ customerOptions: [], customerError: error.message || '客户加载失败' })
}
return
}
if (this.data.customerDirectory.length === 0) await this.loadCustomerDirectory()
const matches = this.data.customerDirectory.filter(customer =>
!keyword || `${customer.name} ${customer.phone}`.toLowerCase().includes(keyword.toLowerCase())
)
this.setData({ customerOptions: this.sortCustomerOptions(matches), customerError: '' })
this.setData({
customerOptions: this.sortCustomerOptions(this.data.customerDirectory),
customerError: ''
})
},
changeCustomerView(event) {
@@ -1013,11 +1029,10 @@ Page({
toggleCustomerSort() {
const customerNewestFirst = !this.data.customerNewestFirst
const keyword = String(this.data.customerKeyword || '').trim().toLowerCase()
const matches = this.data.customerDirectory.filter(customer =>
!keyword || `${customer.name} ${customer.phone}`.toLowerCase().includes(keyword)
)
this.setData({ customerNewestFirst, customerOptions: this.sortCustomerOptions(matches, customerNewestFirst) })
this.setData({
customerNewestFirst,
customerOptions: this.sortCustomerOptions(this.data.customerOptions, customerNewestFirst)
})
},
retryCustomerSearch() {
@@ -1032,7 +1047,8 @@ Page({
this.setData({
'form.customerUserId': customer.id,
'form.customerName': customer.name,
'form.phone': customer.phone || '',
// 选择已有客户时不回填脱敏号码,手机号仅在用户主动修改时提交
'form.phone': '',
'form.createCustomerRecord': false,
customerSheetVisible: false,
customerKeyword: '',
@@ -1925,7 +1941,6 @@ Page({
this.setData({
'form.customerUserId': customer.id,
'form.customerName': customer.name,
'form.phone': customer.phone,
'form.createCustomerRecord': false
})
} else {
@@ -114,7 +114,7 @@ Page({
searchCustomers(event) { const keyword = String(event.detail.value || '').toLowerCase(); this.setData({ customerKeyword: keyword, customerOptions: this.data.allCustomerOptions.filter(item => !keyword || `${item.name} ${item.phone}`.toLowerCase().includes(keyword)) }) },
selectProduct(event) { const item = event.detail.item || {}; const duration = String(item.serviceDurationMinutes || String(item.approximateDuration || '').replace(/[^0-9]/g, '') || '60'); this.setData({ 'form.productId': item.id, 'form.manualProductTitle': '', 'form.amount': item.price == null ? this.data.form.amount : String(item.price), 'form.durationMinutes': duration, selectedProduct: item, selectedProductTitle: item.title, selectedProductPriceText: item.priceText || '价格待定', manualProductDraft: { title: '', price: '', durationMinutes: duration, description: '' }, productSelectorVisible: false, manualProductSheetVisible: false }) },
selectArtist(event) { const item = event.detail.item; this.setData({ 'form.artistId': item.id, selectedArtistName: item.title, artistSelectorVisible: false }) },
selectCustomer(event) { const item = event.detail.item || {}; this.setData({ 'form.customerUserId': item.id, 'form.customerName': item.name || item.title, 'form.phone': item.phone || '', customerSelectorVisible: false }) },
selectCustomer(event) { const item = event.detail.item || {}; this.setData({ 'form.customerUserId': item.id, 'form.customerName': item.name || item.title, 'form.phone': '', customerSelectorVisible: false }) },
useWalkIn() { this.setData({ 'form.customerUserId': '', 'form.customerName': '', 'form.wechatId': '', 'form.phone': '', customerSelectorVisible: false }) },
onCustomerInput(event) { this.setData({ [`form.${event.currentTarget.dataset.field}`]: event.detail.value, 'form.customerUserId': '' }) },
useManualProduct() { const title = String(this.data.manualProductDraft.title || '').trim(); const priceText = String(this.data.manualProductDraft.price || this.data.form.amount || '').trim(); const price = Number(priceText); const images = this.data.form.manualProductImages || []; if (this.data.form.productId) { if (!priceText || !Number.isFinite(price) || price < 0) { wx.showToast({ title: '请输入正确的款式价格', icon: 'none' }); return } this.setData({ 'form.amount': priceText, 'form.durationMinutes': String(this.data.manualProductDraft.durationMinutes || '60'), manualProductSheetVisible: false }); return } if (!title && !images.length) { wx.showToast({ title: '请填写款式名称或添加图片', icon: 'none' }); return } if (!priceText || !Number.isFinite(price) || price < 0) { wx.showToast({ title: '请输入正确的款式价格', icon: 'none' }); return } const duration = String(this.data.manualProductDraft.durationMinutes || '60'); this.setData({ 'form.productId': '', 'form.manualProductTitle': title, 'form.manualProductDescription': this.data.manualProductDraft.description || '', 'form.manualProductPrice': priceText, 'form.amount': priceText, 'form.durationMinutes': duration, 'manualProductDraft.price': priceText, selectedProduct: {}, selectedProductTitle: title, selectedProductPriceText: `¥${price}`, productSelectorVisible: false, manualProductSheetVisible: false }) },