修复管理师端预约与登录体验
This commit is contained in:
@@ -139,10 +139,10 @@ const DEVELOP_TARGET = Object.prototype.hasOwnProperty.call(localOverride, 'deve
|
||||
const BASE_DOMAIN = resolveDomain(DOMAIN_MAP, ENV_VERSION, DEVELOP_TARGET)
|
||||
const brandOverride = localOverride.brand || {}
|
||||
const BRAND_CONFIG = {
|
||||
appName: String(brandOverride.appName || '指尖管理师'),
|
||||
productName: String(brandOverride.productName || 'Fingertip Designer'),
|
||||
defaultShopName: String(brandOverride.defaultShopName || 'Fingertip Designer'),
|
||||
registerShopPlaceholder: String(brandOverride.registerShopPlaceholder || '例如:Fingertip Designer')
|
||||
appName: String(brandOverride.appName || '甲屿店务'),
|
||||
productName: String(brandOverride.productName || '甲屿设计师'),
|
||||
defaultShopName: String(brandOverride.defaultShopName || '甲屿设计师'),
|
||||
registerShopPlaceholder: String(brandOverride.registerShopPlaceholder || '例如:甲屿设计师')
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -3,10 +3,10 @@ module.exports = {
|
||||
requestTimeout: 10000,
|
||||
enableRequestSigning: true,
|
||||
brand: {
|
||||
appName: '指尖管理师',
|
||||
productName: 'Fingertip Designer',
|
||||
defaultShopName: 'Fingertip Designer',
|
||||
registerShopPlaceholder: '例如:Fingertip Designer'
|
||||
appName: '甲屿店务',
|
||||
productName: '甲屿设计师',
|
||||
defaultShopName: '甲屿设计师',
|
||||
registerShopPlaceholder: '例如:甲屿设计师'
|
||||
},
|
||||
domains: {
|
||||
local: 'http://127.0.0.1:80',
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
const date = require('./date')
|
||||
|
||||
const artists = [
|
||||
{ id: 101, name: '小王', shortName: '王', color: '#7BA7C7', status: 1, statusText: '可预约', rangeCount: 0 },
|
||||
{ id: 102, name: '小李', shortName: '李', color: '#8FB89A', status: 1, statusText: '可预约', rangeCount: 0 },
|
||||
{ id: 103, name: '小张', shortName: '张', color: '#A894C7', status: 1, statusText: '可预约', rangeCount: 0 }
|
||||
]
|
||||
|
||||
function countFor(day, index) {
|
||||
const seed = day.getDate() + index * 2 + day.getMonth()
|
||||
if (seed % 7 === 0) return 0
|
||||
return (seed % 4) + 1
|
||||
}
|
||||
|
||||
function buildCalendar(currentDate) {
|
||||
const start = date.startOfMonth(currentDate)
|
||||
const end = date.endOfMonth(currentDate)
|
||||
const daySummaries = []
|
||||
const appointments = []
|
||||
let cursor = new Date(start.getTime())
|
||||
let orderItemId = 1
|
||||
while (cursor <= end) {
|
||||
const dateText = date.formatDate(cursor)
|
||||
const artistCounts = artists.map((artist, index) => {
|
||||
const count = countFor(cursor, index)
|
||||
return {
|
||||
artistId: artist.id,
|
||||
artistName: artist.name,
|
||||
shortName: artist.shortName,
|
||||
color: artist.color,
|
||||
count,
|
||||
status: count >= 4 ? 'full' : count > 0 ? 'working' : 'free'
|
||||
}
|
||||
})
|
||||
const totalCount = artistCounts.reduce((sum, item) => sum + item.count, 0)
|
||||
daySummaries.push({
|
||||
date: dateText,
|
||||
totalCount,
|
||||
artistCounts,
|
||||
dayStatus: totalCount >= 8 ? 'full' : totalCount > 0 ? 'working' : 'free'
|
||||
})
|
||||
artistCounts.forEach((count, artistIndex) => {
|
||||
for (let i = 0; i < Math.min(count.count, 3); i += 1) {
|
||||
const startMinute = 10 * 60 + ((artistIndex * 90 + i * 110 + cursor.getDate() * 5) % 620)
|
||||
const duration = i % 2 === 0 ? 90 : 60
|
||||
const artist = artists[artistIndex]
|
||||
appointments.push({
|
||||
orderId: 9000 + orderItemId,
|
||||
orderItemId,
|
||||
customerName: ['王女士', '陈女士', '林女士', '赵女士'][i % 4],
|
||||
customerPhone: '138****' + String(1000 + orderItemId).slice(-4),
|
||||
productTitle: ['纯色美甲', '猫眼延长', '手部护理', '法式款'][i % 4],
|
||||
artistId: artist.id,
|
||||
artistName: artist.name,
|
||||
artistColor: artist.color,
|
||||
date: dateText,
|
||||
startTime: `${dateText} ${date.timeFromMinutes(startMinute)}:00`,
|
||||
endTime: `${dateText} ${date.timeFromMinutes(startMinute + duration)}:00`,
|
||||
startMinute,
|
||||
durationMinutes: duration,
|
||||
status: i === 2 ? 0 : 1,
|
||||
statusText: i === 2 ? '待确认' : '已确认',
|
||||
remark: ''
|
||||
})
|
||||
orderItemId += 1
|
||||
}
|
||||
})
|
||||
cursor = date.addDays(cursor, 1)
|
||||
}
|
||||
artists.forEach(artist => {
|
||||
artist.rangeCount = appointments.filter(item => item.artistId === artist.id).length
|
||||
})
|
||||
return {
|
||||
businessStartTime: '10:00',
|
||||
businessEndTime: '22:00',
|
||||
slotMinutes: 30,
|
||||
artists,
|
||||
schedules: [],
|
||||
appointments,
|
||||
daySummaries
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
artists,
|
||||
buildCalendar
|
||||
}
|
||||
@@ -9,6 +9,8 @@ const HEADER_NONCE = 'X-Nonce'
|
||||
const HEADER_SIGNATURE = 'X-Signature'
|
||||
const HEADER_SIGNATURE_VERSION = 'X-Sign-Version'
|
||||
|
||||
let sessionExpiredHandling = false
|
||||
|
||||
function buildUrl(url, params) {
|
||||
const sourceParams = params || {}
|
||||
const baseUrl = sourceParams.__baseUrl ? sourceParams.__baseUrl : ADMIN_API_BASE_URL
|
||||
@@ -27,6 +29,47 @@ function normalizeError(message, raw) {
|
||||
return error
|
||||
}
|
||||
|
||||
function resolveResponseMessage(response, fallbackMessage) {
|
||||
const data = response && response.data ? response.data : {}
|
||||
return data.message || fallbackMessage
|
||||
}
|
||||
|
||||
function clearRuntimeSession() {
|
||||
const app = getApp()
|
||||
if (app && typeof app.clearSession === 'function') {
|
||||
app.clearSession()
|
||||
return
|
||||
}
|
||||
auth.clearSession()
|
||||
}
|
||||
|
||||
function redirectToLoginAfterExpired(message) {
|
||||
if (sessionExpiredHandling) {
|
||||
return
|
||||
}
|
||||
sessionExpiredHandling = true
|
||||
clearRuntimeSession()
|
||||
wx.showToast({
|
||||
title: message,
|
||||
icon: 'none',
|
||||
duration: 1200
|
||||
})
|
||||
setTimeout(() => {
|
||||
wx.reLaunch({
|
||||
url: '/pages/login/index',
|
||||
complete() {
|
||||
sessionExpiredHandling = false
|
||||
}
|
||||
})
|
||||
}, 700)
|
||||
}
|
||||
|
||||
function handleUnauthorized(response) {
|
||||
const message = resolveResponseMessage(response, '登录已过期,请重新登录')
|
||||
redirectToLoginAfterExpired(message)
|
||||
return normalizeError(message, response)
|
||||
}
|
||||
|
||||
function extractPath(value) {
|
||||
const target = String(value || '')
|
||||
if (!target) {
|
||||
@@ -71,6 +114,7 @@ function isAuthFreePath(url) {
|
||||
'/auth/register',
|
||||
'/user/send-verification-code',
|
||||
'/user/phone-login',
|
||||
'/user/check/login-shops/',
|
||||
'/legal-agreement/current'
|
||||
].some(path => String(url || '').includes(path))
|
||||
}
|
||||
@@ -134,9 +178,7 @@ function request(options) {
|
||||
},
|
||||
success(response) {
|
||||
if (response.statusCode === 401) {
|
||||
auth.clearSession()
|
||||
wx.reLaunch({ url: '/pages/login/index' })
|
||||
reject(normalizeError('登录已失效,请重新登录', response))
|
||||
reject(handleUnauthorized(response))
|
||||
return
|
||||
}
|
||||
if (response.statusCode >= 400) {
|
||||
@@ -149,6 +191,10 @@ function request(options) {
|
||||
resolve(payload.data)
|
||||
return
|
||||
}
|
||||
if (payload.code === 401) {
|
||||
reject(handleUnauthorized({ data: payload }))
|
||||
return
|
||||
}
|
||||
reject(normalizeError(payload.message || '请求失败', payload))
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user