作者:保定联通员工 | 来源:互联网 | 2023-09-13 09:31
手机端运行会直接调起电话按钮,代码如下:
https://blog.csdn.net/ONLYSRY/article/details/127221380
4007-000-000
// js部分-联系电话
freeTell() {
wx.makePhoneCall({
phoneNumber: '4007-000-000', //仅为示例,并非真实的电话号码
success: function() {
console.log("拨打电话成功!")
},
fail: function() {
console.log("拨打电话失败!")
}
})
},
uni-APP 拨打电话uni.makePhoneCall 遇到的坑
plus.android.requestPermissions(
["android.permission.CALL_PHONE"],
function(resultObj) {
var result = 0;
for (var i = 0; i var grantedPermission = resultObj.granted[i];
console.log('已获取的权限:' + grantedPermission);
result = 1
}
for (var i = 0; i var deniedPresentPermission = resultObj.deniedPresent[i];
console.log('拒绝本次申请的权限:' + deniedPresentPermission);
result = 0
}
for (var i = 0; i var deniedAlwaysPermission = resultObj.deniedAlways[i];
console.log('永久拒绝申请的权限:' + deniedAlwaysPermission);
result = -1
}
console.log(result);
if(result == 1){
uni.makePhoneCall({
phoneNumber: "10086",//电话号码
success(ress) {
console.log("拨打电话成功",ress)
},
fail(err) {
console.log("拨打电话失败",'err')
}
});
}else{
uni.showToast({
title:"请开启拨号权限",
icon:"error",
})
}
},
function(error) {
console.log('申请权限错误:' + error.code + " = " + error.message);
}
);