第一步
<view class="" @tap="call('手机号')">
打电话
</view>
call(phone) {
console.log('传入的电话',phone);
//uni.makePhoneCall({
// phoneNumber:phone,
// success(){
// console.log('拨打成功了');
// },
// fail() {
// console.log('拨打失败了');
// }
// })
const res = uni.getSystemInfoSync();
// ios系统默认有个模态框
if(res.platform=='ios'){
uni.makePhoneCall({
phoneNumber:phone,
success(){
console.log('拨打成功了');
},
fail() {
console.log('拨打失败了');
}
})
}else{
//安卓手机手动设置一个showActionSheet
uni.showActionSheet({
itemList: [phone,'呼叫'],
success:function(res){
console.log(res);
if(res.tapIndex==1){
uni.makePhoneCall({
phoneNumber: phone,
})
}
}
})
}
}
第二步