// 拨打电话
callPhone(){
let phone = this.menber.phone; // 需要拨打的电话号码
// console.log('拨打电话', phone)
const res = uni.getSystemInfoSync();
// ios系统默认有个模态框
if (res.platform == 'ios') {
uni.makePhoneCall({
phoneNumber: phone,
success() {
console.log('ios拨打成功');
},
fail() {
console.log('ios拨打失败');
}
})
} else {
//安卓手机手动设置一个showActionSheet
uni.showActionSheet({
itemList: [phone, '呼叫'],
success: function(res) {
if (res.tapIndex == 1) {
uni.makePhoneCall({
phoneNumber: phone,
success() {
console.log('安卓拨打成功');
},
fail() {
console.log('安卓拨打失败');
}
})
}
}
})
}
},
记录:uniapp写微信小程序如何实现一键拨打电话
最新推荐文章于 2024-05-25 15:29:30 发布