2026-05-23 18:45:41 +08:00
|
|
|
/**
|
|
|
|
|
* Purpose: formatPrice supports format.js by holding or executing the format price page or API role.
|
|
|
|
|
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
*/
|
2026-04-01 15:18:35 +08:00
|
|
|
function formatPrice(value) {
|
|
|
|
|
return Number(value || 0).toFixed(2)
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-23 18:45:41 +08:00
|
|
|
/**
|
|
|
|
|
* Purpose: getProductTitle supports format.js by holding or executing the get product title page or API role.
|
|
|
|
|
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
*/
|
2026-04-01 15:18:35 +08:00
|
|
|
function getProductTitle(product) {
|
|
|
|
|
return (product && (product.title || product.name)) || '未命名作品'
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-23 18:45:41 +08:00
|
|
|
/**
|
|
|
|
|
* Purpose: splitCsv supports format.js by holding or executing the split csv page or API role.
|
|
|
|
|
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
*/
|
2026-04-01 15:18:35 +08:00
|
|
|
function splitCsv(value) {
|
|
|
|
|
return String(value || '')
|
|
|
|
|
.split(',')
|
|
|
|
|
.map(item => item.trim())
|
|
|
|
|
.filter(Boolean)
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-23 18:45:41 +08:00
|
|
|
/**
|
|
|
|
|
* Purpose: sameId supports format.js by holding or executing the same id page or API role.
|
|
|
|
|
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
*/
|
2026-04-01 15:18:35 +08:00
|
|
|
function sameId(left, right) {
|
|
|
|
|
return String(left || '') === String(right || '')
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-23 18:45:41 +08:00
|
|
|
/**
|
|
|
|
|
* Purpose: formatDateTime supports format.js by holding or executing the format date time page or API role.
|
|
|
|
|
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
*/
|
2026-04-01 15:18:35 +08:00
|
|
|
function formatDateTime(value) {
|
|
|
|
|
if (!value) {
|
|
|
|
|
return ''
|
|
|
|
|
}
|
|
|
|
|
return String(value).replace('T', ' ').slice(0, 16)
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-23 18:45:41 +08:00
|
|
|
/**
|
|
|
|
|
* Purpose: parseAppointmentParts supports format.js by holding or executing the parse appointment parts page or API role.
|
|
|
|
|
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
*/
|
2026-04-01 15:18:35 +08:00
|
|
|
function parseAppointmentParts(value) {
|
|
|
|
|
const text = formatDateTime(value)
|
|
|
|
|
if (!text) {
|
|
|
|
|
return {
|
|
|
|
|
date: '',
|
|
|
|
|
clock: ''
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const parts = text.split(' ')
|
|
|
|
|
return {
|
|
|
|
|
date: parts[0] || '',
|
|
|
|
|
clock: parts[1] || ''
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-23 18:45:41 +08:00
|
|
|
/**
|
|
|
|
|
* Purpose: buildAppointmentValue supports format.js by holding or executing the build appointment value page or API role.
|
|
|
|
|
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
*/
|
2026-04-01 15:18:35 +08:00
|
|
|
function buildAppointmentValue(date, clock) {
|
|
|
|
|
if (!date || !clock) {
|
|
|
|
|
return ''
|
|
|
|
|
}
|
|
|
|
|
return `${date} ${clock}:00`
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-23 18:45:41 +08:00
|
|
|
/**
|
|
|
|
|
* Purpose: isPastAppointment supports format.js by holding or executing the is past appointment page or API role.
|
|
|
|
|
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
*/
|
2026-04-01 15:18:35 +08:00
|
|
|
function isPastAppointment(value) {
|
|
|
|
|
if (!value) {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
return new Date(String(value).replace(' ', 'T')).getTime() < Date.now() + 5 * 60 * 1000
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-23 18:45:41 +08:00
|
|
|
/**
|
|
|
|
|
* Purpose: getMinDateText supports format.js by holding or executing the get min date text page or API role.
|
|
|
|
|
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
*/
|
2026-04-01 15:18:35 +08:00
|
|
|
function getMinDateText() {
|
|
|
|
|
const now = new Date()
|
|
|
|
|
const year = now.getFullYear()
|
|
|
|
|
const month = String(now.getMonth() + 1).padStart(2, '0')
|
|
|
|
|
const date = String(now.getDate()).padStart(2, '0')
|
|
|
|
|
return `${year}-${month}-${date}`
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-23 18:45:41 +08:00
|
|
|
/**
|
|
|
|
|
* Purpose: getOrderStatusText supports format.js by holding or executing the get order status text page or API role.
|
|
|
|
|
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
*/
|
2026-04-01 15:18:35 +08:00
|
|
|
function getOrderStatusText(order) {
|
|
|
|
|
if (order && order.statusText) {
|
|
|
|
|
return order.statusText
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const status = Number(order && order.status)
|
|
|
|
|
if (status === 1) {
|
|
|
|
|
return '待服务'
|
|
|
|
|
}
|
|
|
|
|
if (status === 2) {
|
|
|
|
|
return '已完成'
|
|
|
|
|
}
|
|
|
|
|
return '已取消'
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-23 18:45:41 +08:00
|
|
|
/**
|
|
|
|
|
* Purpose: getOrderStatusClass supports format.js by holding or executing the get order status class page or API role.
|
|
|
|
|
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
|
|
|
|
|
*/
|
2026-04-01 15:18:35 +08:00
|
|
|
function getOrderStatusClass(order) {
|
|
|
|
|
const status = Number(order && order.status)
|
|
|
|
|
if (status === 1) {
|
|
|
|
|
return 'pending'
|
|
|
|
|
}
|
|
|
|
|
if (status === 2) {
|
|
|
|
|
return 'completed'
|
|
|
|
|
}
|
|
|
|
|
return 'cancelled'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
formatPrice,
|
|
|
|
|
getProductTitle,
|
|
|
|
|
splitCsv,
|
|
|
|
|
sameId,
|
|
|
|
|
formatDateTime,
|
|
|
|
|
parseAppointmentParts,
|
|
|
|
|
buildAppointmentValue,
|
|
|
|
|
isPastAppointment,
|
|
|
|
|
getMinDateText,
|
|
|
|
|
getOrderStatusText,
|
|
|
|
|
getOrderStatusClass
|
|
|
|
|
}
|