From 8103f4c897f7f1d6794a2ea11957b6669d924028 Mon Sep 17 00:00:00 2001 From: jinhhanhan <1683105490@qq.com> Date: Fri, 19 Dec 2025 09:49:58 +0800 Subject: [PATCH] =?UTF-8?q?chore=EF=BC=9A=E7=94=B5=E8=AF=9D=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E5=8F=AF=E4=BB=A5=E7=82=B9=E5=87=BB=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/hover-nav/hover-nav.vue | 39 +++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/components/hover-nav/hover-nav.vue b/components/hover-nav/hover-nav.vue index f21f8a4..7d3d637 100644 --- a/components/hover-nav/hover-nav.vue +++ b/components/hover-nav/hover-nav.vue @@ -60,11 +60,18 @@ export default { this.customerService = createCustomerService(this); this.buttonConfig = this.customerService.getButtonConfig(); - var that = this; + const that = this; uni.getStorage({ key: 'shopInfo', success(e) { - that.tel = e.data.mobile; + // 校验手机号是否有效,避免空值或非手机号 + if (e.data && e.data.mobile && /^1[3-9]\d{9}$/.test(e.data.mobile)) { + that.tel = e.data.mobile; + } + }, + // 补充storage读取失败的提示 + fail() { + console.warn('未获取到店铺信息'); } }); }, @@ -96,9 +103,35 @@ export default { ...mapMutations([ 'setAiUnreadCount' ]), + /** + * 拨打电话逻辑:增加手机号校验和异常处理 + */ call() { + // 1. 校验手机号是否存在且有效 + if (!this.tel || !/^1[3-9]\d{9}$/.test(this.tel)) { + uni.showToast({ + title: '暂无有效联系电话', + icon: 'none', + duration: 2000 + }); + return; + } + + // 2. 调用系统拨号API(自动弹出拨号对话框) uni.makePhoneCall({ - phoneNumber: this.tel + '' + phoneNumber: this.tel, + // 拨号失败的回调(如用户取消、设备不支持等) + fail(err) { + console.log('拨号操作失败:', err); + // 非用户取消的情况,给出提示 + if (err.errMsg !== 'makePhoneCall:fail cancel') { + uni.showToast({ + title: '拨号失败,请稍后重试', + icon: 'none', + duration: 2000 + }); + } + } }); }, openAIChat() {