index.js
7.9 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
let app = getApp();
// import {
// mobile_list
// } from '/const/index';
// import {
// areas
// } from '/const/area-new';
Page({
data: {
queryForm: {
query: "",
},
formVisible: false,
succVisible: false,
shortCutVisible: false,
tagIndex: 0,
tagList: [{
name: "推荐",
val: "",
},
{
name: "AAA+",
val: "AAA+",
},
{
name: "AABB+",
val: "AABB+",
},
{
name: "ABAB+",
val: "ABAB+",
},
{
name: "ABBA",
val: "ABBA",
},
{
name: "ABCAB",
val: "ABCAB",
},
{
name: "ABCD",
val: "ABCD",
},
{
name: "尾号6/8/9",
val: "LAST689",
fontSize: 26
},
],
page: 1,
size: 10,
totalPages: 0,
// 总号码池
numberPool: [],
// 命中池
targetNumberList: [],
// 号码列表,当前展示号码
numberList: [],
// 当前选择号码
curNumberItem: null,
},
onLoad(query) {
this.initData();
// let area = {};
// let province_list = {};
// let city_list = {};
// let county_list = {};
// areas.forEach(element => {
// province_list[element[0]] = element[1]
// city_list[element[2]] = element[3]
// county_list[element[4]] = element[5]
// });
// area.province_list = province_list;
// area.city_list = city_list;
// area.county_list = county_list;
// console.log(area);
},
async initData() {
let numberPool = await this.getSelectNumberList();
app.func.sortByLength(numberPool)
this.data.targetNumberList = numberPool;
this.data.page = 1;
this.refreshPage();
// let beautyResAAA = app.func.checkBeautyNumberAAA('15014443959');
// console.log("beautyResAAA:", beautyResAAA);
// let beautyResAABB = app.func.checkBeautyNumberAABB('15011337986');
// console.log("beautyResAABB:", beautyResAABB);
// let beautyResABAB = app.func.checkBeautyNumberABAB('15056563959');
// console.log("beautyResABAB:", beautyResABAB);
// let beautyResABBA = app.func.checkBeautyNumberABBA('15056653959');
// console.log("beautyResABBA:", beautyResABBA);
// let beautyResABCAB = app.func.checkBeautyNumberABCAB('15056756959');
// console.log("beautyResABCAB:", beautyResABCAB);
// let beautyResABCD = app.func.checkBeautyNumberABCD('15054323959');
// console.log("beautyResABCD:", beautyResABCD);
// let beautyResLast = app.func.checkBeautyNumberLast('15054323959');
// console.log("beautyResLast:", beautyResLast);
},
// 页面滚动
onPageScroll(e) {
let shortCutVisible = e.scrollTop > 700;
this.setData({
shortCutVisible
});
},
toTop() {
console.log("toTop");
my.pageScrollTo({
scrollTop: 0,
duration: 300
})
},
async onSearch() {
let numberPool = await this.getSelectNumberList();
this.setData({
tagIndex: 0
})
// numberPool = app.util.shuffleArray(numberPool);
this.data.targetNumberList = numberPool;
this.data.page = 1;
this.refreshPage();
},
onSearchConfirm() {
this.onSearch();
},
/**
* 获取
*/
async getSelectNumberList() {
let res = await app.get({
url: app.api.selectNum,
data: this.data.queryForm,
loading: true,
});
// console.log(res);
let funcList = [
app.func.checkBeautyNumberAAA,
app.func.checkBeautyNumberAABB,
app.func.checkBeautyNumberABAB,
app.func.checkBeautyNumberABBA,
app.func.checkBeautyNumberABCAB,
app.func.checkBeautyNumberABCD,
app.func.checkBeautyNumberLast,
]
res.forEach(element => {
element.beautyList = []
element.beautyObj = {}
funcList.forEach(funElement => {
let beautyRes = funElement(element.mobile);
if (beautyRes.beautyNum) {
element.beautyList.push(beautyRes);
element.beautyObj[beautyRes.type] = beautyRes;
}
});
});
let numberPool = res.concat(this.data.numberPool);
numberPool = app.util.uniqueArray(numberPool);
this.data.numberPool = numberPool;
return numberPool;
},
// 点击标签
onTagItem(evt) {
let item = app.tapData(evt);
let index = app.tapData(evt, "index");
this.setData({
queryForm: {
query: "",
},
tagIndex: index,
})
let numberPool = this.data.numberPool;
numberPool = app.util.shuffleArray(numberPool);
if (item.val) {
let targetNumberList = []
numberPool.forEach(element => {
if (element.beautyObj[item.val]) {
targetNumberList.push(element);
}
});
targetNumberList = targetNumberList.concat(numberPool);
targetNumberList = app.util.uniqueArray(targetNumberList);
this.data.targetNumberList = targetNumberList;
} else {
// app.func.sortByLength(numberPool)
this.data.targetNumberList = numberPool;
}
this.data.page = 1;
this.refreshPage();
},
/**
* 点击号码
*/
onNumberItem(evt) {
let item = app.tapData(evt);
item.featureName = app.func.getFeatureName(item.mobile)
this.setData({
curNumberItem: item,
formVisible: true,
})
},
// 上一页
onPagePrev() {
this.data.page--;
if (this.data.page < 1) {
this.data.page = this.data.totalPages;
// return;
};
this.refreshPage();
},
// 下一页
onPageNext() {
this.data.page++;
if (this.data.page > this.data.totalPages) {
this.data.page = 1;
// return;
}
this.refreshPage();
},
refreshPage() {
let listObj = app.util.paginateArray(this.data.targetNumberList, this.data.page, this.data.pageSize);
let curTag = this.data.tagList[this.data.tagIndex];
let curTagVal = curTag.val;
let list = listObj.list;
let query = this.data.queryForm.query;
/**
* 高亮数字
*
* 1、如果query中有值,按query的值
* 2、如果标签有值,按标签
* 3、如果都没有,随机显示靓号
*/
list.forEach(element => {
let beautyObj = null;
if (query) {
beautyObj = {
beautyNum: query,
index: element.mobile.indexOf(query),
len: query.length,
type: "query",
}
} else if (element.beautyObj[curTagVal]) {
beautyObj = element.beautyObj[curTagVal];
} else {
// 默认靓号提示
let len = element.beautyList.length;
if (len) {
beautyObj = element.beautyList[Math.floor(Math.random() * len)] || null
}
}
let numberDisplayList = []
element.mobile.split("").forEach((ele, index) => {
let numberObj = {
number: ele,
highlight: beautyObj && index >= beautyObj.index && index <= beautyObj.index + beautyObj.len - 1,
}
numberDisplayList.push(numberObj);
});
element.numberDisplayList = numberDisplayList;
});
this.setData({
numberList: list,
totalPages: listObj.totalPages,
})
},
/**
* input绑定
* 多输入文本绑定
* 在input/texarea中设置 data-name="属性值即可"
*/
inputEdit(e) {
let dataset = e.currentTarget.dataset;
let value = e.detail.value;
let name = dataset.name;
this.setData({
[name]: value
});
},
evtcomp(evt) {
console.log("evtcomp evt:", evt)
let {
name,
data
} = evt;
// console.log("name:", name)
switch (name) {
case "_evt_hide":
this.hideMask();
break;
case "_evt_submit_complete":
this.setData({
formVisible: false,
succVisible: true,
})
break;
}
},
// 关闭蒙层
onHideMask() {
this.setData({
formVisible: false,
succVisible: false,
})
},
onShareAppMessage() {
// 返回自定义分享信息
return {
title: '',
desc: '',
path: '',
};
},
});