This commit is contained in:
2026-09-24 16:25:22 +08:00
commit 7428184f01
1198 changed files with 314515 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
## 1.0.32025-07-25
* 兼容原生鸿蒙
## 1.0.22024-08-11
* 拨号,三端可用.
+82
View File
@@ -0,0 +1,82 @@
{
"id": "x-call-phone",
"displayName": "x-call-phone",
"version": "1.0.0",
"description": "x-call-phone",
"keywords": [
"x-call-phone"
],
"repository": "",
"engines": {
"HBuilderX": "^3.6.8"
},
"dcloudext": {
"type": "uts",
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "",
"data": "",
"permissions": ""
},
"npmurl": ""
},
"uni_modules": {
"dependencies": [],
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "u",
"aliyun": "u",
"alipay": "u"
},
"client": {
"Vue": {
"vue2": "u",
"vue3": "u"
},
"App": {
"app-android": "u",
"app-ios": "u"
},
"H5-mobile": {
"Safari": "u",
"Android Browser": "u",
"微信浏览器(Android)": "u",
"QQ浏览器(Android)": "u"
},
"H5-pc": {
"Chrome": "u",
"IE": "u",
"Edge": "u",
"Firefox": "u",
"Safari": "u"
},
"小程序": {
"微信": "u",
"阿里": "u",
"百度": "u",
"字节跳动": "u",
"QQ": "u",
"钉钉": "u",
"快手": "u",
"飞书": "u",
"京东": "u"
},
"快应用": {
"华为": "u",
"联盟": "u"
}
}
}
}
}
+55
View File
@@ -0,0 +1,55 @@
# x-call-phone
### 开发文档
[TMUI4.0文档](https://xui.tmui.design/)
[TMUI4.0组件库](https://ext.dcloud.net.cn/plugin?id=16369)
拨打号码插件,支持跨平台调用系统拨号功能。
### 说明
这是tmui4.0|XUI的原生插件附赠插件,提供了统一的API接口来实现拨打电话功能。
### 兼容性
| Harmony | IOS | Android | WEB | 小程序 |
| --- | --- | --- | --- | --- |
| 支持 | 支持 | 支持 | 支持 | 支持 |
### 使用前准备
#### Android平台
需要在应用中申请电话权限(CALL_PHONE)。插件会自动处理权限申请流程,如果用户拒绝授权,将无法使用拨号功能。
#### iOS平台
无需特殊权限设置。
### 开发环境配置
- 如果是uniapp应用需要自定基座
- uniappx不需要定义基座,但win开发ios时需要
- 如果是mac开发uniappx不需要基座
### API接口
#### makePhone(tel: string)
拨打电话号码
**参数说明:**
- tel: string 类型,要拨打的电话号码
**平台差异说明:**
- Android 10及以上版本:使用ACTION_DIAL实现,直接跳转到拨号界面
- Android 10以下版本:使用ACTION_CALL实现,直接拨打电话
- iOS:统一使用系统拨号功能
**示例代码:**
```ts
import {makePhone} from "@/uni_modules/x-call-phone"
// 拨打电话
makePhone('10086')
```
### 注意事项
1. Android平台需要在应用启动时确保已获取CALL_PHONE权限
2. 不同Android版本的实现方式有所不同,以确保符合系统安全策略
3. 建议在调用接口前先进行平台判断,确保更好的兼容性
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
package="io.dcloud.uni_modules.xCallPhone">
<uses-permission android:name="android.permission.CALL_PHONE" />
</manifest>
@@ -0,0 +1,3 @@
{
"minSdkVersion": "21"
}
@@ -0,0 +1,30 @@
import Intent from 'android.content.Intent';
import Uri from 'android.net.Uri';
import Build from 'android.os.Build';
import Activity from 'android.app.Activity';
export function makePhone(tel : string) {
let phone = "tel:" + tel;
let ac = UTSAndroid.getUniActivity() as Activity
let permissionCheck = ["android.permission.CALL_PHONE"]
let _this = this;
function callphone() {
//10以上
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
let intent = new Intent(Intent.ACTION_DIAL, Uri.parse(phone))
ac.startActivity(intent)
// 10以下.
} else {
let intent = new Intent(Intent.ACTION_CALL, Uri.parse(phone))
ac.startActivity(intent)
}
}
if (UTSAndroid.checkSystemPermissionGranted(UTSAndroid.getUniActivity()!, permissionCheck)) {
callphone()
} else {
console.log("当前不具备指定权限")
UTSAndroid.requestSystemPermission(UTSAndroid.getUniActivity()!, permissionCheck, function (_ : boolean, _ : string[]) {
callphone()
}, function (_ : boolean, _ : string[]) {
})
}
}
@@ -0,0 +1,7 @@
import { call } from '@kit.TelephonyKit';
import { BusinessError } from '@kit.BasicServicesKit';
export function makePhone(tel : string) {
call.makeCall(tel, (err : BusinessError) => {
console.error(err.message)
})
}
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyAccessedAPITypes</key>
<array/>
<key>NSPrivacyCollectedDataTypes</key>
<array/>
<key>NSPrivacyTracking</key>
<false/>
<key>NSPrivacyTrackingDomains</key>
<array/>
</dict>
</plist>
@@ -0,0 +1,3 @@
{
"deploymentTarget": "12"
}
@@ -0,0 +1,12 @@
import { URL } from 'Foundation';
import { UIApplication } from 'UIKit';
export function makePhone(tel : string) {
let phone = new URL(string = `tel://\(${tel})`);
if (UIApplication.shared.canOpenURL(phone!)) {
UIApplication.shared.open(phone!, options= new Map(), completionHandler= nil)
}
}
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>tel</string>
</array>
</dict>
</plist>
@@ -0,0 +1,8 @@
export function makePhone(tel : string) {
wx.makePhoneCall({
phoneNumber:tel,
fail(er) {
console.error(er)
}
})
}
@@ -0,0 +1,12 @@
export function makePhone(tel : string) {
let isCanalinks = document.body.querySelector("#xPhoneAlinks")
if (!isCanalinks) {
let a = document.createElement("a")
a.href = `tel:${tel}`
a.id = "xPhoneAlinks"
document.body.append(a)
isCanalinks = a;
}
isCanalinks.click();
}