mine-handler.js
2.14 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
import moment from 'moment';
export function parseAssetList(json) {
let {
data,
page,
pagetotal,
summary
} = json;
let parsedList = data ? data.map((item) => {
let price = '';
if (item.amount !== null) {
if (item.incomeOutcome === 2) {
if (item.amount > 0) {
price = '-' + Number(Math.abs(item.amount)).toFixed(2);
} else {
price = '+' + Number(Math.abs(item.amount)).toFixed(2);
}
} else {
if (item.amount > 0) {
price += '+' + Number(Math.abs(item.amount)).toFixed(2);
} else {
price += '-' + Number(Math.abs(item.amount)).toFixed(2);
}
}
}
return {
title: item.tradeTypeDesc + '(订单号:' + item.orderCode + ')',
price: price,
tradeTypeDesc: item.tradeTypeDesc,
type: item.tradeType,
productName: item.productName,
sizeName: item.sizeName,
time: moment(new Date(item.createTime * 1000)).format('YYYY.MM.DD HH:mm'),
normalFlag: item.normalFlag,
};
}) : [];
summary = summary ? summary : {};
let endReached = parsedList.length === 0 || page === pagetotal;
return {
currentPage: page,
list: parsedList,
endReached,
compensateIncome: summary.compensateIncome,
goodsIncome: summary.goodsIncome,
totalIncome: summary.totalIncome,
};
}
export function formatNumber(number) {
return parseFloat(number) < 0 ? '-¥' + Math.abs(parseFloat(number)).toFixed(2) : '¥' + Math.abs(parseFloat(number)).toFixed(2);
}
export function maskAccount(string) {
if (/^1[3|4|5|7|8][0-9]{9}$/.test(string)) {
return string.substring(0, 3) + '****' + string.substring(7);
} else if (/^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/.test(string.toLowerCase())) {
if (string.indexOf('@') > 3) {
return string.substring(0, 3) + '****' + string.substring(string.lastIndexOf('@'));
} else {
return '****' + string.substring(string.lastIndexOf('@'));
}
} else if (string.length > 2) {
return string.substring(0, 1) + '****' + string.substring(string.length - 1);
}
return string.substring(0, 1) + '****';
}