phone-dial.js 421 B

12345678910111213141516
  1. /** 规范化号码:去首尾空白与常见空格 */
  2. export function normalizeDialNumber(phone) {
  3. return String(phone ?? '')
  4. .trim()
  5. .replace(/\s/g, '')
  6. }
  7. /** 一键拨号;号码为空时提示 */
  8. export function dialPhone(phone) {
  9. const raw = normalizeDialNumber(phone)
  10. if (!raw) {
  11. uni.showToast({ title: '暂无号码', icon: 'none' })
  12. return
  13. }
  14. uni.makePhoneCall({ phoneNumber: raw })
  15. }