Files
shanxia2.0/miniprogram/utils/phone-dial.js
T
2026-07-11 17:15:17 +08:00

17 lines
437 B
JavaScript

/** 规范化号码:去首尾空白与常见空格 */
export function normalizeDialNumber(phone) {
return String(phone ?? '')
.trim()
.replace(/\s/g, '')
}
/** 一键拨号;号码为空时提示 */
export function dialPhone(phone) {
const raw = normalizeDialNumber(phone)
if (!raw) {
uni.showToast({ title: '暂无号码', icon: 'none' })
return
}
uni.makePhoneCall({ phoneNumber: raw })
}