功能:新增微信小程序界面
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
function formatPrice(value) {
|
||||
return Number(value || 0).toFixed(2)
|
||||
}
|
||||
|
||||
function getProductTitle(product) {
|
||||
return (product && (product.title || product.name)) || '未命名作品'
|
||||
}
|
||||
|
||||
function splitCsv(value) {
|
||||
return String(value || '')
|
||||
.split(',')
|
||||
.map(item => item.trim())
|
||||
.filter(Boolean)
|
||||
}
|
||||
|
||||
function sameId(left, right) {
|
||||
return String(left || '') === String(right || '')
|
||||
}
|
||||
|
||||
function formatDateTime(value) {
|
||||
if (!value) {
|
||||
return ''
|
||||
}
|
||||
return String(value).replace('T', ' ').slice(0, 16)
|
||||
}
|
||||
|
||||
function parseAppointmentParts(value) {
|
||||
const text = formatDateTime(value)
|
||||
if (!text) {
|
||||
return {
|
||||
date: '',
|
||||
clock: ''
|
||||
}
|
||||
}
|
||||
|
||||
const parts = text.split(' ')
|
||||
return {
|
||||
date: parts[0] || '',
|
||||
clock: parts[1] || ''
|
||||
}
|
||||
}
|
||||
|
||||
function buildAppointmentValue(date, clock) {
|
||||
if (!date || !clock) {
|
||||
return ''
|
||||
}
|
||||
return `${date} ${clock}:00`
|
||||
}
|
||||
|
||||
function isPastAppointment(value) {
|
||||
if (!value) {
|
||||
return false
|
||||
}
|
||||
return new Date(String(value).replace(' ', 'T')).getTime() < Date.now() + 5 * 60 * 1000
|
||||
}
|
||||
|
||||
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}`
|
||||
}
|
||||
|
||||
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 '已取消'
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user