mui.plusReady(function() {
document.addEventListener("netchange", onNetChange, false);
//获取当前网络类型
function onNetChange() {
var nt = plus.networkinfo.getCurrentType();
switch (nt) {
case plus.networkinfo.CONNECTION_ETHERNET:
case plus.networkinfo.CONNECTION_WIFI:
mui.toast("当前网络为WiFi");
break;
case plus.networkinfo.CONNECTION_CELL2G:
case plus.networkinfo.CONNECTION_CELL3G:
case plus.networkinfo.CONNECTION_CELL4G:
mui.toast("当前网络非WiFi");
break;
default:
mui.toast("当前没有网络");
break;
}
}
});