reg.js
1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* 注册控制器
*/
'use strict';
const passportHelper = require('../models/passport-helper');
const regService = require('../models/reg-service');
let helpers = global.yoho.helpers;
let index = (req, res, next) => {
// 设置注册有效时间30分钟, 防机器刷
req.session._REG_EXPIRE = Date.now() + 1800000;
let refer = req.query.refer;
refer && res.cookie('refer', encodeURI(refer), {
domain: 'yohobuy.com'
});
regService.getRegData().then((result) => {
res.render('reg/index', {
title: '新用户注册',
passport: {
region: passportHelper.getCountry(),
location: '+86',
captchaUrl: helpers.urlFormat('/passport/images', {t: Date.now()}),
itemUrl: helpers.urlFormat('/help/', {category_id: 9}),
referUrl: refer,
loginUrl: helpers.urlFormat('/signin.html', {refer: refer}),
coverHref: result.url,
coverImg: result.img,
regBtnText: '立即注册'
}
});
}).catch(next);
};
module.exports = {
index
};