更新记录
1.0.0(2024-11-25) 下载此版本
插件用法
处理定位
import { hmGetLocation, locationToAdress } from "@/uni_modules/jys-openAppProduct";
uni.getLocation = (options) => {
hmGetLocation().then((res) => {
if (!res?.longitude) return options?.fail(err)
locationToAdress({ longitude: res.longitude, latitude: res.latitude }).then((ans) => {
const rs = ans?.[0]
if (!rs) return options?.fail(ans)
options?.success({
...rs, "type": "WGS84", address: {
"country": rs.countryName,
"province": rs.administrativeArea,
"city": rs.subAdministrativeArea,
"district": rs.subLocality,
"street": rs.roadName,
"streetNum": rs.premises,
"poiName": rs.subRoadName,
"cityCode": rs.descriptions?.[0] || ''
}, "errMsg": "getLocation:ok"
})
}).catch((err) => {
options?.fail(err)
});
})
};
沙箱图片地址到相册
import { urlToBase64 } from "@/uni_modules/jys-openAppProduct"
uni.chooseImage({
count: 1,
sizeType: ["compressed"],
sourceType: ["camera"],
success: (res) => {
urlToBase64(res.tempFilePaths[0])
.then((base64Image) => {
})
.catch((err) => {
});
},
});
活体检测
//建议放在minxs文件夹中 默认返回png格式
import { openAppProduct, getDetectionResult } from "@/uni_modules/jys-openAppProduct"
export default {
data() {
return {
it: null,
time:0
}
},
methods: {
_startGetFace(successCallBack, failCallback) {
this.time=new Date().getTime()
this.it = setInterval(() => {
if(this.time+60000<new Date().getTime()){
return clearInterval(this.it);
}
getDetectionResult().then((res) => {
if (res.indexOf("data:image/png;") > -1) {
clearInterval(this.it);
successCallBack?.(res)
}
})
;
}, 2000);
},
_toFace(successCallBack, failCallback) {
clearInterval(this.it);
return openAppProduct().then((res) => {
if (res == '1') {
this._startGetFace(successCallBack, failCallback);
}
});
}
},
beforeUnmount() {
clearInterval(this.it);
},
}
//使用
this._toFace(
(faceFile) => {
that.upload(faceFile)
},
(errorMsg,code) => {
switch (code) {
case -1: //启动活体检测失败
break
case -2: //设备不支持该 API。
break
case -3: //相机权限未授予
break
case -4: //请求权限时出错
break
}
}
)
跳转到App权限设置
import { goAppSetting } from "@/uni_modules/jys-openAppProduct";
goAppSetting()
获取App信息
import { getBundleInfoForSelf } from "@/uni_modules/jys-openAppProduct";
getBundleInfoForSelf().then((res) => {
});
平台兼容性
Vue2 | Vue3 |
---|---|
× | √ |
App | 快应用 | 微信小程序 | 支付宝小程序 | 百度小程序 | 字节小程序 | QQ小程序 |
---|---|---|---|---|---|---|
HBuilderX 4.29,Android:不支持,iOS:不支持,HarmonyNext:支持 | × | × | × | × | × | × |
钉钉小程序 | 快手小程序 | 飞书小程序 | 京东小程序 |
---|---|---|---|
× | × | × | × |
H5-Safari | Android Browser | 微信浏览器(Android) | QQ浏览器(Android) | Chrome | IE | Edge | Firefox | PC-Safari |
---|---|---|---|---|---|---|---|---|
× | × | × | × | × | × | × | × | × |