-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.wxs
160 lines (151 loc) · 5.83 KB
/
app.wxs
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
//商家活动类型
var filterTitle = function(activity) {
console.log('传入的数据', activity);
var str = '';
if (activity.type == 'shopnew') {
str = '门店新客立减' + activity.value + '元 '
console.log('传出的数据', str);
return str;
}
if (activity.type == 'shopyouhui' && activity.youhui) {
for (var i = 0; i < activity.youhui.length; i++) {
if (i !== activity.youhui.length - 1) {
str += "满" + activity.youhui[i].cond_count + "减" + activity.youhui[i].value + ";"
} else {
str += "满" + activity.youhui[i].cond_count + "减" + activity.youhui[i].value
}
}
console.log('传出的数据', str);
return str;
}
if (activity.type == 'platnew') {
str = "平台首单立减" + activity.value + "元"
console.log('传出的pingtaixinke数据', str);
return str;
}
if (activity.type == 'getcoupon') {
for (var i = 0; i < activity.coupons.length; i++) {
if (i !== activity.coupons.length - 1) {
str += activity.coupons[i].value + "元代金券;"
} else {
str += activity.coupons[i].value + "元代金券"
}
}
return str
}
if (activity.type == 'fanxian') {
console.log('activity', activity.level);
for (var i = 0; i < activity.level.length; i++) {
if (i !== activity.level.length - 1) {
str += "满" + activity.level[i].single_amount + "返现" + activity.level[i].value + "元;"
} else {
str += '满' + activity.level[i].single_amount + "返现" + activity.level[i].value + "元"
}
}
return str
}
if (activity.type == 'fanquan') {
for (var i = 0; i < activity.coupons.length; i++) {
if (i !== activity.coupons.length - 1) {
str += "满" + activity.coupons[i].single_amount + "返券" + activity.coupons[i].value + "元;"
} else {
str += '满' + activity.coupons[i].single_amount + "返券" + activity.coupons[i].value + "元"
}
}
return str
}
if (activity.type == 'shopzeng') {
for (var i = 0; i < activity.items.length; i++) {
if (i !== activity.items.length - 1) {
str += "满" + activity.items[i].cond_count + "赠送" + activity.items[i].present + ";"
} else {
str += "满" + activity.items[i].cond_count + "赠送" + activity.items[i].present
}
}
return str
}
if (activity.type == 'zhekou') {
for (var i = 0; i < activity.sales.length; i++) {
if (i !== activity.sales.length - 1) {
str += "本店消费一律" + activity.sales[i].dis_rate + "折;"
} else {
str += "本店消费一律" + activity.sales[i].dis_rate + "折"
}
}
console.log('传出的数据', str);
return str;
}
}
var filterPay = function(activity) {
// console.log('传入的数据',activity);
var str = '';
if (activity.type == 'shopnew') {
str = '门店新客:立减' + activity.value + '元 '
console.log('传出的数据', str);
return str;
} else if (activity.type == 'shopyouhui' && activity.youhui) {
for (var i = 0; i < activity.youhui.length; i++) {
if (i !== activity.youhui.length - 1) {
str += "满" + activity.youhui[i].cond_count + "减" + activity.youhui[i].value + ";"
} else {
str += "满" + activity.youhui[i].cond_count + "减" + activity.youhui[i].value
}
}
str = '商家满减:' + str
console.log('传出的数据', str);
return str;
} else if (activity.type == 'platnew') {
str = "平台新客:立减" + activity.value + "元"
console.log('传出的pingtaixinke数据', str);
return str;
} else if (activity.type == 'getcoupon') {
for (var i = 0; i < activity.coupons.length; i++) {
if (i !== activity.coupons.length - 1) {
str += "满" + activity.coupons[i].cond_count + "减" + activity.coupons[i].value + ";"
}
str += "满" + activity.coupons[i].cond_count + "减" + activity.coupons[i].value
}
str = '优惠券:' + str
return str
}
}
var filterDistance = function(distance) {
if (distance >= 1000) {
distance = (distance / 1000).toFixed(1)
return distance + 'km'
} else {
return distance + 'm'
}
}
var filterTime = function(business_time) {
var str = ''
console.log('计算营业时间');
// for(var i=0;i<arr.length;i++) {
// str += arr[i] + ' '
// console.log('i',arr[i]);
// }
console.log('str', business_time);
return str
}
var formatIntro = function(text) {
if (!text) {
return
}
var reg = getRegExp('\\\\n', 'g')
return text.replace(reg, '\n ')
}
var filterNumber = function(number) {
console.log(number, number.toFixed(1));
return number = number.toFixed(0)
}
var filterDate = function(date) {
return date.split(' ')[0].split('-')[0] + '.' + date.split(' ')[0].split('-')[1] + '.' + date.split(' ')[0].split('-')[2]
}
module.exports = {
filterTitle: filterTitle,
filterPay: filterPay,
filterDistance: filterDistance,
filterNumber: filterNumber,
formatIntro: formatIntro,
filterDate: filterDate
}