朱丽叶

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

uniapp app端拨打电话权限

<view class="collect_item image1" @click="callPhone"><text>致电</text></view>
// app端 需要导入 工具方法进行判断是否授权  插件地址 https://ext.dcloud.net.cn/plugin?id=594
import permision from "@/js_sdk/wa-permission/permission.js" 



// 打电话
 callPhone() {
  // #ifdef APP-PLUS
  this.myRequestAndroidPermission('android.permission.CALL_PHONE')
  // #endif
				
  // #ifndef APP-PLUS
   uni.makePhoneCall({
    phoneNumber: this.houseDetailInfo.itemmap.linkphone,
  })
  // #endif
},
async myRequestAndroidPermission(permisionID) {
				var result = await permision.requestAndroidPermission(permisionID)
				var strStatus
				if (result == 1) {
					strStatus = "已获得授权"
					uni.makePhoneCall({
						phoneNumber: this.houseDetailInfo.itemmap.linkphone,
					})
					return;
				} else if (result == 0) {
					strStatus = "未获得授权"
				} else {
					strStatus = "被永久拒绝"
				}
				
				uni.showModal({
					content: "电话权限" + strStatus + ",如果像使用此功能需开启授权是否授权?",
					success: res => {
						if (res.confirm) {
							permision.gotoAppPermissionSetting();
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
},

posted on   朱丽叶  阅读(1463)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
点击右上角即可分享
微信分享提示