feat: chat integration, tenant admin spec, backend chat service, miniprogram updates, DEMO moved to tmp, XCX-TEST removed, migrations & docs

This commit is contained in:
Neo
2026-03-20 09:02:10 +08:00
parent 3d2e5f8165
commit beb88d5bea
388 changed files with 6436 additions and 25458 deletions

View File

@@ -0,0 +1,83 @@
// WXS 格式化工具 — WXML 中不能调用 JS 方法,需通过 WXS 桥接
// 规范docs/miniprogram-dev/design-system/DISPLAY-STANDARDS.md
/** 数字保留 N 位小数;空值返回 '--' */
function toFixed(num, digits) {
if (num === undefined || num === null) return '--'
return num.toFixed(digits)
}
/** 空值兜底null/undefined/'' 统一返回 '--' */
function safe(val) {
if (val === undefined || val === null || val === '') return '--'
return val
}
/**
* 金额格式化WXS 版)
* ¥12,680 / -¥368 / ¥0 / --
*/
function money(value) {
if (value === undefined || value === null) return '--'
if (value === 0) return '¥0'
var abs = Math.round(Math.abs(value))
var s = abs.toString()
var result = ''
var count = 0
for (var i = s.length - 1; i >= 0; i--) {
if (count > 0 && count % 3 === 0) result = ',' + result
result = s[i] + result
count++
}
return (value < 0 ? '-¥' : '¥') + result
}
/**
* 计数格式化WXS 版)
* 零值返回 '--'≥1000 加千分位;自动拼接单位
*/
function count(value, unit) {
if (value === undefined || value === null || value === 0) return '--'
var s = value.toString()
if (value >= 1000) {
var result = ''
var c = 0
for (var i = s.length - 1; i >= 0; i--) {
if (c > 0 && c % 3 === 0) result = ',' + result
result = s[i] + result
c++
}
return result + unit
}
return s + unit
}
/**
* 百分比展示WXS 版)
* 保留1位小数超过100%正常展示;空值返回 '--'
*/
function percent(value) {
if (value === undefined || value === null) return '--'
if (value === 0) return '0%'
return value.toFixed(1) + '%'
}
/**
* 课时格式化WXS 版)
* 整数 → Nh非整数 → N.Nh0 → 0h空 → --
*/
function hours(value) {
if (value === undefined || value === null) return '--'
if (value === 0) return '0h'
if (value % 1 === 0) return value + 'h'
return value.toFixed(1) + 'h'
}
module.exports = {
toFixed: toFixed,
safe: safe,
money: money,
count: count,
percent: percent,
hours: hours,
}