currency.js
2.18 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/**
* [个人中心]yoho币
* @author: jiangmin
* @date: 2016/07/11
*/
'use strict';
const mcHandler = require('../models/menu-crumb-handler');
const currencyModel = require('../models/currency');
const moment = require('moment');
const convertUnitTime = (src) => {
return moment.unix(src).format('YYYY-MM-DD');
};
/**
* yoho币页面加载
*/
const index = (req, res) => {
let uid = req.user.uid || '8041246';
var page = parseInt(req.query.page) || 1;
var queryType = parseInt(req.query.queryType) || 0;
var beginTime = req.query.beginTime || convertUnitTime(new Date() / 1000 - 3600 * 24 * 90);
var date1 = new Date().getTime() / 1000;
var date2 = new Date(beginTime).getTime() / 1000;
var selectIndex = parseInt((date1 - date2) / (3600 * 24 * 30 * 6));
console.log('请求参数:', 'page:' + page, 'queryType:' + queryType, 'beginTime:' + beginTime);
currencyModel.getIndexData(uid, page, queryType, beginTime).then(result=> {
result.list.tabs[queryType].isActive = true;
result.list.coinList.forEach(function(x) {
x.date = x.date.replace(/\-/g, '.');
});
result.list.selects[selectIndex].isSelected = 'selected';
if (result.list.paginationOpts) {
result.list.paginationOpts.queryParams = {
queryType: queryType,
beginTime: beginTime
};
}
console.log('返回个数:' + result.list.total);
res.render('index', {
module: 'me',
page: 'currency',
isMe: true,
content: {
nav: mcHandler.getMeCrumb(),
navigation: mcHandler.getSideMenu('YOHO币'),
banner: 'http://placehold.it/150x120',
currency: true,
tabs: result.list.tabs,
title: '我的YOHO币',
currentYear: new Date().getFullYear(),
data: result.list.coinList,
paginationOpts: result.list.paginationOpts,
num: result.num.data,
selects: result.list.selects,
total: result.list.total
}
});
});
};
module.exports = {
index
};