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

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

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