提交 036d461c 编写于 作者: 杜庆泉's avatar 杜庆泉

获取电量api 按照uni-error 规范调整

上级 82a4bd66
......@@ -36,23 +36,15 @@
},
testConnnectWifi(){
// uni.connectWifi({
// maunal:false,
// SSID:"Xiaomi_20D0",
// password:"BBBB",
// complete:(res)=>{
// console.log(res);
// }
// });
uni.connectWifi({
maunal:false,
partialInfo:false,
SSID:"Xiaomi_20D0",
password:"streamApp!2016",
password:"BBBB",
complete:(res)=>{
console.log(res);
}
});
},
testGetConnnectWifi(){
uni.getConnectedWifi({
......@@ -190,6 +182,7 @@
testGetBatteryInfo() {
uni.getBatteryInfo({
success(res) {
console.log(res);
uni.showToast({
title: "当前电量:" + res.level + '%',
icon: 'none'
......
......@@ -19,6 +19,8 @@ export default function getBatteryInfo(options: GetBatteryInfoOptions) {
BatteryManager.BATTERY_PROPERTY_CAPACITY
);
const res = {
errSubject: "uni-getBatteryInfo",
errCode: 0,
errMsg: 'getBatteryInfo:ok',
level,
isCharging: manager.isCharging()
......@@ -27,6 +29,8 @@ export default function getBatteryInfo(options: GetBatteryInfoOptions) {
options.complete?.(res)
} else {
const res = {
errSubject: "uni-getBatteryInfo",
errCode: 1001,
errMsg: 'getBatteryInfo:fail getAppContext is null'
}
options.fail?.(res)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册