chore:电话按钮可以点击了
This commit is contained in:
@@ -60,11 +60,18 @@ export default {
|
|||||||
this.customerService = createCustomerService(this);
|
this.customerService = createCustomerService(this);
|
||||||
this.buttonConfig = this.customerService.getButtonConfig();
|
this.buttonConfig = this.customerService.getButtonConfig();
|
||||||
|
|
||||||
var that = this;
|
const that = this;
|
||||||
uni.getStorage({
|
uni.getStorage({
|
||||||
key: 'shopInfo',
|
key: 'shopInfo',
|
||||||
success(e) {
|
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([
|
...mapMutations([
|
||||||
'setAiUnreadCount'
|
'setAiUnreadCount'
|
||||||
]),
|
]),
|
||||||
|
/**
|
||||||
|
* 拨打电话逻辑:增加手机号校验和异常处理
|
||||||
|
*/
|
||||||
call() {
|
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({
|
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() {
|
openAIChat() {
|
||||||
|
|||||||
Reference in New Issue
Block a user