currency.page.js
1.58 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
69
70
/**
* [个人中心]YOHO币
* @author: jiangmin
* @date: 2016/07/11
*/
const moment = require('moment');
// 时间格式化
const convertUnitTime = (src) => {
return moment.unix(src).format('YYYY-MM-DD');
};
var beginTime = convertUnitTime(new Date() / 1000 - 3600 * 24 * 90);
var type = 0;
var page = 1;
var Bll = {
// 获取路由中的请求参数
getQueryString: function() {
var queryArr = location.search.substr(1).split('&');
var query = {};
queryArr.forEach(function(pair) {
var arr = pair.split('=');
query[arr[0]] = arr[1];
});
return query;
},
typeMap: {
all: 0,
paying: 1,
delivering: 2
},
getDataList: function(type1, page1, beginTime1) {
var query = ['page=' + page1, 'queryType=' + type1, 'beginTime=' + beginTime1];
location.search = query.join('&');
}
};
require('./me');
// tab切换
$('.tabs li').on('click', function() {
var $this = $(this);
type = Bll.typeMap[$this.data('type')];
page = 1;
beginTime = Bll.getQueryString().beginTime || beginTime;
if (!$this.hasClass('active')) {
$('.tabs li.active').removeClass('active');
$this.addClass('active');
Bll.getDataList(type, page, beginTime);
}
});
// 时间控件切换
$('#begin-time').on('change', function() {
var months = parseInt($(this).val(), 10);
type = Bll.getQueryString().queryType || 1;
page = 1;
beginTime = convertUnitTime(new Date() / 1000 - 3600 * 24 * 30 * months);
Bll.getDataList(type, page, beginTime);
});