diff --git a/AGENTS.md b/AGENTS.md index fcafeba6..d90e86b6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,7 +1,7 @@ # GitNexus — Code Intelligence -This project is indexed by GitNexus as **xiaowang** (15795 symbols, 31793 relationships, 300 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely. +This project is indexed by GitNexus as **xiaowang** (16101 symbols, 32240 relationships, 300 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely. > If any GitNexus tool warns the index is stale, run `npx gitnexus analyze` in terminal first. diff --git a/CLAUDE.md b/CLAUDE.md index e392f45b..40e2bf36 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,7 +1,7 @@ # GitNexus — Code Intelligence -This project is indexed by GitNexus as **xiaowang** (15795 symbols, 31793 relationships, 300 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely. +This project is indexed by GitNexus as **xiaowang** (16101 symbols, 32240 relationships, 300 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely. > If any GitNexus tool warns the index is stale, run `npx gitnexus analyze` in terminal first. diff --git a/FingertipManager-Program/api/auth.js b/FingertipManager-Program/api/auth.js new file mode 100644 index 00000000..b8955e35 --- /dev/null +++ b/FingertipManager-Program/api/auth.js @@ -0,0 +1,41 @@ +const request = require('../utils/request') +const { API_DOMAIN } = require('../utils/config') + +module.exports = { + login(data) { + return request({ + url: '/auth/login', + method: 'POST', + data + }) + }, + + register(data) { + return request({ + url: '/auth/register', + method: 'POST', + data + }) + }, + + sendCode(phone) { + return request({ + url: '/user/send-verification-code', + method: 'POST', + params: { + __baseUrl: API_DOMAIN + }, + data: { + phone, + sceneCode: 'PLANNING_MANAGER_REGISTER' + } + }) + }, + + logout() { + return request({ + url: '/auth/logout', + method: 'POST' + }) + } +} diff --git a/FingertipManager-Program/api/customers.js b/FingertipManager-Program/api/customers.js new file mode 100644 index 00000000..e86c5ab5 --- /dev/null +++ b/FingertipManager-Program/api/customers.js @@ -0,0 +1,20 @@ +const request = require('../utils/request') + +module.exports = { + list(params) { + return request({ + url: '/user/list', + params: { + type: 0, + hasOrder: true, + ...params + } + }) + }, + + detail(id) { + return request({ + url: `/user/detail/${id}` + }) + } +} diff --git a/FingertipManager-Program/api/employees.js b/FingertipManager-Program/api/employees.js new file mode 100644 index 00000000..d5c2b8e0 --- /dev/null +++ b/FingertipManager-Program/api/employees.js @@ -0,0 +1,39 @@ +const request = require('../utils/request') + +module.exports = { + list(params) { + return request({ + url: '/nail-artist/list', + params + }) + }, + + detail(userId) { + return request({ + url: `/nail-artist/get/${userId}` + }) + }, + + save(data) { + return request({ + url: '/nail-artist/save', + method: 'POST', + data + }) + }, + + schedules(params) { + return request({ + url: '/artist-schedule/list', + params + }) + }, + + saveSchedule(data) { + return request({ + url: '/artist-schedule/save', + method: 'POST', + data + }) + } +} diff --git a/FingertipManager-Program/api/planning.js b/FingertipManager-Program/api/planning.js new file mode 100644 index 00000000..3cfae429 --- /dev/null +++ b/FingertipManager-Program/api/planning.js @@ -0,0 +1,40 @@ +const request = require('../utils/request') + +module.exports = { + calendar(params) { + return request({ + url: '/planning/calendar', + params + }) + }, + + createAppointment(data) { + return request({ + url: '/planning/appointments', + method: 'POST', + data + }) + }, + + appointment(orderItemId) { + return request({ + url: `/planning/appointments/${orderItemId}` + }) + }, + + moveAppointment(orderItemId, data) { + return request({ + url: `/planning/appointments/${orderItemId}/time-artist`, + method: 'PUT', + data + }) + }, + + updateStatus(orderId, status) { + return request({ + url: `/planning/appointments/${orderId}/status`, + method: 'PUT', + data: { status } + }) + } +} diff --git a/FingertipManager-Program/api/products.js b/FingertipManager-Program/api/products.js new file mode 100644 index 00000000..5441ff71 --- /dev/null +++ b/FingertipManager-Program/api/products.js @@ -0,0 +1,10 @@ +const request = require('../utils/request') + +module.exports = { + list(params) { + return request({ + url: '/product/list', + params + }) + } +} diff --git a/FingertipManager-Program/api/shop.js b/FingertipManager-Program/api/shop.js new file mode 100644 index 00000000..e1704809 --- /dev/null +++ b/FingertipManager-Program/api/shop.js @@ -0,0 +1,24 @@ +const request = require('../utils/request') + +module.exports = { + settings() { + return request({ + url: '/shops/current' + }) + }, + + saveSettings(data) { + return request({ + url: '/shops/current', + method: 'PUT', + data + }) + }, + + exportData(params) { + return request({ + url: '/export', + params + }) + } +} diff --git a/FingertipManager-Program/app.js b/FingertipManager-Program/app.js new file mode 100644 index 00000000..0343d4d0 --- /dev/null +++ b/FingertipManager-Program/app.js @@ -0,0 +1,31 @@ +const auth = require('./utils/auth') + +App({ + globalData: { + appName: '指尖管理师', + shopName: 'Yumi Nail', + userInfo: null + }, + + onLaunch() { + this.bootstrapSession() + }, + + bootstrapSession() { + const session = auth.getSession() + this.globalData.userInfo = session.userInfo || null + if (session.shopName) { + this.globalData.shopName = session.shopName + } + }, + + setSession(session) { + auth.setSession(session) + this.bootstrapSession() + }, + + clearSession() { + auth.clearSession() + this.globalData.userInfo = null + } +}) diff --git a/FingertipManager-Program/app.json b/FingertipManager-Program/app.json new file mode 100644 index 00000000..ee0dbed0 --- /dev/null +++ b/FingertipManager-Program/app.json @@ -0,0 +1,64 @@ +{ + "pages": [ + "pages/login/index", + "pages/register/index", + "pages/planning/index", + "pages/appointment-form/index", + "pages/appointment-detail/index", + "pages/artist-transfer/index", + "pages/customers/index", + "pages/customer-detail/index", + "pages/employees/index", + "pages/employee-detail/index", + "pages/schedule-setting/index", + "pages/leave-management/index", + "pages/color-setting/index", + "pages/employee-orders/index", + "pages/profile/index", + "pages/shop-settings/index", + "pages/export/index", + "pages/password/index", + "pages/about/index" + ], + "window": { + "navigationBarTitleText": "指尖管理师", + "navigationBarBackgroundColor": "#F8F5EF", + "navigationBarTextStyle": "black", + "backgroundColor": "#F8F5EF", + "backgroundTextStyle": "dark" + }, + "tabBar": { + "color": "#8B8680", + "selectedColor": "#2F6F62", + "backgroundColor": "#FFFDF8", + "borderStyle": "white", + "list": [ + { + "pagePath": "pages/planning/index", + "text": "规划", + "iconPath": "assets/tabbar/planning.png", + "selectedIconPath": "assets/tabbar/planning-active.png" + }, + { + "pagePath": "pages/customers/index", + "text": "客户", + "iconPath": "assets/tabbar/customers.png", + "selectedIconPath": "assets/tabbar/customers-active.png" + }, + { + "pagePath": "pages/employees/index", + "text": "员工", + "iconPath": "assets/tabbar/employees.png", + "selectedIconPath": "assets/tabbar/employees-active.png" + }, + { + "pagePath": "pages/profile/index", + "text": "我的", + "iconPath": "assets/tabbar/profile.png", + "selectedIconPath": "assets/tabbar/profile-active.png" + } + ] + }, + "style": "v2", + "sitemapLocation": "sitemap.json" +} diff --git a/FingertipManager-Program/app.wxss b/FingertipManager-Program/app.wxss new file mode 100644 index 00000000..9402c400 --- /dev/null +++ b/FingertipManager-Program/app.wxss @@ -0,0 +1,257 @@ +page { + min-height: 100%; + background: #f8f5ef; + color: #26231f; + font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif; + font-size: 28rpx; +} + +view, +text, +button, +input, +textarea, +picker, +scroll-view { + box-sizing: border-box; +} + +button { + margin: 0; + padding: 0; + min-width: 0; + border-radius: 0; + background: transparent; + line-height: 1; +} + +button::after { + border: 0; +} + +.page { + min-height: 100vh; + padding: 22rpx 24rpx 140rpx; + background: #f8f5ef; +} + +.page.no-tab { + padding-bottom: 196rpx; +} + +.card { + border: 1rpx solid rgba(50, 43, 34, 0.06); + border-radius: 12px; + background: #fffdf8; + box-shadow: 0 10rpx 28rpx rgba(58, 48, 34, 0.06); +} + +.section { + margin-top: 20rpx; +} + +.section-title { + margin: 4rpx 4rpx 16rpx; + color: #4c4740; + font-size: 28rpx; + font-weight: 700; +} + +.row { + display: flex; + align-items: center; +} + +.between { + justify-content: space-between; +} + +.muted { + color: #9d968e; +} + +.tag { + display: inline-flex; + align-items: center; + min-height: 40rpx; + padding: 0 16rpx; + border-radius: 999rpx; + background: #f0ece5; + color: #6d675f; + font-size: 22rpx; + font-weight: 600; +} + +.primary-btn, +.secondary-btn, +.text-btn, +.danger-btn { + display: flex; + align-items: center; + justify-content: center; + width: 100%; + min-height: 76rpx; + border-radius: 12px; + font-size: 26rpx; + font-weight: 700; +} + +.primary-btn, +.secondary-btn, +.danger-btn { + min-width: 100%; + max-width: 100%; +} + +.primary-btn { + background: #6f8f83; + color: #fffdf8; + box-shadow: 0 12rpx 24rpx rgba(111, 143, 131, 0.22); +} + +.secondary-btn { + border: 1rpx solid #d8d1c8; + background: #fffdf8; + color: #514b44; +} + +.danger-btn { + background: #d98d8d; + color: #fff; +} + +.text-btn { + width: auto; + min-width: 0; + max-width: none; + min-height: 56rpx; + color: #6f8f83; + font-size: 26rpx; +} + +.compact-btn, +.small-action { + display: inline-flex; + align-items: center; + justify-content: center; + width: 112rpx; + min-width: 112rpx; + max-width: 112rpx; + height: 56rpx; + padding: 0 20rpx; + border-radius: 999rpx; + background: #e5eee9; + color: #55786d; + font-size: 24rpx; + font-weight: 800; +} + +.small-action { + width: 112rpx; + min-width: 104rpx; + max-width: 112rpx; + height: 52rpx; + background: #f0ece5; + color: #5f5951; +} + +.icon-btn { + display: flex; + align-items: center; + justify-content: center; + width: 64rpx; + min-width: 64rpx; + max-width: 64rpx; + height: 64rpx; + min-height: 64rpx; + padding: 0; + border-radius: 50%; + background: #fffdf8; + color: #4e4942; + box-shadow: 0 6rpx 14rpx rgba(58, 48, 34, 0.05); +} + +.form-card { + padding: 8rpx 24rpx; +} + +.field { + display: flex; + align-items: center; + min-height: 108rpx; + border-bottom: 1rpx solid #eee8df; +} + +.field:last-child { + border-bottom: 0; +} + +.field-label { + width: 180rpx; + color: #625c55; + font-size: 26rpx; + font-weight: 600; +} + +.field input, +.field textarea, +.field-value { + flex: 1; + color: #27231f; + font-size: 28rpx; +} + +.field textarea { + min-height: 140rpx; + padding: 34rpx 0; +} + +.fixed-bottom { + position: fixed; + right: 0; + bottom: 0; + left: 0; + z-index: 20; + padding: 14rpx 24rpx calc(14rpx + env(safe-area-inset-bottom)); + background: rgba(248, 245, 239, 0.94); + backdrop-filter: blur(18rpx); +} + +.fab { + position: fixed; + right: 28rpx; + bottom: calc(100rpx + env(safe-area-inset-bottom)); + z-index: 18; + display: flex; + align-items: center; + justify-content: center; + width: 84rpx; + min-width: 84rpx; + max-width: 84rpx; + height: 84rpx; + min-height: 84rpx; + padding: 0; + border-radius: 50%; + background: #6f8f83; + color: #fff; + font-size: 46rpx; + font-weight: 300; + line-height: 84rpx; + box-shadow: 0 12rpx 26rpx rgba(111, 143, 131, 0.24); +} + +.list { + display: flex; + flex-direction: column; + gap: 18rpx; +} + +.list-card { + padding: 24rpx; +} + +.empty { + padding: 56rpx 24rpx; + color: #a39b91; + text-align: center; +} diff --git a/FingertipManager-Program/assets/tabbar/customers-active.png b/FingertipManager-Program/assets/tabbar/customers-active.png new file mode 100644 index 00000000..da956a3b Binary files /dev/null and b/FingertipManager-Program/assets/tabbar/customers-active.png differ diff --git a/FingertipManager-Program/assets/tabbar/customers.png b/FingertipManager-Program/assets/tabbar/customers.png new file mode 100644 index 00000000..4d3d214a Binary files /dev/null and b/FingertipManager-Program/assets/tabbar/customers.png differ diff --git a/FingertipManager-Program/assets/tabbar/employees-active.png b/FingertipManager-Program/assets/tabbar/employees-active.png new file mode 100644 index 00000000..877a92d9 Binary files /dev/null and b/FingertipManager-Program/assets/tabbar/employees-active.png differ diff --git a/FingertipManager-Program/assets/tabbar/employees.png b/FingertipManager-Program/assets/tabbar/employees.png new file mode 100644 index 00000000..bde55544 Binary files /dev/null and b/FingertipManager-Program/assets/tabbar/employees.png differ diff --git a/FingertipManager-Program/assets/tabbar/planning-active.png b/FingertipManager-Program/assets/tabbar/planning-active.png new file mode 100644 index 00000000..f176ce48 Binary files /dev/null and b/FingertipManager-Program/assets/tabbar/planning-active.png differ diff --git a/FingertipManager-Program/assets/tabbar/planning.png b/FingertipManager-Program/assets/tabbar/planning.png new file mode 100644 index 00000000..0fc55ea6 Binary files /dev/null and b/FingertipManager-Program/assets/tabbar/planning.png differ diff --git a/FingertipManager-Program/assets/tabbar/profile-active.png b/FingertipManager-Program/assets/tabbar/profile-active.png new file mode 100644 index 00000000..3171b328 Binary files /dev/null and b/FingertipManager-Program/assets/tabbar/profile-active.png differ diff --git a/FingertipManager-Program/assets/tabbar/profile.png b/FingertipManager-Program/assets/tabbar/profile.png new file mode 100644 index 00000000..4f7172e7 Binary files /dev/null and b/FingertipManager-Program/assets/tabbar/profile.png differ diff --git a/FingertipManager-Program/minitest/test.config.json b/FingertipManager-Program/minitest/test.config.json new file mode 100644 index 00000000..41cf3d02 --- /dev/null +++ b/FingertipManager-Program/minitest/test.config.json @@ -0,0 +1,3 @@ +{ + "treeData": [] +} \ No newline at end of file diff --git a/FingertipManager-Program/pages/about/index.js b/FingertipManager-Program/pages/about/index.js new file mode 100644 index 00000000..ba768046 --- /dev/null +++ b/FingertipManager-Program/pages/about/index.js @@ -0,0 +1 @@ +Page({}) diff --git a/FingertipManager-Program/pages/about/index.json b/FingertipManager-Program/pages/about/index.json new file mode 100644 index 00000000..259eaf65 --- /dev/null +++ b/FingertipManager-Program/pages/about/index.json @@ -0,0 +1,3 @@ +{ + "navigationBarTitleText": "关于系统" +} diff --git a/FingertipManager-Program/pages/about/index.wxml b/FingertipManager-Program/pages/about/index.wxml new file mode 100644 index 00000000..eb2f3bb8 --- /dev/null +++ b/FingertipManager-Program/pages/about/index.wxml @@ -0,0 +1,11 @@ + + + + 指尖管理师 + 专为美甲店店长设计的预约排班日历子系统 + + + 版本1.0.0 + 定位规划 / 客户 / 员工 / 我的 + + diff --git a/FingertipManager-Program/pages/about/index.wxss b/FingertipManager-Program/pages/about/index.wxss new file mode 100644 index 00000000..4e769916 --- /dev/null +++ b/FingertipManager-Program/pages/about/index.wxss @@ -0,0 +1,40 @@ +.about-page { + padding-top: 80rpx; +} + +.brand-card { + display: flex; + flex-direction: column; + align-items: center; + padding: 52rpx 28rpx; +} + +.logo { + display: flex; + align-items: center; + justify-content: center; + width: 112rpx; + height: 112rpx; + border-radius: 30rpx; + background: #6f8f83; + color: #fff; + font-size: 52rpx; + font-weight: 900; +} + +.name { + margin-top: 22rpx; + font-size: 38rpx; + font-weight: 900; +} + +.desc { + margin-top: 12rpx; + color: #90887e; + font-size: 24rpx; +} + +.about-list { + margin-top: 20rpx; + padding: 24rpx; +} diff --git a/FingertipManager-Program/pages/appointment-detail/index.js b/FingertipManager-Program/pages/appointment-detail/index.js new file mode 100644 index 00000000..10ad3fda --- /dev/null +++ b/FingertipManager-Program/pages/appointment-detail/index.js @@ -0,0 +1,64 @@ +const planningApi = require('../../api/planning') +const mock = require('../../utils/mock') + +Page({ + data: { + id: '', + appointment: {}, + avatarText: '', + timeText: '' + }, + + onLoad(options) { + this.setData({ id: options.id || '' }) + this.loadDetail() + }, + + async loadDetail() { + try { + const appointment = await planningApi.appointment(this.data.id) + this.applyAppointment(appointment) + } catch (error) { + const demo = mock.buildCalendar(new Date()).appointments[0] + this.applyAppointment(demo) + } + }, + + applyAppointment(appointment) { + this.setData({ + appointment, + avatarText: String(appointment.customerName || '客').slice(0, 1), + timeText: `${(appointment.startTime || '').slice(0, 16)} - ${(appointment.endTime || '').slice(11, 16)}` + }) + }, + + async updateStatus(status) { + try { + await planningApi.updateStatus(this.data.appointment.orderId, status) + wx.showToast({ title: '已更新' }) + this.loadDetail() + } catch (error) { + wx.showToast({ title: error.message || '操作失败', icon: 'none' }) + } + }, + + confirm() { + this.updateStatus(1) + }, + + complete() { + this.updateStatus(2) + }, + + cancel() { + this.updateStatus(3) + }, + + goTransfer() { + wx.navigateTo({ url: `/pages/artist-transfer/index?id=${this.data.id}` }) + }, + + back() { + wx.navigateBack() + } +}) diff --git a/FingertipManager-Program/pages/appointment-detail/index.json b/FingertipManager-Program/pages/appointment-detail/index.json new file mode 100644 index 00000000..7712f917 --- /dev/null +++ b/FingertipManager-Program/pages/appointment-detail/index.json @@ -0,0 +1,3 @@ +{ + "navigationBarTitleText": "预约详情" +} diff --git a/FingertipManager-Program/pages/appointment-detail/index.wxml b/FingertipManager-Program/pages/appointment-detail/index.wxml new file mode 100644 index 00000000..b1725e46 --- /dev/null +++ b/FingertipManager-Program/pages/appointment-detail/index.wxml @@ -0,0 +1,46 @@ + + + + + {{avatarText}} + + {{appointment.customerName}} + {{appointment.customerPhone}} + + + + {{appointment.statusText}} + + + + + + 项目 + {{appointment.productTitle}} + + + 美甲师 + {{appointment.artistName}} + + + 时间 + {{timeText}} + + + 时长 + {{appointment.durationMinutes}}分钟 + + + + + + 备注 + {{appointment.remark || '暂无备注'}} + + + + + + + + diff --git a/FingertipManager-Program/pages/appointment-detail/index.wxss b/FingertipManager-Program/pages/appointment-detail/index.wxss new file mode 100644 index 00000000..6f074c89 --- /dev/null +++ b/FingertipManager-Program/pages/appointment-detail/index.wxss @@ -0,0 +1,99 @@ +.detail-card { + padding: 24rpx; +} + +.detail-head { + display: flex; + align-items: center; + justify-content: space-between; + gap: 18rpx; +} + +.detail-person { + display: flex; + align-items: center; + min-width: 0; + gap: 18rpx; +} + +.avatar { + display: flex; + align-items: center; + justify-content: center; + flex-shrink: 0; + width: 82rpx; + height: 82rpx; + border-radius: 50%; + background: #e5eee9; + color: #5d8175; + font-size: 32rpx; + font-weight: 900; +} + +.customer, +.phone { + display: block; +} + +.customer { + color: #24211d; + font-size: 32rpx; + font-weight: 800; +} + +.phone { + margin-top: 6rpx; + color: #928a81; + font-size: 24rpx; +} + +.detail-actions { + display: flex; + flex-shrink: 0; + align-items: center; + gap: 10rpx; +} + +.detail-grid { + display: grid; + grid-template-columns: repeat(2, 1fr); + gap: 22rpx; + margin-top: 28rpx; +} + +.label, +.value { + display: block; +} + +.label { + color: #9a9288; + font-size: 22rpx; +} + +.value { + margin-top: 8rpx; + color: #2d2924; + font-size: 28rpx; + font-weight: 700; +} + +.note-card { + padding: 24rpx; + color: #6d655d; + line-height: 1.6; +} + +.action-row { + display: grid; + grid-template-columns: 1fr 1fr 1fr; + gap: 14rpx; +} + +.action-row .primary-btn, +.action-row .secondary-btn, +.action-row .danger-btn { + width: 100%; + min-width: 0; + max-width: 100%; +} diff --git a/FingertipManager-Program/pages/appointment-form/index.js b/FingertipManager-Program/pages/appointment-form/index.js new file mode 100644 index 00000000..2ceee872 --- /dev/null +++ b/FingertipManager-Program/pages/appointment-form/index.js @@ -0,0 +1,170 @@ +const planningApi = require('../../api/planning') +const productsApi = require('../../api/products') +const mock = require('../../utils/mock') +const dateUtil = require('../../utils/date') + +Page({ + data: { + form: { + customerName: '', + phone: '', + appointmentDate: dateUtil.formatDate(new Date()), + appointmentTime: '13:00', + productId: '', + durationMinutes: '', + artistId: '', + remark: '' + }, + products: [], + artists: mock.artists, + selectedProduct: {}, + selectedArtist: {}, + conflictTip: '', + conflictLevel: 'free', + loading: false + }, + + onLoad(options) { + this.setData({ + 'form.appointmentDate': options.date || dateUtil.formatDate(new Date()), + 'form.artistId': options.artistId || '' + }) + this.loadOptions() + }, + + async loadOptions() { + const fallbackProducts = [ + { id: 1, title: '纯色美甲', approximateDuration: '90分钟' }, + { id: 2, title: '猫眼延长', approximateDuration: '120分钟' }, + { id: 3, title: '手部护理', approximateDuration: '60分钟' } + ] + try { + const productsData = await productsApi.list({ page: 1, size: 100 }) + const products = productsData.list || productsData || fallbackProducts + this.setData({ products }) + } catch (error) { + this.setData({ products: fallbackProducts }) + } + if (this.data.form.artistId) { + const selectedArtist = this.data.artists.find(item => String(item.id) === String(this.data.form.artistId)) || {} + this.setData({ selectedArtist }) + } + this.checkAvailability() + }, + + onInput(event) { + this.setData({ + [`form.${event.currentTarget.dataset.field}`]: event.detail.value + }) + }, + + onDateChange(event) { + this.setData({ 'form.appointmentDate': event.detail.value }) + this.checkAvailability() + }, + + onTimeChange(event) { + this.setData({ 'form.appointmentTime': event.detail.value }) + this.checkAvailability() + }, + + onProductChange(event) { + const selectedProduct = this.data.products[Number(event.detail.value)] || {} + this.setData({ + selectedProduct, + 'form.productId': selectedProduct.id, + 'form.durationMinutes': String(parseInt(selectedProduct.approximateDuration, 10) || this.data.form.durationMinutes || 60) + }) + this.checkAvailability() + }, + + onArtistChange(event) { + const selectedArtist = this.data.artists[Number(event.detail.value)] || {} + this.setData({ + selectedArtist, + 'form.artistId': selectedArtist.id + }) + this.checkAvailability() + }, + + async checkAvailability() { + const form = this.data.form + if (!form.appointmentDate || !form.appointmentTime || !form.artistId) { + this.setData({ conflictTip: '', conflictLevel: 'free' }) + return { ok: true } + } + const durationMinutes = Number(form.durationMinutes || 0) || 60 + const startMinute = dateUtil.minutesOfDay(form.appointmentTime) + const endMinute = startMinute + durationMinutes + if (startMinute < dateUtil.minutesOfDay('10:00') || endMinute > dateUtil.minutesOfDay('22:00')) { + const tip = '该时间超出营业时间 10:00-22:00' + this.setData({ conflictTip: tip, conflictLevel: 'danger' }) + return { ok: false, tip } + } + try { + let calendar + try { + calendar = await planningApi.calendar({ + startDate: form.appointmentDate, + endDate: form.appointmentDate, + artistId: form.artistId + }) + } catch (error) { + calendar = mock.buildCalendar(form.appointmentDate) + } + const conflicts = (calendar.appointments || []).filter(item => { + if (String(item.artistId) !== String(form.artistId) || item.date !== form.appointmentDate) return false + if (item.status === 3 || item.statusText === '已取消') return false + const itemStart = Number(item.startMinute || dateUtil.minutesOfDay((item.startTime || '').slice(11, 16))) + const itemEnd = itemStart + Number(item.durationMinutes || 60) + return startMinute < itemEnd && endMinute > itemStart + }) + if (conflicts.length > 0) { + const first = conflicts[0] + const itemStart = Number(first.startMinute || dateUtil.minutesOfDay((first.startTime || '').slice(11, 16))) + const itemEnd = itemStart + Number(first.durationMinutes || 60) + const tip = `${this.data.selectedArtist.name || '该美甲师'} ${dateUtil.timeFromMinutes(itemStart)}-${dateUtil.timeFromMinutes(itemEnd)} 已有预约` + this.setData({ conflictTip: tip, conflictLevel: 'danger' }) + return { ok: false, tip } + } + const tip = `${this.data.selectedArtist.name || '该美甲师'} ${form.appointmentTime}-${dateUtil.timeFromMinutes(endMinute)} 可预约` + this.setData({ conflictTip: tip, conflictLevel: 'free' }) + return { ok: true, tip } + } catch (error) { + const tip = '暂未获取到排班,请保存时以系统校验为准' + this.setData({ conflictTip: tip, conflictLevel: 'warn' }) + return { ok: true, tip } + } + }, + + async submit() { + const form = this.data.form + if (!form.customerName || !form.phone || !form.productId || !form.artistId) { + wx.showToast({ title: '请补全预约信息', icon: 'none' }) + return + } + const availability = await this.checkAvailability() + if (!availability.ok) { + wx.showToast({ title: availability.tip || '该时段已被预约', icon: 'none' }) + return + } + this.setData({ loading: true }) + try { + const result = await planningApi.createAppointment({ + ...form, + productId: Number(form.productId), + artistId: Number(form.artistId), + durationMinutes: Number(form.durationMinutes || 0) || undefined + }) + wx.redirectTo({ url: `/pages/appointment-detail/index?id=${result.orderItemId}` }) + } catch (error) { + wx.showToast({ title: error.message || '保存失败', icon: 'none' }) + } finally { + this.setData({ loading: false }) + } + }, + + back() { + wx.navigateBack() + } +}) diff --git a/FingertipManager-Program/pages/appointment-form/index.json b/FingertipManager-Program/pages/appointment-form/index.json new file mode 100644 index 00000000..9b43ad76 --- /dev/null +++ b/FingertipManager-Program/pages/appointment-form/index.json @@ -0,0 +1,3 @@ +{ + "navigationBarTitleText": "新建预约" +} diff --git a/FingertipManager-Program/pages/appointment-form/index.wxml b/FingertipManager-Program/pages/appointment-form/index.wxml new file mode 100644 index 00000000..c1029621 --- /dev/null +++ b/FingertipManager-Program/pages/appointment-form/index.wxml @@ -0,0 +1,59 @@ + + + + 客户姓名 + + + + 手机号 + + + + 预约日期 + + {{form.appointmentDate}} + + + + 预约时间 + + {{form.appointmentTime}} + + + + 项目内容 + + {{selectedProduct.title || '请选择项目'}} + + + + 预计时长 + + 分钟 + + + 指定员工 + + {{selectedArtist.name || '请选择美甲师'}} + + + + 备注 +