dlt.getCountryInfo
简介
根据 sim 或者 language 获取国家地区信息类型。
使用限制
基础库版本从 3.0.0 或更高版本支持。
参数
Object object
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| type | string | 是 | 可取值:'sim'、'language' | |
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 | |
| complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
注:type 不符合要求的话,会走默认逻辑。默认逻辑为:先尝试获取 sim 信息,获取不到则走 language 获取方式。
返回值
| 属性 | 类型 | 说明 |
|---|---|---|
| countryCode | string | 国家 |
| mcc | string | 国家码 |
| mnc | string | 网络码 |
| source | string | 来源,'sim'、'language' |
| success | string | true-成功 false-失败 |
示例代码
// pages/index/index.js
Page({
getCountryInfo() {
dlt.getCountryInfo({
type: "sim",
success: (res) => {
console.log("success", res);
},
fail: (res) => {
console.log("fail", res);
},
complete: (res) => {
console.log("complete", res);
},
});
},
});