1.调用api函数封装
function funTelCallPhone(iphone_) {
// opWithPermission('phone')
var systemType = api.systemType
if (systemType == 'ios') {
//获取当前登录人的经纬度
var permission = 'call';
var resultList = api.hasPermission({
list: [permission]
});
if (resultList[0].granted) {
api.call({
type: 'tel_prompt',
number: iphone_
});
} else {
api.confirm({
msg: '应用需要您的授权才能拨打电话',
buttons: ['取消', '去设置']
}, function (ret) {
if (ret.buttonIndex == 2) {
api.requestPermission({
list: [permission],
}, function (res) {
if (res.list[0].granted) {
// 已授权,可以继续下一步操作
api.alert({
msg: '已授权'
});
}
});
}
});
}
} else {
api.call({
type: 'tel_prompt',
number: iphone_
});
}
}
2.打电话函数的使用
function voiceCall(phone, name) {
console.log(phone)
if (phone != 'null') {
api.confirm({
title: '提示',
msg: '是否打电话给' + name + "?",
buttons: ['取消', '拨打电话']
}, function (ret, err) {
console.log(ret)
var index = ret.buttonIndex;
console.log(index)
if (index == 2) {
funTelCallPhone(phone);
}
});
}
}