login-new.js 2.65 KB
const _ = require('lodash');
const co = Promise.coroutine;
const RegService = require('../models/reg-service');
const LoginNewModel = require('../models/login-new');

class Login {
    /**
     * 登录页面
     */
    loginPage(req, res, next) {
        // 是否关闭账号登录
        let closePassword = _.get(req.app.locals.wap, 'close.passwordLogin', false);

        if (closePassword) {
            return res.redirect(`/signin.html?refer=${req.query.refer || ''}`);
        }
        if (req.session.captchaValidCount == null) { // eslint-disable-line
            req.session.captchaValidCount = 5;
        }

        co(function* () {
            let bannerData = yield req.ctx(LoginNewModel).getTopBanner();
            let banner = _.get(bannerData, 'result.data[0].data.list[0]', '');

            res.render('login/login-new', {
                module: 'passport',
                page: 'login-new',
                localCss: true,
                width750: true,
                banner: banner,
                captchaShow: req.yoho.captchaShow,
                backUrl: 'javascript:history.go(-1)', // eslint-disable-line
                smsLoginUrl: '/passport/sms_login',
                registerUrl: '/passport/reg/index', // 注册的URL链接
                aliLoginUrl: '/passport/login/alipay', // 支付宝快捷登录的URL链接
                weiboLoginUrl: '/passport/login/sina', // 微博登录的URL链接
                qqLoginUrl: '/passport/login/qq', // 腾讯QQ登录的URL链接
                wechatLoginUrl: '/passport/login/wechat', // 微信登录的URL链接
                internationalUrl: '/passport/international-new', // 国际号登录的URL链接
                phoneRetriveUrl: '/passport/back/mobile', // 通过手机号找回密码的URL链接
                emailRetriveUrl: '/passport/back/email', // 通过邮箱找回密码的URL链接
            });
        })().catch(next);
    }

    /**
     * 国际账号登录
     */
    international(req, res) {
        // 是否关闭账号登录
        let closePassword = _.get(req.app.locals.wap, 'close.passwordLogin', false);

        if (closePassword) {
            return res.redirect(`/signin.html?refer=${req.query.refer || ''}`);
        }
        if (req.session.captchaValidCount == null) { // eslint-disable-line
            req.session.captchaValidCount = 5;
        }

        res.render('login/international-new', {
            module: 'passport',
            page: 'international-new',
            localCss: true,
            width750: true,
            captchaShow: req.yoho.captchaShow,
            countrys: RegService.getAreaData()
        });
    }
}

module.exports = Login;