ejs + ajax



<% include header.ejs %>
<% include footer.ejs %>

var utils = require('../models/utils');
//在index.js中调用这个函数,把这里定义的处理逻辑设置到router里
exports.setRouter = function(router) {
    router.get('/online', function (req, res) { utils.checkPermission(req, res, "menu_online", utils.PERMISSION_TYPE.Readonly, GetOnlineStatus);});
    router.post('/online1', function (req, res) { utils.checkPermission(req, res, "menu_online", utils.PERMISSION_TYPE.Readonly, GetOnlineStatusBy7);});

}

function GetOnlineStatus(req, res, menuKey, localData) {
        res.render('online');
}

function GetOnlineStatusBy7(req, res, menuKey, localData) {
    var regDatas = [];
    utils.query('SELECT * FROM data_onlinecnt order by `timekey` desc limit 2;', function (error, regData) {
        if (error) {
            utils.logError('select data_account list failed', error);
            return ;
        }
        if(regData.length >= 2){
            for(var i in regData){
                if(regData[i].gameappid === 'wx60c5e1f255cb23a0'){
                    regDatas.push({value:regData[i].onlinecntios,name:'WX_IOS'});
                    regDatas.push({value:regData[i].onlinecntandroid,name:'WX_Android'});
                }
                if(regData[i].gameappid === '1105197308'){
                    regDatas.push({value:regData[i].onlinecntios,name:'QQ_IOS'});
                    regDatas.push({value:regData[i].onlinecntandroid,name:'QQ_Android'});
                }
            }
        }
        res.json({
            success : regDatas
        });
    });
}





你可能感兴趣的:(ejs + ajax)