手机端运行会直接调起电话按钮,代码如下:
https://blog.csdn.net/ONLYSRY/article/details/127221380
<view class="text2_button" @click="freeTell">
<text>4007-000-000</text>
</view>
// 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 < resultObj.granted.length; i++) {
var grantedPermission = resultObj.granted[i];
console.log('已获取的权限:' + grantedPermission);
result = 1
}
for (var i = 0; i < resultObj.deniedPresent.length; i++) {
var deniedPresentPermission = resultObj.deniedPresent[i];
console.log('拒绝本次申请的权限:' + deniedPresentPermission);
result = 0
}
for (var i = 0; i < resultObj.deniedAlways.length; 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);
}
);
标签:function,uniapp,resultObj,console,log,几种,result,var,打电话 From: https://www.cnblogs.com/hongdoudou/p/16842401.html