list.js
2.7 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
const util = new window.publicMethod() ;
new Vue({
el: '#app',
data: {
loginInfo: JSON.parse(localStorage.getItem('appLoginInfo') || '{}'),
activeTab: 'tab1',
searchQuery: '',
todoData: [],
completedData: []
},
computed: {
currentData() {
return this.activeTab === 'tab1' ? this.todoData : this.completedData;
},
filteredData() {
if (!this.searchQuery.trim()) {
return this.currentData;
}
let query = this.searchQuery.toLowerCase();
let arr = this.currentData.filter(item =>
item.accNbr.toLowerCase().includes(query)
);
console.log(arr)
return arr;
}
},
methods: {
logout(){
localStorage.removeItem('appLoginInfo');
window.location.replace('login.html');
},
switchTab(tab) {
this.activeTab = tab;
this.searchQuery = ''; // 切换标签时清空搜索
this.queryList()
},
handleItemClick(item) {
sessionStorage.removeItem('huaiAnAppParam')
sessionStorage.setItem('listInfoParam',JSON.stringify(item))
window.location.href = 'index.html'
},
queryList(){
if(this.activeTab==='tab1' && this.todoData.length>0){
return
}
if(this.activeTab==='tab2' && this.completedData.length>0){
return
}
util.httpRequest({
url: '/zj/'+(this.activeTab==='tab1'?'pending':'completed'),
middleUrl: '/zhijian-trial/api',
data: {
campaignId: this.loginInfo.campaignId,
accNbr: this.searchQuery,
},
}).then(res=>{
if(res.code == 200){
if(this.activeTab==='tab1'){
let arr = res.data.records || []
let tArr = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
tArr.forEach(item=>{
arr.push({
accNbr: 'testAccount'+item,
fullAddress: 'test地址'+item,
})
})
this.todoData = arr
}
if(this.activeTab==='tab2'){
this.completedData = res.data.records || []
}
}else{
util.toast(res.msg || '获取失败')
}
})
},
},
mounted() {
this.queryList()
}
});