From 2fef9eb5603cea996452bb23075ebaf98751481b Mon Sep 17 00:00:00 2001 From: liudan <18634735655@163.com> Date: Sun, 3 Mar 2024 22:31:50 +0800 Subject: [PATCH] 1 --- manifest.json | 5 ++- pages/news/user/vip.vue | 83 +++++++++++++++++++++++++---------------- 2 files changed, 55 insertions(+), 33 deletions(-) diff --git a/manifest.json b/manifest.json index 40e8601..a915bb8 100644 --- a/manifest.json +++ b/manifest.json @@ -115,7 +115,10 @@ "permission" : { "scope.userLocation" : { "desc" : "获取当前所在城市位置" - } + }, + "makePhoneCall": { + "desc": "用于拨打电话" + } }, "optimization" : { "subPackages" : true diff --git a/pages/news/user/vip.vue b/pages/news/user/vip.vue index 4cc2412..f9e4718 100644 --- a/pages/news/user/vip.vue +++ b/pages/news/user/vip.vue @@ -110,39 +110,58 @@ }); }, makeCall(phoneNumber) { - uni.getSetting({ - success(res) { - if (!res.authSetting['scope.phoneCall']) { - // 没有权限,需要请求用户授权 - uni.authorize({ - scope: 'scope.phoneCall', - success() { - // 用户已授权,可以拨打电话 - uni.makePhoneCall({ - phoneNumber: phoneNumber // 电话号码 - }); - }, - fail() { - // 用户拒绝授权,可以引导用户开启 - uni.showModal({ - title: '提示', - content: '需要电话权限', - success: function(modalRes) { - if (modalRes.confirm) { - uni.openSetting(); - } - } - }); - } - }); - } else { - // 已经有权限,直接拨打电话 - uni.makePhoneCall({ - phoneNumber: phoneNumber // 电话号码 - }); - } - } + uni.makePhoneCall({ + phoneNumber: phoneNumber, // 电话号码 + success: (res) => { + }, + // 失败回调 + fail: (res) => { + } }); + // uni.getSetting({ + // success(res) { + // if (!res.authSetting['scope.makePhoneCall']) { + // // 没有权限,需要请求用户授权 + // uni.authorize({ + // scope: 'scope.makePhoneCall', + // success() { + // // 用户已授权,可以拨打电话 + // uni.makePhoneCall({ + // phoneNumber: phoneNumber // 电话号码 + // }); + // }, + // fail() { + // // 用户拒绝授权,可以引导用户开启 + // uni.showModal({ + // title: '提示', + // content: '需要电话权限', + // success: function(modalRes) { + // console.log(modalRes) + // if (modalRes.confirm) { + // uni.openSetting({ + // success: (res) => { + // console.log(res) + // if (res.authSetting['scope.makePhoneCall']) { + // uni.makePhoneCall({ + // phoneNumber: phoneNumber // 电话号码 + // }); + // } + // } + + // }); + // } + // } + // }); + // } + // }); + // } else { + // // 已经有权限,直接拨打电话 + // uni.makePhoneCall({ + // phoneNumber: phoneNumber // 电话号码 + // }); + // } + // } + // }); }, goVipDetails(item){ let details = JSON.stringify(item)