filter.wxs
3.2 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
var filters = {
toFix: function (val, count) {
if(!val){
return parseFloat(0).toFixed(count);
}
val = parseFloat(val);
return val.toFixed(count)
},
replace_time: function (val) {
if (!val) return "不限";
return val.replace("00:00:00", "");
},
replace_time2: function (val) {
if (val == null || val == undefined || val == '') return "";
var a = val.split(" ");
return a[0];
},
format_time: function (ts, isFull) {
// 如果数值位数为1,则补0
function appendZero(obj) {
if (obj < 10) {
return "0" + "" + obj;
} else {
return obj;
}
};
if (ts == null || ts == undefined || ts == '') return "";
var d = getDate(ts * 1000)
var fm = [d.getFullYear(), d.getMonth() + 1, d.getDate()].join('-');
var md = (d.getMonth() + 1) + '月' + d.getDate() + '日';
if (isFull == 1)
fm = fm + ' ' + [appendZero(d.getHours()), appendZero(d.getMinutes()), appendZero(d.getSeconds())].join(':');
if (isFull == 2) {
fm = md + ' ' + [appendZero(d.getHours()), appendZero(d.getMinutes())].join(':');
}
return fm;
},
pInt: function (t) {
var d = parseInt(t);
return d;
},
show_gui_ge: function (spec, color) {
if ((spec == "" || spec == null || spec == "null")) {
if ((color == "" || color == null || color == "null")) {
return "规格1";
} else {
return color;
}
} else {
if ((color == "" || color == null || color == "null")) {
return spec;
} else {
return spec + "/" + color;
}
}
},
// show_default: function (value, placeholder, multiple) {
// if(typeof value === 'number') {
// if(isNaN(value) || value === 0) {
// return placeholder || '0';
// } else {
// if(multiple) {
// return value / multiple;
// } else {
// return value;
// }
// };
// } else if(value === '' || value === undefined || value === null) {
// return placeholder || '-';
// } else {
// return value;
// }
// },
show_default: function (value, placeholder, multiple) {
if(typeof value === 'number') {
if(isNaN(value)) {
return placeholder || '-';
} else if(value === 0) {
return placeholder || '0';
} else {
if(multiple) {
return value / multiple;
} else {
return value;
}
};
} else if(value === '' || value === undefined || value === null) {
return placeholder || '-';
} else {
return value;
}
},
// 根据状态值返回相应的状态文字
// num:状态数值,
// arr: 状态文字数组,
// 文字顺序必须跟状态数值对应
status: function(num, arr) {
// var text = '';
// if(num == 0) {
// text = '未付款';
// } else if(num == 1) {
// text = '已付款';
// } else if(num == 2) {
// text = '等待分成(已收货)';
// } else if(num == 3) {
// text = '已完成';
// };
return arr[num];
},
in_arr: function(index, arr) {
if(arr.indexOf(index) != -1) {
return true;
} else {
return false;
};
},
};
module.exports = {
toFix: filters.toFix,
replace_time: filters.replace_time,
replace_time2: filters.replace_time2,
format_time: filters.format_time,
pInt: filters.pInt,
show_gui_ge: filters.show_gui_ge,
show_default: filters.show_default,
status: filters.status,
in_arr: filters.in_arr,
}