uniapp:点击手机号拨打电话

<view class="ui-msg_th" @click="dialPhone(item.phonenumber)">
	  {
   
   {item.phonenumber || ''}}
</view>
dialPhone(phonenumber){
	console.log('手机号',phonenumber)
	const res = uni.getSystemInfoSync();
	// ios系统默认有个模态框
	if(res.platform=='ios'){
		uni.makePhoneCall({
			phoneNumber:phonenumber,
			success(){
				console.log('拨打成功了');
			},
			fail() {
				console.log('拨打失败了');
			}
		})
	}else{
		//安卓手机手动设置一个showActionSheet
		uni.showActionSheet({
			itemList: [phonenumber,'呼叫'],
			success:function(res){
			    console.log(res);
			   if(res.tapIndex==1){
				   console.log(res.tapIndex,789)
				   uni.makePhoneCall({
				  	  phoneNumber: phonenumber,
				   })
			    }
			}
		})
	}
}

在manifest.json文件中,打开权限:

猜你喜欢

转载自blog.csdn.net/Ygaidi/article/details/128180402