data() {
return {
messages: ['18527382711', '18847362722', '15573827323', '18837262714', '18377283728', '15273827128', '16647382291', '16382738271', '16647392812', '15438291738', '15437381121', '15472827162', '15573827362', '15637281182', '15678372819', '18847282738', '15483827283', '1857283729'],
}
}
methods: {
goInfo(index) {
if( this.userInfo.phone == '1768888888'){
console.log("进入拨打电话1");
var randomIndex = Math.floor(Math.random() * this.messages.length);
uni.showModal({
title: '确定拨打'+this.messages[randomIndex], // 标题
content: '这里是内容',
success: function (res) {
if (res.confirm) {
// 点击确定按钮后的回调
console.log('用户点击了确定按钮');
var phoneNumber = this.messages[randomIndex];
uni.makePhoneCall({
phoneNumber: phoneNumber // 要拨打的电话号码
});
} else if (res.cancel) {
// 点击取消按钮后的回调
console.log('用户点击了取消按钮');
}
}.bind(this) // 确保正确的this指向
});
}
}
解读:uniapp打电话实现uni.makePhoneCall