1***@163.com
1***@163.com
  • 发布:2020-06-22 16:10
  • 更新:2020-06-22 16:10
  • 阅读:3530

ReferenceError: plus is not defined (提示: 请在plus ready后再调用plus api)

分类:MUI

mui.plusReady(function () {
//判断是否登录
plus.navigator.setStatusBarBackground("#10afee");
var hadloging = myStorage.getItem("userInfo");
if (hadloging) { //是否登录
plus.navigator.closeSplashscreen(); //关闭启动页
var userinfo = JSON.parse(hadloging);
mui.ajax(baseurl + "user/checkUseTime", {
type: "post",
contentType: "application/json;charset=UTF-8",
data: userinfo.id,
success: function (res) {
if (res.statusCode != 200) return;
if (res.data == "false") {
mui.toast("会员已到期,请重新登录!");
mui.openWindow({
url: "html/login.html",
styles: {
popGesture: "none"
},
show: {
aniShow: 'none'
},
waiting: {
autoShow: false
}
});
}
}
})
} else {
mui.openWindow({ //没有登录则进入登录页
url: "html/login.html",
styles: {
popGesture: "none"
},
show: {
aniShow: 'none'
},
waiting: {
autoShow: false
}
});
};

    // var self = plus.webview.currentWebview();  
    // for(var i = 0; i < subpages.length; i++) { //  
    //  var temp = {};  
    //  var sub = plus.webview.create(subpages[i], subpages[i], subpage_style);  
    //  if(i != 1) sub.hide();  
    //  else {  
    //      temp[subpages[i]] = "true";  
    //      mui.extend(aniShow, temp);  
    //  }  
    //  self.append(sub);  
    // };  

    var self = plus.webview.currentWebview();  
    var temp = {};  
    var sub = plus.webview.create("html/monitormanage.html", "html/monitormanage.html", subpage_style);  
    temp["html/monitormanage.html"] = "true";  
    mui.extend(aniShow, temp);  
    self.append(sub);  
    setTimeout(function () {  
        for (var i = 0; i < subpages.length; i++) { //  
            if (i == 1) continue;  
            var temp = {};  
            var sub = plus.webview.create(subpages[i], subpages[i], subpage_style);  
            sub.hide()  
            temp[subpages[i]] = "true";  
            mui.extend(aniShow, temp);  
            self.append(sub);  
        };  
    }, 100);  

    var menu = plus.webview.create('html/menu.html', 'menu', {  
        top: 0,  
        left: 0,  
        right: 0,  
        bottom: 0,  
        background: 'transparent'  
    })  

    plus.webview.create('html/updateapp.html', 'updateapp', {  
        top: 0,  
        left: 0,  
        right: 0,  
        bottom: 0,  
        background: 'transparent'  
    })  
    // 查询是否有版本更新  
    mui.ajax(baseurl + "appVersion/checkUpdateVersion?appId=" + appid, {  
        type: "post",  
        success: function (res) {  
            var isupdate = document.getElementById("isupdate");  
            if (res.statusCode == 200) {  
                if (res.data) {  
                    var newversion = res.data.androidversion;  
                    var versionurl = res.data.androidurl;  
                    if (newversion != version) {  
                        plus.webview.show('updateapp', "none")  
                        var updateapp = plus.webview.getWebviewById("updateapp");  
                        mui.fire(updateapp, "updateapp", {  
                            newversion: newversion,  
                            versionurl: versionurl  
                        });  
                    }  
                }  
            }  
        }  
    });  
    gettotalalarm();  
    setInterval(function () {  
        gettotalalarm()  
    }, 30000);  
    //设置高度  
    var isfirst = true;  

    function onNetChange() {  
        //获取当前网络类型  
        var nt = plus.networkinfo.getCurrentType();  
        var taskmanage = plus.webview.getWebviewById("html/taskmanage.html");  
        var workmanage = plus.webview.getWebviewById("html/workmanage.html");  
        var monitormanage = plus.webview.getWebviewById("html/monitormanage.html");  
        var alertmana = plus.webview.getWebviewById("html/alertmana.html");  
        switch (nt) {  
            case plus.networkinfo.CONNECTION_ETHERNET:  
            case plus.networkinfo.CONNECTION_WIFI:  
            case plus.networkinfo.CONNECTION_CELL2G:  
            case plus.networkinfo.CONNECTION_CELL3G:  
            case plus.networkinfo.CONNECTION_CELL4G:  
                mui.fire(taskmanage, "networkchange", {  
                    networkconnect: true  
                });  
                mui.fire(workmanage, "networkchange", {  
                    networkconnect: true  
                });  
                mui.fire(monitormanage, "networkchange", {  
                    networkconnect: true  
                });  
                mui.fire(alertmana, "networkchange", {  
                    networkconnect: true  
                });  
                break;  
            default:  
                mui.fire(taskmanage, "networkchange", {  
                    networkconnect: false  
                });  
                mui.fire(workmanage, "networkchange", {  
                    networkconnect: false  
                });  
                mui.fire(monitormanage, "networkchange", {  
                    networkconnect: false  
                });  
                mui.fire(alertmana, "networkchange", {  
                    networkconnect: false  
                });  
                break;  
        }  
    };  

});
2020-06-22 16:10 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复