|
callThis: function(tel, r) {
var _this = this
// 获取 拨打电话 权限
var resultList = api.hasPermission({
list:['phone-call']
});
var granted = resultList[0].granted;
console.log({msg:granted? '有权限' : '无权限'})
var permission = 'phone-call';
var resultList = api.hasPermission({
list: [permission]
});
if (resultList[0].granted) {
// 已授权,可以继续下一步操作
// api.alert({
// msg: '已授权'
// });
if (r == 'SendAddr') {
if (_this.detail.NoSendAddr) {
api.actionSheet({
buttons: ['呼叫发货人']
}, function(ret, err) {
alert(ret)
if (ret) {
if (ret.buttonIndex == 1) {
api.call({
type: 'tel_prompt',
number: tel
});
}
}
});
} else {
api.call({
type: 'tel_prompt',
number: tel
});
}
} else if (r == 'ReciveAddr') {
if (_this.detail.NoReciveAddr) {
api.actionSheet({
buttons: ['呼叫发货人']
}, function(ret, err) {
if (ret) {
if (ret.buttonIndex == 1) {
api.call({
type: 'tel_prompt',
number: tel
});
}
}
});
} else {
api.call({
type: 'tel_prompt',
number: tel
});
}
}
} 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: '已授权'
// });
if (r == 'SendAddr') {
if (_this.detail.NoSendAddr) {
api.actionSheet({
buttons: ['呼叫发货人']
}, function(ret, err) {
alert(ret)
if (ret) {
if (ret.buttonIndex == 1) {
api.call({
type: 'tel_prompt',
number: tel
});
}
}
});
} else {
api.call({
type: 'tel_prompt',
number: tel
});
}
} else if (r == 'ReciveAddr') {
if (_this.detail.NoReciveAddr) {
api.actionSheet({
buttons: ['呼叫发货人']
}, function(ret, err) {
if (ret) {
if (ret.buttonIndex == 1) {
api.call({
type: 'tel_prompt',
number: tel
});
}
}
});
} else {
api.call({
type: 'tel_prompt',
number: tel
});
}
}
}
});
}
});
}
// 授权拨打电话 end
|
|