小程序剩余原生弹窗统一接入 action-modal
自动发布开发环境 Nacos 配置 / publish (push) Successful in 25s

This commit is contained in:
2026-11-07 00:50:04 +08:00
parent 1482bda1fa
commit 5fae5163ff
14 changed files with 116 additions and 133 deletions
+12 -12
View File
@@ -2,6 +2,7 @@ const userApi = require('../../api/user')
const auth = require('../../utils/auth')
const profileCache = require('../../utils/profile-cache')
const { showErrorToast, toUserMessage } = require('../../utils/toast')
const { showActionModal } = require('../../utils/action-modal')
Page({
data: {
@@ -34,14 +35,13 @@ Page({
},
async requestClosure() {
const confirmed = await new Promise(resolve => wx.showModal({
const result = await showActionModal(this, {
title: '申请注销账号',
content: '申请提交后由管理人员处理。完成后会清理账号身份资料,必要业务记录仍按保存要求保留。你可以在处理前撤回。',
confirmText: '提交申请',
success: result => resolve(result.confirm),
fail: () => resolve(false)
}))
if (!confirmed) return
confirmType: 'danger'
})
if (!result.confirm) return
try {
const closureRequest = await userApi.requestAccountClosure()
this.setData({ closureRequest })
@@ -52,8 +52,8 @@ Page({
},
async withdrawClosure() {
const confirmed = await new Promise(resolve => wx.showModal({ title: '撤回注销申请', content: '确定撤回账号注销申请吗?', success: result => resolve(result.confirm), fail: () => resolve(false) }))
if (!confirmed) return
const result = await showActionModal(this, { title: '撤回注销申请', content: '确定撤回账号注销申请吗?', cancelText: '取消', confirmText: '确定' })
if (!result.confirm) return
try {
await userApi.withdrawAccountClosure()
await this.loadClosureRequest()
@@ -163,14 +163,14 @@ Page({
if (!/^\d{6}$/.test(code)) {
wx.showToast({ title: '请输入当前手机号收到的6位验证码', icon: 'none' }); return
}
const confirmed = await new Promise(resolve => wx.showModal({
const result = await showActionModal(this, {
title: '解绑手机号',
content: '解绑后手机号将从账号资料中删除,短信验证码仅用于验证当前手机号。确定继续吗?',
cancelText: '取消',
confirmText: '确认解绑',
success: result => resolve(result.confirm),
fail: () => resolve(false)
}))
if (!confirmed) return
confirmType: 'danger'
})
if (!result.confirm) return
this.setData({ binding: true })
try {
await userApi.unbindPhone(code)
@@ -1,3 +1,6 @@
{
"navigationBarTitleText": "账号设置"
"navigationBarTitleText": "账号设置",
"usingComponents": {
"action-modal": "/components/action-modal/index"
}
}
@@ -30,4 +30,5 @@
<button wx:elif="{{!closureRequest || closureRequest.status === 'REJECTED'}}" class="closure-btn" bindtap="requestClosure">申请注销账号</button>
</block>
</view>
<action-modal id="actionModal" />
</view>
+28 -50
View File
@@ -1216,15 +1216,11 @@ Page({
const nextDate = event.detail.value
const today = dateUtil.formatDate(new Date())
if (nextDate < today) {
const result = await new Promise(resolve => {
wx.showModal({
title: '历史日期不能新建预约',
content: '之前的日期只能作为历史补单记录,不会校验美甲师排班,也不会占用预约时段。',
cancelText: '取消',
confirmText: '去补单',
success: resolve,
fail: () => resolve({ confirm: false })
})
const result = await showActionModal(this, {
title: '历史日期不能新建预约',
content: '之前的日期只能作为历史补单记录,不会校验美甲师排班,也不会占用预约时段。',
cancelText: '取消',
confirmText: '去补单'
})
if (result.confirm) {
const query = [`serviceDate=${encodeURIComponent(nextDate)}`]
@@ -1782,14 +1778,12 @@ Page({
},
async showBackfillPrompt(serviceDate, reason = '该日期或时段已过去') {
const result = await new Promise(resolve => wx.showModal({
const result = await showActionModal(this, {
title: '转为历史补单',
content: `${reason},普通预约不能使用过去时间。可以前往补录历史订单,或取消继续选择未来时间。`,
cancelText: '取消',
confirmText: '去补录',
success: resolve,
fail: () => resolve({ confirm: false })
}))
confirmText: '去补录'
})
if (!result.confirm) return
const query = [`serviceDate=${encodeURIComponent(serviceDate || dateUtil.formatDate(new Date()))}`]
const artistId = this.data.form.artistId || this._pendingHistoricalArtistId
@@ -1902,15 +1896,11 @@ Page({
try {
const matches = await customersApi.matchIdentityForAppointment(name, wechatId || undefined, phone || undefined)
if (matches.length > 1) {
const choice = await new Promise(resolve => {
wx.showModal({
title: '找到多个同名客户',
content: phone ? '无法确定唯一客户,请选择已有客户或按散客继续。' : '请先补充手机号或选择一个已有客户,也可以按散客继续。',
cancelText: '不关联提交',
confirmText: '选择客户',
success: resolve,
fail: () => resolve({ confirm: false })
})
const choice = await showActionModal(this, {
title: '找到多个同名客户',
content: phone ? '无法确定唯一客户,请选择已有客户或按散客继续。' : '请先补充手机号或选择一个已有客户,也可以按散客继续。',
cancelText: '不关联提交',
confirmText: '选择客户'
})
if (!choice.confirm) {
this.setData({ 'form.createCustomerRecord': false })
@@ -1925,15 +1915,11 @@ Page({
}
if (matches.length > 0) {
const customer = normalizeCustomer(matches[0])
const choice = await new Promise(resolve => {
wx.showModal({
title: '客户已存在',
content: `系统中已有“${name}”${phone ? `(${phone})` : ''},是否使用该客户?`,
cancelText: '不关联提交',
confirmText: '使用已有',
success: resolve,
fail: () => resolve({ confirm: false })
})
const choice = await showActionModal(this, {
title: '客户已存在',
content: `系统中已有“${name}”${phone ? `(${phone})` : ''},是否使用该客户?`,
cancelText: '不关联提交',
confirmText: '使用已有'
})
if (choice.confirm) {
this.setData({
@@ -1947,15 +1933,11 @@ Page({
return true
}
const createChoice = await new Promise(resolve => {
wx.showModal({
title: '新建客户',
content: '系统中没有匹配客户,是否新建到客户档案?',
cancelText: '不新建',
confirmText: '确认',
success: resolve,
fail: () => resolve({ confirm: false })
})
const createChoice = await showActionModal(this, {
title: '新建客户',
content: '系统中没有匹配客户,是否新建到客户档案?',
cancelText: '不新建',
confirmText: '确认'
})
this.setData({ 'form.createCustomerRecord': Boolean(createChoice.confirm) })
return true
@@ -2019,15 +2001,11 @@ Page({
return
}
if (!form.artistId) {
const result = await new Promise(resolve => {
wx.showModal({
title: '保存为待分配预约',
content: '当前未指定美甲师,预约会正常保存,但不会占用美甲师时间。可以稍后在预约详情中分配。',
cancelText: '返回选择',
confirmText: '继续保存',
success: resolve,
fail: () => resolve({ confirm: false })
})
const result = await showActionModal(this, {
title: '保存为待分配预约',
content: '当前未指定美甲师,预约会正常保存,但不会占用美甲师时间。可以稍后在预约详情中分配。',
cancelText: '返回选择',
confirmText: '继续保存'
})
if (!result.confirm) return
}
@@ -485,17 +485,15 @@ Page({
remark: '新建美甲师默认全年全天排班,预约仍受门店营业时间限制,可在排班设置中调整'
}).then(() => {
this.finishCreated(this.data.pickerMode, true)
}).catch(error => {
wx.showModal({
}).catch(async error => {
const result = await showActionModal(this, {
title: '默认排班设置失败',
content: toUserMessage(error, '未设置排班前,该美甲师暂不可预约。请重试或返回排班设置。'),
confirmText: '重试',
cancelText: '稍后设置',
success: result => {
if (result.confirm) this.skipFirstSchedule()
else this.setData({ savingDefaultSchedule: false })
}
cancelText: '稍后设置'
})
if (result.confirm) this.skipFirstSchedule()
else this.setData({ savingDefaultSchedule: false })
}).finally(() => {
if (this.data.onboardingVisible) this.setData({ savingDefaultSchedule: false })
})
@@ -24,23 +24,24 @@
<text class="field-label required">手机号</text>
<input value="{{form.phone}}" data-field="phone" bindinput="onInput" type="number" maxlength="11" placeholder="请输入手机号" />
</view>
<view class="login-unlinked" bindtap="openUserPicker">
<text class="login-unlinked-label">微信账号</text>
<text class="login-unlinked-status">{{selectedWechatUser ? '已绑定' : '未绑定'}}</text>
<text class="login-unlinked-note">{{selectedWechatUser ? selectedWechatUser.title : '点击可选择当前店铺中未绑定身份的微信身份进行绑定'}}</text>
</view>
<view class="field">
<text class="field-label">微信号</text>
<input value="{{form.wechatId}}" data-field="wechatId" bindinput="onInput" placeholder="选填" />
</view>
<view class="field color-field">
<text class="field-label required">日程中排班展示颜色</text>
<text class="field-label required">日程排班
展示颜色</text>
<view class="color-current">
<view class="color-current-chip" style="background: {{form.color}};"></view>
<text class="color-current-value">{{form.color}}</text>
<view class="color-select-btn" bindtap="openColorSheet">选择颜色<text class="color-select-arrow">›</text></view>
</view>
</view>
<view class="login-unlinked" bindtap="openUserPicker">
<text class="login-unlinked-label">微信账号</text>
<text class="login-unlinked-status">{{selectedWechatUser ? '已绑定' : '未绑定'}}</text>
<text class="login-unlinked-note">{{selectedWechatUser ? selectedWechatUser.title : '点击可选择当前店铺中未绑定身份的微信身份进行绑定'}}</text>
</view>
</view>
<view class="fixed-bottom">
+8 -11
View File
@@ -2,6 +2,7 @@ const employeesApi = require('../../api/employees')
const planningApi = require('../../api/planning')
const dateUtil = require('../../utils/date')
const { showErrorToast, toUserMessage } = require('../../utils/toast')
const { showActionModal } = require('../../utils/action-modal')
const EMPLOYEE_COLORS = ['#7AA9C2', '#8EB99B', '#BDA7D8', '#D7B17D', '#D98D8D']
@@ -16,12 +17,6 @@ function formatApplicationTime(value) {
return String(value).replace('T', ' ').slice(0, 16)
}
function confirmModal(options) {
return new Promise(resolve => {
wx.showModal({ ...options, success: resolve, fail: () => resolve({ confirm: false }) })
})
}
Page({
data: {
employees: [],
@@ -134,7 +129,7 @@ Page({
})
if (!artists.length) {
this.setData({ associationSheetVisible: false })
const result = await confirmModal({
const result = await showActionModal(this, {
title: '需要先新建美甲师',
content: '当前门店没有未关联微信的美甲师档案。新建后将自动关联这条申请并通过审核。',
confirmText: '去新建',
@@ -203,7 +198,7 @@ Page({
useApplicantNickname ? '采用申请昵称' : '保留门店姓名',
useApplicantAvatar ? '采用申请头像' : '保留门店头像'
].join('\n')
const confirmed = await confirmModal({ title: '确认关联并通过', content: summary, confirmText: '确认通过' })
const confirmed = await showActionModal(this, { title: '确认关联并通过', content: summary, confirmText: '确认通过' })
if (!confirmed.confirm) return
this.setData({ associationSheetVisible: false })
@@ -215,7 +210,7 @@ Page({
},
askProfileAdoption(field, value) {
return confirmModal({
return showActionModal(this, {
title: `采用申请${field}?`,
content: field === '昵称' ? `申请昵称为“${value}”,采用后会替换门店员工姓名。` : '采用后会替换门店员工当前头像。',
confirmText: `采用申请${field}`,
@@ -226,12 +221,14 @@ Page({
async rejectApplication(event) {
const id = event.currentTarget.dataset.id
if (!id || this.data.reviewingId) return
const result = await confirmModal({
const result = await showActionModal(this, {
title: '驳回美甲师申请',
content: '',
editable: true,
placeholderText: '请输入驳回原因',
confirmText: '确认驳回'
cancelText: '取消',
confirmText: '确认驳回',
confirmType: 'danger'
})
if (!result.confirm) return
const reason = String(result.content || '').trim()
+2 -1
View File
@@ -1,6 +1,7 @@
{
"navigationBarTitleText": "美甲师",
"usingComponents": {
"entity-selector-sheet": "/components/entity-selector-sheet/index"
"entity-selector-sheet": "/components/entity-selector-sheet/index",
"action-modal": "/components/action-modal/index"
}
}
@@ -84,4 +84,5 @@
bind:close="closeApprovalAssociation"
/>
<action-modal id="actionModal" />
</view>
+16 -18
View File
@@ -4,6 +4,7 @@ const { BRAND_CONFIG } = require('../../utils/config')
const loginFlow = require('../../utils/login-flow')
const { requestSubscribeMessages } = require('../../utils/subscribe-message')
const { showErrorToast, toUserMessage } = require('../../utils/toast')
const { showActionModal } = require('../../utils/action-modal')
function wxLoginCode() {
return new Promise((resolve, reject) => wx.login({
@@ -135,14 +136,13 @@ Page({
async chooseRememberMode() {
if (this.data.rememberMe) return true
return new Promise(resolve => wx.showModal({
const result = await showActionModal(this, {
title: '记住登录',
content: loginFlow.REMEMBER_LOGIN_PROMPT,
confirmText: '确认',
cancelText: '取消',
success: result => resolve(loginFlow.resolveRememberChoice(result)),
fail: () => resolve(null)
}))
cancelText: '取消'
})
return loginFlow.resolveRememberChoice(result)
},
async quickLogin() {
@@ -196,22 +196,20 @@ Page({
: status === 'NEED_MANUAL_LOGIN' ? '需要完成注册' : '登录失败'
const content = result.registrationRejectReason || toUserMessage(result, '请稍后重试')
const canRetry = status === 'ERROR' || status === 'NEED_MANUAL_LOGIN' || status === 'REJECTED'
wx.showModal({
const choice = await showActionModal(this, {
title,
content,
showCancel: canRetry,
confirmText: status === 'REJECTED' ? '重新提交' : canRetry ? '重新登录' : '知道了',
cancelText: '取消',
success: choice => {
if (!choice.confirm) return
if (status === 'REJECTED' && result.registrationTicket) this.navigateToRegistration(result)
else if (status === 'REJECTED') {
this._resumeRegistrationAfterRejected = true
this.quickLogin()
}
else if (status === 'ERROR' || status === 'NEED_MANUAL_LOGIN') this.quickLogin()
}
cancelText: canRetry ? '取消' : '',
confirmText: status === 'REJECTED' ? '重新提交' : canRetry ? '重新登录' : '知道了'
})
if (!choice.confirm) return
if (status === 'REJECTED' && result.registrationTicket) this.navigateToRegistration(result)
else if (status === 'REJECTED') {
this._resumeRegistrationAfterRejected = true
this.quickLogin()
}
else if (status === 'ERROR' || status === 'NEED_MANUAL_LOGIN') this.quickLogin()
},
navigateToRegistration(result) {
+4 -1
View File
@@ -2,5 +2,8 @@
"navigationBarTitleText": "登录",
"navigationBarBackgroundColor": "#F3F7F4",
"navigationBarTextStyle": "black",
"backgroundColor": "#F3F7F4"
"backgroundColor": "#F3F7F4",
"usingComponents": {
"action-modal": "/components/action-modal/index"
}
}
+4 -4
View File
@@ -81,21 +81,21 @@ async function run() {
assert.strictEqual(toastOptions.title, '请同意协议后使用')
const statePage = createPage()
statePage.handleResult({ status: 'PENDING_REVIEW', message: '申请审核中' })
await statePage.handleResult({ status: 'PENDING_REVIEW', message: '申请审核中' })
assert.strictEqual(modalOptions.title, '申请审核中')
assert.strictEqual(modalOptions.showCancel, false)
assert.strictEqual(statePage._presentedLoginState.startsWith('PENDING_REVIEW:'), true)
const modalCountBeforeError = modalCount
const errorPage = createPage()
errorPage.handleResult({ status: 'ERROR', message: '网络连接失败' })
errorPage.handleResult({ status: 'ERROR', message: '网络连接失败' })
await errorPage.handleResult({ status: 'ERROR', message: '网络连接失败' })
await errorPage.handleResult({ status: 'ERROR', message: '网络连接失败' })
assert.strictEqual(modalOptions.title, '登录失败')
assert.strictEqual(modalCount, modalCountBeforeError + 1)
modalChoice = { confirm: true, cancel: false }
const rejectedPage = createPage()
rejectedPage.handleResult({ status: 'REJECTED', message: '资料需修改', registrationTicket: 'ticket-1', registrationApplicationId: 23, registrationRole: 'STAFF' })
await rejectedPage.handleResult({ status: 'REJECTED', message: '资料需修改', registrationTicket: 'ticket-1', registrationApplicationId: 23, registrationRole: 'STAFF' })
assert.match(navigatedTo, /registrationTicket=ticket-1/)
assert.match(navigatedTo, /applicationId=23/)
assert.match(navigatedTo, /role=STAFF/)
+1
View File
@@ -49,4 +49,5 @@
</view><text wx:if="{{switchingShop}}" class="switching">正在进入门店…</text>
</view>
</view>
<action-modal id="actionModal" />
</view>
+23 -22
View File
@@ -157,24 +157,25 @@
box-sizing: border-box;
width: 100%;
overflow: hidden;
border-radius: 30rpx;
padding-bottom: 28rpx;
border-radius: 28rpx;
background: #fff;
}
.agreement-prompt-title {
display: block;
padding: 48rpx 28rpx 0;
color: #171a18;
font-size: 36rpx;
font-weight: 700;
padding: 44rpx 28rpx 0;
color: #17211f;
font-size: 32rpx;
font-weight: 800;
line-height: 1.45;
text-align: center;
}
.agreement-prompt-body {
padding: 56rpx 38rpx 48rpx;
color: #8a8e8b;
font-size: 29rpx;
padding: 24rpx 28rpx 8rpx;
color: #71807a;
font-size: 27rpx;
line-height: 1.72;
text-align: center;
}
@@ -190,21 +191,20 @@
.agreement-prompt-actions {
display: flex;
align-items: center;
height: 112rpx;
border-top: 1rpx solid #e5e5e5;
gap: 20rpx;
padding: 24rpx 28rpx 0;
}
.agreement-prompt-button {
box-sizing: border-box;
height: 100%;
flex: 1;
height: 88rpx;
flex: 1 1 0;
margin: 0;
padding: 0 12rpx;
border: 0;
border-radius: 0;
background: #fff;
font-size: 30rpx;
line-height: 112rpx;
border-radius: 20rpx;
font-size: 26rpx;
font-weight: 700;
line-height: 88rpx;
}
.agreement-prompt-button::after {
@@ -212,17 +212,18 @@
}
.agreement-prompt-decline {
color: #888d8a;
border: 1rpx solid #E7ECE9;
background: #F1F3F2;
color: #71807A;
}
.agreement-prompt-accept {
color: #247b63;
background: #247B63;
color: #ffffff;
}
.agreement-prompt-divider {
width: 1rpx;
height: 100%;
background: #e5e5e5;
display: none;
}
.modal-mask {