freqLogSearch.js
3.89 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
const WXRequest = require('../../utils/wxrequest.js');
Page({
data: {
inputVal: '',
searchTypes: [{
label: '申请单号',
value: '4'
},{
label: '车架号',
value: '1'
},{
label: '设备号',
value: '3'
},{
label: '姓名',
value: '2'
}],
placeholders: [
'请输入完整的申请单号',
'请输入车架号后六位',
'请输入设备SN',
'请输入客户姓名'
],
searchTypesIndex: 0,
list: [],
scrollTop: 0,
scrollHeight: 300,
page: 1,
maxPage: 0,
ing: false,
initSearch: false
},
onLoad() {
var that = this;
wx.getSystemInfo({
success: function(res) {
that.setData({
scrollHeight: res.windowHeight-50
})
}
});
that.loadData(true);
},
clearInput: function () {
this.setData({
inputVal: ""
});
},
inputTyping: function (e) {
this.setData({
inputVal: e.detail.value
});
},
searchConfirm(e){
this.setData({
ing: false,
page: 1,
scrollTop: 0
});
this.loadData();
},
loadData(isInit){
var that = this;
if(!isInit && !that.validate()) return;
that.setData({
ing: true
});
let params = {};
if(isInit){
params = {
pageSize: 50,
currentPage: 1
}
that.setData({
page: 5
})
}else{
params = {
queryType: that.data.searchTypes[that.data.searchTypesIndex].value,
params: that.data.inputVal,
pageSize: 10,
currentPage: that.data.page
}
}
WXRequest.get('adjFreq/adjFreqList',params).then((res)=>{
if(!that.data.ing) return;
const _list = res.data;
const maxPage = Math.ceil(res.recordsTotal/10);
if(_list){
_list.forEach((item)=>{
const deviceObj = {}
item.deviceInfo&&item.deviceInfo.forEach((deviceItem)=>{
if(!deviceObj[deviceItem.type]){
deviceObj[deviceItem.type] = [];
}
deviceObj[deviceItem.type].push(deviceItem.sn);
});
item.deviceList = [];
for(let type in deviceObj){
item.deviceList.push({
type,
sns: deviceObj[type]
});
}
});
that.setData({
list: that.data.page===1?_list:that.data.list.concat(_list),
ing: false,
maxPage,
initSearch: true
});
}else{
that.setData({
list: [],
ing: false,
maxPage
});
}
})
},
searchTypeChange(e){
this.setData({
searchTypesIndex: e.detail.value
});
if(!this.data.inputVal) return;
this.setData({
ing: false,
page: 1,
scrollTop: 0
});
this.loadData()
},
bindDownLoad(){
if(this.data.ing) return;
const nextPage = this.data.page+1;
if(nextPage>this.data.maxPage) return;
this.setData({
page: nextPage
});
this.loadData();
},
bindScroll(){
},
validate(){
const type = this.data.searchTypes[this.data.searchTypesIndex].value;
const inputVal = this.data.inputVal;
if(type === '3'){//姓名
if(inputVal.length<2){
wx.showModal({
content: '请输入正确的姓名,至少2位数',
showCancel: false
});
return false;
}
}else if(inputVal.length<6){
wx.showModal({
content: '请输入至少6位数',
showCancel: false
});
return false;
}
return true;
},
redirectDetail(e){
const dataset = e.currentTarget.dataset;
wx.navigateTo({
url: `../../pages/freqLogDetail/freqLogDetail?vehicleid=${dataset.vehicleid}&name=${dataset.name}&standno=${dataset.standno}&deviceinfo=${JSON.stringify(dataset.deviceinfo)}&sqbh=${dataset.sqbh}`
});
}
})