currency.js
2.07 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
/**
* [个人中心]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) => {
var uid = req.user.uid;
var page = parseInt(req.query.page, 10) || 1;
var queryType = parseInt(req.query.queryType, 10) || 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), 10);
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
};
}
res.display('index', {
module: 'me',
page: 'currency',
isMe: true,
content: {
nav: mcHandler.getMeCrumb('我的YOHO币'),
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 ? result.list.total : 0
}
});
});
};
module.exports = {
index
};