小程序浮层动作项按钮化并统一按钮样式
自动发布开发环境 Nacos 配置 / publish (push) Successful in 27s

This commit is contained in:
2026-11-07 00:38:22 +08:00
parent a5f050286b
commit 1482bda1fa
31 changed files with 322 additions and 78 deletions
@@ -0,0 +1,56 @@
Component({
data: {
visible: false,
title: '',
content: '',
icon: '',
cancelText: '',
confirmText: '确定',
confirmType: 'primary',
layout: 'column',
editable: false,
placeholderText: '',
inputValue: ''
},
methods: {
open(options = {}) {
this._onClose = typeof options.onClose === 'function' ? options.onClose : null
this.setData({
visible: true,
title: options.title || '',
content: options.content || '',
icon: options.icon || '',
cancelText: options.cancelText || '',
confirmText: options.confirmText || '确定',
confirmType: options.confirmType || 'primary',
layout: options.layout || (options.cancelText ? 'row' : 'column'),
editable: options.editable === true,
placeholderText: options.placeholderText || '',
inputValue: ''
})
},
close(result) {
this.setData({ visible: false })
const onClose = this._onClose
this._onClose = null
if (onClose) onClose(result)
},
onInput(event) {
this.setData({ inputValue: event.detail.value })
},
onConfirm() {
this.close({ confirm: true, cancel: false, content: this.data.inputValue })
},
onCancel() {
this.close({ confirm: false, cancel: true, content: this.data.inputValue })
},
stopEvent() {
}
}
})
@@ -0,0 +1,4 @@
{
"component": true,
"styleIsolation": "apply-shared"
}
@@ -0,0 +1,12 @@
<view wx:if="{{visible}}" class="action-modal-mask" catchtouchmove="stopEvent">
<view class="action-modal-card">
<view wx:if="{{icon}}" class="action-modal-icon {{icon}}">{{icon === 'warning' ? '!' : 'i'}}</view>
<text class="action-modal-title">{{title}}</text>
<text wx:if="{{content}}" class="action-modal-content">{{content}}</text>
<input wx:if="{{editable}}" class="action-modal-input" value="{{inputValue}}" maxlength="60" placeholder="{{placeholderText}}" bindinput="onInput" />
<view class="action-modal-actions {{layout === 'row' ? 'row' : ''}}">
<button wx:if="{{cancelText}}" class="action-modal-btn secondary" bindtap="onCancel">{{cancelText}}</button>
<button class="action-modal-btn {{confirmType === 'danger' ? 'danger' : 'primary'}}" bindtap="onConfirm">{{confirmText}}</button>
</view>
</view>
</view>
@@ -0,0 +1,117 @@
.action-modal-mask {
position: fixed;
z-index: 80;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
padding: 40rpx;
background: rgba(23, 33, 31, 0.45);
}
.action-modal-card {
box-sizing: border-box;
display: flex;
width: 100%;
flex-direction: column;
align-items: center;
padding: 40rpx 32rpx 32rpx;
border-radius: 28rpx;
background: #ffffff;
}
.action-modal-icon {
display: flex;
align-items: center;
justify-content: center;
width: 88rpx;
height: 88rpx;
margin-bottom: 20rpx;
border-radius: 50%;
background: #FFF1DC;
color: #8B5E24;
font-size: 44rpx;
font-weight: 800;
line-height: 1;
}
.action-modal-title {
color: #17211f;
font-size: 32rpx;
font-weight: 800;
text-align: center;
}
.action-modal-content {
margin-top: 16rpx;
color: #71807a;
font-size: 26rpx;
line-height: 1.6;
text-align: center;
}
.action-modal-input {
box-sizing: border-box;
width: 100%;
height: 88rpx;
margin-top: 24rpx;
padding: 0 24rpx;
border: 1rpx solid #e7ece9;
border-radius: 16rpx;
background: #f7faf8;
color: #17211f;
font-size: 26rpx;
}
.action-modal-actions {
display: flex;
width: 100%;
flex-direction: column;
gap: 20rpx;
margin-top: 32rpx;
}
.action-modal-actions.row {
flex-direction: row;
}
.action-modal-btn {
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
width: 100%;
height: 88rpx;
padding: 0;
border: 0;
border-radius: 20rpx;
font-size: 26rpx;
font-weight: 700;
line-height: 88rpx;
}
.action-modal-btn::after {
border: 0;
}
.action-modal-btn.secondary {
border: 1rpx solid #E7ECE9;
background: #F1F3F2;
color: #71807A;
}
.action-modal-btn.primary {
background: #247B63;
color: #ffffff;
}
.action-modal-btn.danger {
background: #B3261E;
color: #ffffff;
}
.action-modal-actions.row .action-modal-btn {
width: auto;
min-width: 0;
flex: 1 1 0;
}
@@ -2,6 +2,7 @@ const planningApi = require('../../api/planning')
const customersApi = require('../../api/customers')
const { markPlanningRefresh } = require('../../utils/planning-refresh')
const { showErrorToast, toUserMessage } = require('../../utils/toast')
const { showActionModal } = require('../../utils/action-modal')
function displayValue(value, fallback) {
if (value === null || value === undefined) return fallback
@@ -127,21 +128,20 @@ Page({
this.updateStatus(2)
},
cancel() {
async cancel() {
if (!this.data.showCancel || this.data.updating) return
this._cancelReason = ''
wx.showModal({
const result = await showActionModal(this, {
title: '取消预约',
editable: true,
placeholderText: '可填写取消原因',
content: '',
cancelText: '取消',
confirmText: '确认取消',
success: result => {
if (!result.confirm) return
this._cancelReason = result.content || ''
this.updateStatus(3)
}
confirmType: 'danger'
})
if (!result.confirm) return
this._cancelReason = result.content || ''
this.updateStatus(3)
},
async dialCustomer() {
@@ -1,3 +1,6 @@
{
"navigationBarTitleText": "预约详情"
"navigationBarTitleText": "预约详情",
"usingComponents": {
"action-modal": "/components/action-modal/index"
}
}
@@ -85,4 +85,5 @@
<button wx:if="{{showComplete}}" class="secondary-btn" loading="{{updating}}" disabled="{{updating}}" bindtap="complete">{{appointment.historicalBackfill ? '完成补单' : '完成服务'}}</button>
<button wx:if="{{showCancel}}" class="danger-btn" loading="{{updating}}" disabled="{{updating}}" bindtap="cancel">取消预约</button>
</view>
<action-modal id="actionModal" />
</view>
+10 -13
View File
@@ -5,6 +5,7 @@ const dateUtil = require('../../utils/date')
const { markPlanningRefresh } = require('../../utils/planning-refresh')
const { uploadObjectFile } = require('../../utils/upload')
const { showErrorToast, toUserMessage } = require('../../utils/toast')
const { showActionModal } = require('../../utils/action-modal')
const DRAFT_STORAGE_PREFIX = 'managerAppointmentDraft'
const DRAFT_TTL_MS = 7 * 24 * 60 * 60 * 1000
@@ -39,15 +40,12 @@ function isShopBusinessExpired() {
return Number(userInfo.type) === 2 && userInfo.shopBusinessExpired === true
}
function showBusinessExpiryNotice() {
return new Promise(resolve => wx.showModal({
function showBusinessExpiryNotice(page) {
return showActionModal(page, {
title: '门店经营有效期已到期',
content: '当前门店暂不能新增普通预约。历史订单、查询和补录不受影响,请联系平台管理员办理续期。',
showCancel: false,
confirmText: '知道了',
success: () => resolve(),
fail: () => resolve()
}))
confirmText: '知道了'
}).then(() => {})
}
function buildDraftKey() {
@@ -1136,14 +1134,13 @@ Page({
wx.showToast({ title: '图片上传中,请稍后再恢复默认值', icon: 'none' })
return
}
const result = await new Promise(resolve => wx.showModal({
const result = await showActionModal(this, {
title: '恢复默认值',
content: '将清除本表单内容和本机草稿,但不会删除已上传图片文件。保留日历带入的日期和美甲师,确定继续吗?',
cancelText: '继续填写',
confirmText: '恢复默认',
success: resolve,
fail: () => resolve({ confirm: false })
}))
confirmType: 'danger'
})
if (!result.confirm) return
this.cancelDraftSave()
try {
@@ -1979,7 +1976,7 @@ Page({
return
}
if (isShopBusinessExpired()) {
await showBusinessExpiryNotice()
await showBusinessExpiryNotice(this)
return
}
let form = this.data.form
@@ -2079,7 +2076,7 @@ Page({
wx.redirectTo({ url: `/pages/appointment-detail/index?id=${result.orderItemId}` })
} catch (error) {
if ((error.message || '').includes('有效期') || (error.message || '').includes('到期')) {
await showBusinessExpiryNotice()
await showBusinessExpiryNotice(this)
} else {
showErrorToast(error, '提交失败')
}
@@ -2,6 +2,7 @@
"navigationBarTitleText": "新增预约",
"usingComponents": {
"entity-selector-sheet": "/components/entity-selector-sheet/index",
"product-selector-sheet": "/components/product-selector-sheet/index"
"product-selector-sheet": "/components/product-selector-sheet/index",
"action-modal": "/components/action-modal/index"
}
}
@@ -150,4 +150,5 @@
</view>
<view class="fixed-bottom"><view wx:if="{{canCreateAppointment}}" class="action-row"><button class="secondary-btn draft-btn" bindtap="saveDraft">保存草稿</button><button class="primary-btn submit-btn" loading="{{loading}}" bindtap="submit">提交预约</button></view></view>
<action-modal id="actionModal" />
</view>
@@ -5,6 +5,7 @@ const customersApi = require('../../api/customers')
const dateUtil = require('../../utils/date')
const { uploadObjectFile } = require('../../utils/upload')
const { showErrorToast, toUserMessage } = require('../../utils/toast')
const { showActionModal } = require('../../utils/action-modal')
function normalizeProduct(product, artists) {
const artistIds = String(product.bookableArtists || '').split(',').map(id => id.trim()).filter(Boolean)
@@ -42,14 +43,13 @@ Page({
wx.showToast({ title: '图片上传中,请稍后再恢复默认值', icon: 'none' })
return
}
const result = await new Promise(resolve => wx.showModal({
const result = await showActionModal(this, {
title: '恢复默认值',
content: '将清除本次补录内容,但不会删除已上传图片文件。保留入口带入的日期和美甲师,确定继续吗?',
cancelText: '继续填写',
confirmText: '恢复默认',
success: resolve,
fail: () => resolve({ confirm: false })
}))
confirmType: 'danger'
})
if (!result.confirm) return
const defaults = this._entryDefaults || {}
const artistId = defaults.artistId || ''
@@ -1,4 +1,4 @@
{
"navigationBarTitleText": "补录历史订单",
"usingComponents": { "entity-selector-sheet": "/components/entity-selector-sheet/index", "product-selector-sheet": "/components/product-selector-sheet/index" }
"usingComponents": { "entity-selector-sheet": "/components/entity-selector-sheet/index", "product-selector-sheet": "/components/product-selector-sheet/index", "action-modal": "/components/action-modal/index" }
}
@@ -97,4 +97,5 @@
<view class="manual-style-footer"><button class="manual-style-confirm" bindtap="useManualProduct">用于本次补录</button><button class="manual-style-library-link" bindtap="openProductLibrary">从款式库中选择</button></view>
</view>
</view>
<action-modal id="actionModal" />
</view>
@@ -1,6 +1,7 @@
const employeesApi = require('../../api/employees')
const { chooseImageFilePath, uploadObjectFile } = require('../../utils/upload')
const { showErrorToast, toUserMessage } = require('../../utils/toast')
const { showActionModal } = require('../../utils/action-modal')
const EMPLOYEE_COLORS = ['#7BA7C7', '#8FB89A', '#A894C7', '#D7A86E', '#D98DA5', '#79A6A3', '#B9A16B', '#9BA9C8']
const COLOR_WHEEL_RADIUS = 110
@@ -372,16 +373,15 @@ Page({
wx.showToast({ title: '已关联并通过审核', icon: 'success' })
} catch (error) {
this.setData({ associatingApplication: false })
wx.showModal({
const result = await showActionModal(this, {
title: '关联审核未完成',
content: toUserMessage(error, '美甲师档案已创建,可重试关联申请。'),
icon: 'warning',
confirmText: '重试',
cancelText: '稍后处理',
success: result => {
if (result.confirm) this.associateCreatedEmployee()
else this.setData({ onboardingVisible: true })
}
cancelText: '稍后处理'
})
if (result.confirm) this.associateCreatedEmployee()
else this.setData({ onboardingVisible: true })
}
},
@@ -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"
}
}
@@ -55,12 +55,12 @@
<view wx:if="{{applicationId && !applicationApproved}}" class="association-retry-box">
<text>申请编号 {{applicationNo || applicationId}}</text>
<button class="primary-btn onboarding-primary" loading="{{associatingApplication}}" disabled="{{associatingApplication}}" bindtap="associateCreatedEmployee">重试关联并通过审核</button>
<button class="onboarding-skip" disabled="{{associatingApplication}}" bindtap="leaveAssociationForLater">稍后处理</button>
<button class="secondary-btn onboarding-skip" disabled="{{associatingApplication}}" bindtap="leaveAssociationForLater">稍后处理</button>
</view>
<block wx:else>
<text class="onboarding-default-note">不立即设置时,将默认全年无休、全天排班(00:00-23:59);实际预约仍受门店营业时间限制,之后可在排班设置中调整。</text>
<button class="primary-btn onboarding-primary" loading="{{savingDefaultSchedule}}" disabled="{{savingDefaultSchedule}}" bindtap="setupFirstSchedule">{{pickerMode ? '设置排班并分配' : '立即设置排班'}}</button>
<button class="onboarding-skip" loading="{{savingDefaultSchedule}}" disabled="{{savingDefaultSchedule}}" bindtap="skipFirstSchedule">{{pickerMode ? '暂不设置(使用全天排班)' : '不设置,保留全天排班'}}</button>
<button class="secondary-btn onboarding-skip" loading="{{savingDefaultSchedule}}" disabled="{{savingDefaultSchedule}}" bindtap="skipFirstSchedule">{{pickerMode ? '暂不设置(使用全天排班)' : '不设置,保留全天排班'}}</button>
</block>
</view>
</view>
@@ -87,4 +87,5 @@
</view>
<entity-selector-sheet visible="{{userPickerVisible}}" title="选择微信用户" keyword="{{userKeyword}}" placeholder="搜索昵称或手机号" items="{{userItems}}" selected-id="{{selectedWechatUserId}}" loading="{{userLoading}}" empty-text="暂无未关联的微信用户" action-text="暂不关联" bind:search="onUserSearch" bind:select="selectWechatUser" bind:action="closeUserPicker" bind:close="closeUserPicker" />
<entity-selector-sheet visible="{{associationSheetVisible}}" title="关联待审核申请" keyword="{{associationKeyword}}" placeholder="搜索申请昵称、手机号或编号" items="{{associationItems}}" selected-id="{{associationSelectedId}}" loading="{{associationLoading}}" empty-text="暂无可关联申请" action-text="暂不关联,继续" bind:search="onAssociationSearch" bind:select="selectAssociation" bind:action="skipAssociation" bind:close="skipAssociation" />
<action-modal id="actionModal" />
</view>
@@ -301,6 +301,6 @@
.onboarding-desc { margin-top: 12rpx; color: #837b72; font-size: 23rpx; line-height: 1.7; text-align: center; }
.onboarding-default-note { margin-top: 14rpx; padding: 14rpx 16rpx; border-radius: 12rpx; background: #eff7f2; color: #39705d; font-size: 21rpx; line-height: 1.55; text-align: left; }
.onboarding-primary { width: 100%; margin-top: 30rpx; }
.onboarding-skip { margin-top: 12rpx; background: transparent; color: #7e776f; font-size: 23rpx; }
.onboarding-skip { margin-top: 20rpx; }
.association-retry-box { width: 100%; margin-top: 20rpx; padding: 18rpx; box-sizing: border-box; border-radius: 12rpx; background: #fff5f3; color: #8f4d46; font-size: 22rpx; text-align: center; }
.association-retry-box .onboarding-primary { margin-top: 18rpx; }
+11 -17
View File
@@ -7,6 +7,7 @@ const { normalizeAvatar } = require('../../utils/profile-card')
const profileCache = require('../../utils/profile-cache')
const employeesApi = require('../../api/employees')
const { showErrorToast, toUserMessage } = require('../../utils/toast')
const { showActionModal } = require('../../utils/action-modal')
function canCreateAppointment() {
const app = getApp()
@@ -287,15 +288,11 @@ Page({
}
if (!summary.noticeEnabled || Number(summary.pendingCount || 0) <= 0) return false
app.globalData.reviewNoticeShown = true
const result = await new Promise(resolve => {
wx.showModal({
title: '有美甲师申请待审核',
content: `当前有 ${summary.pendingCount} 条美甲师加入申请,请在小程序员工页面审核。是否立即处理?`,
cancelText: '稍后处理',
confirmText: '立即审核',
success: resolve,
fail: () => resolve({ confirm: false })
})
const result = await showActionModal(this, {
title: '有美甲师申请待审核',
content: `当前有 ${summary.pendingCount} 条美甲师加入申请,请在小程序员工页面审核。是否立即处理?`,
cancelText: '稍后处理',
confirmText: '立即审核'
})
if (!result.confirm) return false
app.globalData.openEmployeeReview = true
@@ -934,21 +931,18 @@ Page({
wx.navigateTo({ url: `/pages/artist-transfer/index?id=${event.currentTarget.dataset.id}` })
},
quickCancel(event) {
async quickCancel(event) {
const appointment = (this._calendarData && this._calendarData.appointments || []).find(item => String(item.orderItemId) === String(event.currentTarget.dataset.id))
if (!appointment) return
wx.showModal({
const result = await showActionModal(this, {
title: '取消预约',
editable: true,
placeholderText: '可填写取消原因',
content: '',
cancelText: '取消',
confirmText: '确认取消',
success: result => {
if (result.confirm) {
this.updateAppointmentStatus(appointment.orderId, 3, result.content || '')
}
}
confirmType: 'danger'
})
if (result.confirm) this.updateAppointmentStatus(appointment.orderId, 3, result.content || '')
},
async updateAppointmentStatus(orderId, status, cancelReason) {
+4 -1
View File
@@ -1,3 +1,6 @@
{
"navigationBarTitleText": "日程"
"navigationBarTitleText": "日程",
"usingComponents": {
"action-modal": "/components/action-modal/index"
}
}
+2 -1
View File
@@ -48,7 +48,7 @@
<view class="wechat-avatar-hint">{{profileSaving ? '上传中' : '点击更换'}}</view>
</button>
<input class="wechat-nickname" type="nickname" value="{{profileForm.nickname}}" bindinput="onNicknameInput" placeholder="填写微信昵称" />
<button class="profile-save" loading="{{profileSaving}}" bindtap="saveWechatProfile">保存资料</button><button class="profile-skip" bindtap="skipProfilePrompt">暂时跳过</button>
<button class="primary-btn profile-save" loading="{{profileSaving}}" bindtap="saveWechatProfile">保存资料</button><button class="secondary-btn profile-skip" bindtap="skipProfilePrompt">暂时跳过</button>
</view>
</view>
@@ -226,4 +226,5 @@
</block>
<button wx:if="{{canCreateAppointment && businessHoursConfigured && !calendarError && (viewMode !== 'day' || currentShopOpen)}}" class="fab" bindtap="createAppointment">+</button>
<action-modal id="actionModal" />
</view>
+10 -8
View File
@@ -2,7 +2,7 @@
padding-top: 18rpx;
}
.phone-banner { display:flex; align-items:center; margin-bottom:18rpx; padding:16rpx 18rpx; border-radius:14rpx; background:#fff2d8; color:#815f2b; overflow:hidden; }.phone-banner-track { display:flex; flex:1; width:0; gap:50rpx; white-space:nowrap; animation:phoneBannerScroll 10s linear infinite; font-size:22rpx; }.phone-banner-close { position:relative; z-index:2; margin-left:18rpx; padding:6rpx; background:#fff2d8; font-size:32rpx; }.profile-prompt-mask { position:fixed; z-index:30; inset:0; display:flex; align-items:center; justify-content:center; padding:40rpx; background:rgba(25,41,33,.55); }.profile-prompt { box-sizing:border-box; display:flex; width:100%; flex-direction:column; align-items:center; padding:36rpx; border-radius:24rpx; background:#fff; }.profile-prompt-title { color:#17211f; font-size:32rpx; font-weight:800; }.profile-prompt-desc { margin-top:10rpx; color:#71807a; font-size:22rpx; text-align:center; }.wechat-nickname { box-sizing:border-box; width:100%; height:80rpx; margin-top:24rpx; padding:0 22rpx; border:1rpx solid #dce8df; border-radius:13rpx; background:#f7faf8; }.profile-save { width:100%; height:80rpx; margin-top:22rpx; border-radius:14rpx; background:#247b63; color:#fff; line-height:80rpx; }.profile-skip { margin-top:12rpx; background:transparent; color:#7e8e85; font-size:23rpx; }
.phone-banner { display:flex; align-items:center; margin-bottom:18rpx; padding:16rpx 18rpx; border-radius:14rpx; background:#fff2d8; color:#815f2b; overflow:hidden; }.phone-banner-track { display:flex; flex:1; width:0; gap:50rpx; white-space:nowrap; animation:phoneBannerScroll 10s linear infinite; font-size:22rpx; }.phone-banner-close { position:relative; z-index:2; margin-left:18rpx; padding:6rpx; background:#fff2d8; font-size:32rpx; }.profile-prompt-mask { position:fixed; z-index:30; inset:0; display:flex; align-items:center; justify-content:center; padding:40rpx; background:rgba(25,41,33,.55); }.profile-prompt { box-sizing:border-box; display:flex; width:100%; flex-direction:column; align-items:center; padding:36rpx; border-radius:24rpx; background:#fff; }.profile-prompt-title { color:#17211f; font-size:32rpx; font-weight:800; }.profile-prompt-desc { margin-top:10rpx; color:#71807a; font-size:22rpx; text-align:center; }.wechat-nickname { box-sizing:border-box; width:100%; height:80rpx; margin-top:24rpx; padding:0 22rpx; border:1rpx solid #dce8df; border-radius:13rpx; background:#f7faf8; }.profile-save { margin-top:22rpx; }.profile-skip { margin-top:20rpx; }
.wechat-avatar {
position: relative;
@@ -40,16 +40,18 @@
.wechat-avatar-hint {
position: absolute;
right: 0;
bottom: 0;
left: 0;
height: 38rpx;
background: rgba(22, 27, 25, 0.68);
left: 50%;
height: 44rpx;
padding: 0 24rpx;
border-radius: 22rpx;
background: rgba(0, 0, 0, 0.55);
color: #fff;
font-size: 19rpx;
font-size: 22rpx;
font-weight: 600;
line-height: 38rpx;
text-align: center;
line-height: 44rpx;
white-space: nowrap;
transform: translateX(-50%);
}
@keyframes phoneBannerScroll { from { transform:translateX(0); } to { transform:translateX(-48%); } }
+7 -5
View File
@@ -5,6 +5,7 @@ const { buildProfileCard } = require('../../utils/profile-card')
const profileCache = require('../../utils/profile-cache')
const authApi = require('../../api/auth')
const { showErrorToast } = require('../../utils/toast')
const { showActionModal } = require('../../utils/action-modal')
function resolveRoleText(type) {
const role = Number(type)
@@ -118,13 +119,14 @@ Page({
},
async logout() {
const confirmed = await new Promise(resolve => wx.showModal({
const result = await showActionModal(this, {
title: '退出登录',
content: '退出后将关闭自动登录,并清除本机提醒设置。',
success: result => resolve(result.confirm),
fail: () => resolve(false)
}))
if (!confirmed) return
cancelText: '取消',
confirmText: '确定',
confirmType: 'danger'
})
if (!result.confirm) return
try { await authApi.logout() } catch (error) {}
getApp().logoutDevice()
wx.reLaunch({ url: '/pages/login/index' })
+4 -1
View File
@@ -1,3 +1,6 @@
{
"navigationBarTitleText": "我的"
"navigationBarTitleText": "我的",
"usingComponents": {
"action-modal": "/components/action-modal/index"
}
}
+1
View File
@@ -60,4 +60,5 @@
</view>
<button class="profile-logout" bindtap="logout">退出登录</button>
<action-modal id="actionModal" />
</view>
@@ -2,6 +2,7 @@ const employeesApi = require('../../api/employees')
const dateUtil = require('../../utils/date')
const { markPlanningRefresh } = require('../../utils/planning-refresh')
const { showErrorToast, toUserMessage } = require('../../utils/toast')
const { showActionModal } = require('../../utils/action-modal')
const PRESETS = [
{ value: 'DOUBLE_REST', label: '双休', workDays: [1, 2, 3, 4, 5], startTime: '09:00', endTime: '17:00' },
@@ -254,7 +255,7 @@ Page({
}
} catch (error) {
const message = toUserMessage(error, '保存失败')
wx.showModal({ title: '排班保存失败', content: message, showCancel: false, confirmText: '知道了' })
await showActionModal(this, { title: '排班保存失败', content: message, confirmText: '知道了' })
} finally {
this.setData({ saving: false })
}
@@ -285,7 +286,7 @@ Page({
await this.loadRule()
} catch (error) {
const message = toUserMessage(error, '例外保存失败')
wx.showModal({ title: '特殊日期保存失败', content: message, showCancel: false, confirmText: '知道了' })
await showActionModal(this, { title: '特殊日期保存失败', content: message, confirmText: '知道了' })
} finally {
this.setData({ saving: false })
}
@@ -1,3 +1,6 @@
{
"navigationBarTitleText": "排班设置"
"navigationBarTitleText": "排班设置",
"usingComponents": {
"action-modal": "/components/action-modal/index"
}
}
@@ -69,4 +69,5 @@
<view class="fixed-bottom">
<button class="primary-btn" loading="{{saving}}" bindtap="save">{{onboarding && onboardingSource === 'appointment' ? '保存排班并继续分配' : '保存排班规则'}}</button>
</view>
<action-modal id="actionModal" />
</view>
+3 -3
View File
@@ -2,6 +2,7 @@ const { BRAND_CONFIG } = require('../../utils/config')
const profileCache = require('../../utils/profile-cache')
const shopApi = require('../../api/shop')
const { showErrorToast, toUserMessage } = require('../../utils/toast')
const { showActionModal } = require('../../utils/action-modal')
function resolveNameStatus(value) {
const status = String(value || '').toUpperCase()
@@ -164,11 +165,10 @@ Page({
}
},
explainDefaultDuration() {
wx.showModal({
async explainDefaultDuration() {
await showActionModal(this, {
title: '默认时长',
content: '用于新建预约表单的初始值和未设置款式时的后备时长。已选款式的时长或你在预约中修改的时长优先。',
showCancel: false,
confirmText: '知道了'
})
},
@@ -1,3 +1,6 @@
{
"navigationBarTitleText": "店铺设置"
"navigationBarTitleText": "店铺设置",
"usingComponents": {
"action-modal": "/components/action-modal/index"
}
}
@@ -19,4 +19,5 @@
<button class="settings-action" loading="{{settingsSaving}}" disabled="{{settingsSaving}}" bindtap="saveAppointmentSettings">保存预约设置</button>
</view>
<view wx:elif="{{settingsLoading}}" class="settings-loading">正在加载店铺设置…</view>
<action-modal id="actionModal" />
</view>
+34
View File
@@ -0,0 +1,34 @@
function showActionModal(page, options = {}) {
const modal = page && typeof page.selectComponent === 'function' ? page.selectComponent('#actionModal') : null
if (modal && typeof modal.open === 'function') {
return new Promise(resolve => {
modal.open({
title: options.title,
content: options.content,
icon: options.icon,
cancelText: options.cancelText,
confirmText: options.confirmText,
confirmType: options.confirmType,
layout: options.layout,
editable: options.editable,
placeholderText: options.placeholderText,
onClose: resolve
})
})
}
return new Promise(resolve => {
wx.showModal({
title: options.title,
content: options.content || '',
cancelText: options.cancelText,
confirmText: options.confirmText,
showCancel: !!options.cancelText,
editable: options.editable === true,
placeholderText: options.placeholderText,
success: resolve,
fail: () => resolve({ confirm: false, cancel: true, content: '' })
})
})
}
module.exports = { showActionModal }