invite-list.html
15.3 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
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>邀约数据列表</title>
<script src="config.js"></script>
<script src="auth-utils.js"></script>
<style>
*, *::before, *::after { box-sizing: border-box; }
body {
font-family: 'PingFang SC', 'Microsoft YaHei', Arial, sans-serif;
margin: 0;
min-height: 100vh;
background: linear-gradient(135deg, #e8f5e9 0%, #b2dfdb 100%);
padding: 20px;
}
.container {
width: 100%;
max-width: 480px;
margin: 0 auto;
}
.header {
display: flex;
align-items: center;
justify-content: space-between;
}
.back-btn {
background: #fff;
border: none;
border-radius: 12px;
padding: 8px 12px;
color: #388e3c;
font-size: 0.9em;
cursor: pointer;
box-shadow: 0 2px 8px rgba(76, 175, 80, 0.15);
transition: all 0.2s ease;
}
.back-btn:hover {
box-shadow: 0 4px 16px rgba(76, 175, 80, 0.25);
transform: translateY(-1px);
}
h2 {
text-align: center;
color: #388e3c;
margin: 10px 0;
letter-spacing: 2px;
flex: 1;
}
.search-card {
background: #fff;
border-radius: 16px;
box-shadow: 0 4px 16px rgba(76, 175, 80, 0.1);
padding: 20px;
margin-bottom: 20px;
}
.search-input {
width: 100%;
padding: 12px 16px;
border: 1.5px solid #c8e6c9;
border-radius: 12px;
font-size: 1em;
background: #f9fff9;
color: #2e7d32;
transition: all 0.2s ease;
}
.search-input:focus {
outline: none;
border-color: #43a047;
box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
background: #fff;
}
.search-input::placeholder {
color: #6a9c6a;
}
.list-card {
background: #fff;
border-radius: 16px;
box-shadow: 0 4px 16px rgba(76, 175, 80, 0.1);
overflow: hidden;
max-height: 70vh;
}
.list-header {
background: linear-gradient(120deg, #43e97b 0%, #38f9d7 100%);
padding: 16px 20px;
color: #fff;
font-weight: 600;
letter-spacing: 1px;
display: flex;
justify-content: space-between;
align-items: center;
}
.total-count {
font-size: 0.9em;
opacity: 0.9;
}
.list-content {
max-height: calc(70vh - 60px);
overflow-y: auto;
}
.list-item {
padding: 16px 20px;
border-bottom: 1px solid #f0f0f0;
cursor: pointer;
transition: all 0.2s ease;
position: relative;
}
.list-item:hover {
background: #f8fff8;
transform: translateX(4px);
}
.list-item:last-child {
border-bottom: none;
}
.item-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 8px;
}
.customer-name {
font-weight: 600;
color: #2e7d32;
font-size: 1.05em;
}
.invite-time {
font-size: 0.85em;
color: #6a9c6a;
}
.item-details {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
margin-bottom: 8px;
}
.detail-item {
display: flex;
align-items: center;
font-size: 0.9em;
color: #555;
}
.detail-label {
color: #6a9c6a;
margin-right: 6px;
font-size: 0.85em;
}
.item-footer {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 0.85em;
}
.invite-status {
padding: 2px 8px;
border-radius: 12px;
font-size: 0.8em;
font-weight: 500;
}
.invite-status.success {
background: #e8f5e9;
color: #2e7d32;
}
.invite-status.pending {
background: #fff3e0;
color: #ef6c00;
}
.invite-status.failed {
background: #ffebee;
color: #c62828;
}
.loading {
text-align: center;
padding: 40px 20px;
color: #6a9c6a;
font-size: 0.9em;
}
.loading::after {
content: '';
display: inline-block;
width: 20px;
height: 20px;
border: 2px solid #c8e6c9;
border-radius: 50%;
border-top-color: #43a047;
animation: spin 1s linear infinite;
margin-left: 10px;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
.empty-state {
text-align: center;
padding: 60px 20px;
color: #6a9c6a;
}
.empty-icon {
font-size: 3em;
margin-bottom: 16px;
opacity: 0.5;
}
.error-state {
text-align: center;
padding: 40px 20px;
color: #c62828;
}
.retry-btn {
background: #43a047;
color: #fff;
border: none;
border-radius: 8px;
padding: 8px 16px;
margin-top: 12px;
cursor: pointer;
font-size: 0.9em;
transition: all 0.2s ease;
}
.retry-btn:hover {
background: #388e3c;
}
.message-toast {
position: fixed;
top: 20px;
right: 20px;
max-width: 300px;
padding: 16px 20px;
border-radius: 10px;
color: #fff;
font-weight: 500;
z-index: 2000;
transform: translateX(200%);
transition: all 0.3s ease;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}
.message-toast.show {
transform: translateX(0);
}
.message-toast.success {
background: linear-gradient(135deg, #4caf50 0%, #66bb6a 100%);
}
.message-toast.error {
background: linear-gradient(135deg, #f44336 0%, #ef5350 100%);
}
.message-toast.info {
background: linear-gradient(135deg, #2196f3 0%, #42a5f5 100%);
}
@media (max-width: 520px) {
.container { max-width: 100%; }
.list-card { max-height: 65vh; }
.list-content { max-height: calc(65vh - 60px); }
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<button class="back-btn" onclick="goBack()">← 返回</button>
<div></div>
</div>
<h2>邀约数据列表</h2>
<div class="search-card">
<input
type="text"
class="search-input"
id="searchInput"
placeholder="搜索顾客姓名"
autocomplete="off"
>
</div>
<div class="list-card">
<div class="list-header">
<span>邀约记录</span>
<span class="total-count" id="totalCount">共 0 条</span>
</div>
<div class="list-content" id="listContent">
<div class="loading">正在加载数据...</div>
</div>
</div>
</div>
<div id="messageToast" class="message-toast"></div>
<script>
// 全局变量
let currentPage = 1;
let pageSize = 10000;
let totalCount = 0;
let isLoading = false;
let hasMore = true;
let searchKeyword = '';
let searchTimer = null;
let userInfo = {};
// 页面加载完成后初始化
document.addEventListener('DOMContentLoaded', function() {
initializePage();
bindEvents();
});
// 初始化页面
async function initializePage() {
try {
// 检查登录状态
await checkLoginStatus();
// 加载第一页数据
await loadInviteList();
} catch (error) {
console.error('页面初始化失败:', error);
showErrorState('页面初始化失败,请刷新重试');
}
}
// 检查登录状态
async function checkLoginStatus() {
userInfo = JSON.parse(localStorage.getItem('userInfo'));
if (!userInfo || Object.keys(userInfo).length === 0) {
window.location.href = 'login.html';
return;
}
}
// 获取用户信息
async function getUserInfo() {
try {
const apiUrl = `${APP_CONFIG.getApiBaseUrl()}/api/oauth/CurrentUser`;
const response = await fetch(apiUrl, {
method: 'GET',
headers: {
'Authorization': `${getAuthToken()}`,
'Content-Type': 'application/json'
},
});
if (response.ok) {
const result = await response.json();
if (result.code == 200 && result.data) {
return result.data.userInfo;
}
}
return {};
} catch (error) {
console.error('获取用户信息出错:', error);
return {};
}
}
// 绑定事件
function bindEvents() {
// 搜索输入事件
document.getElementById('searchInput').addEventListener('input', function(e) {
searchKeyword = e.target.value.trim();
// 清除之前的定时器
if (searchTimer) {
clearTimeout(searchTimer);
}
// 设置新的定时器,延迟500ms执行搜索
searchTimer = setTimeout(() => {
resetAndSearch();
}, 500);
});
// 滚动加载更多
document.getElementById('listContent').addEventListener('scroll', function(e) {
const { scrollTop, scrollHeight, clientHeight } = e.target;
// 滚动到底部时加载更多
if (scrollTop + clientHeight >= scrollHeight - 50 && !isLoading && hasMore) {
loadMoreData();
}
});
}
// 重置并搜索
async function resetAndSearch() {
currentPage = 1;
hasMore = true;
await loadInviteList();
}
// 加载邀约列表
async function loadInviteList() {
if (isLoading) return;
try {
isLoading = true;
showLoadingState();
const apiUrl = `${APP_CONFIG.getApiBaseUrl()}/api/Extend/LqYaoyjl`;
const params = new URLSearchParams({
page: currentPage,
pageSize: pageSize,
yyr: userInfo.userId
});
// 添加搜索关键字
if (searchKeyword) {
params.append('yykhxm', searchKeyword);
}
const response = await fetch(`${apiUrl}?${params}`, {
method: 'GET',
headers: {
'Authorization': `${getAuthToken()}`,
'Content-Type': 'application/json'
}
});
if (response.ok) {
const result = await response.json();
if (result.code === 200) {
const data = result.data;
totalCount = data.pagination?.total || 0;
const list = data.list || [];
console.log(list)
updateTotalCount();
if (currentPage === 1) {
// 第一页,清空列表
renderList(list);
} else {
// 加载更多,追加到列表
appendToList(list);
}
hasMore = list.length === pageSize;
} else {
throw new Error(result.message || '获取数据失败');
}
} else {
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
}
} catch (error) {
console.error('加载邀约列表失败:', error);
if (currentPage === 1) {
showErrorState('加载数据失败,请重试');
} else {
showMessage('加载更多数据失败', 'error');
}
} finally {
isLoading = false;
}
}
// 加载更多数据
async function loadMoreData() {
if (isLoading || !hasMore) return;
currentPage++;
await loadInviteList();
}
// 渲染列表
function renderList(list) {
const listContent = document.getElementById('listContent');
if (list.length === 0) {
listContent.innerHTML = `
<div class="empty-state">
<div class="empty-icon">📋</div>
<div>暂无邀约数据</div>
${searchKeyword ? `<div style="margin-top: 8px; font-size: 0.9em; opacity: 0.7;">未找到匹配"${searchKeyword}"的记录</div>` : ''}
</div>
`;
return;
}
listContent.innerHTML = list.map(item => createListItem(item)).join('');
}
// 追加到列表
function appendToList(list) {
const listContent = document.getElementById('listContent');
const newItems = list.map(item => createListItem(item)).join('');
listContent.insertAdjacentHTML('beforeend', newItems);
}
// 创建列表项
function createListItem(item) {
const inviteTime = new Date(item.yysj).toLocaleString('zh-CN', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit'
});
// 根据电话是否有效显示状态
let statusClass = 'pending';
let statusText = '待确认';
if (item.dhsfyx === '是') {
statusClass = 'success';
statusText = '电话有效';
} else if (item.dhsfyx === '否') {
statusClass = 'failed';
statusText = '电话无效';
}
// 截取联系记录,避免过长
const contactRecord = item.lxjl || '无联系记录';
const shortRecord = contactRecord.length > 20 ? contactRecord.substring(0, 20) + '...' : contactRecord;
return `
<div class="list-item" onclick="goToDetail('${item.id}')">
<div class="item-header">
<span class="customer-name">${item.yykhxm || '未知客户'}</span>
<span class="invite-time">${inviteTime}</span>
</div>
<div class="item-footer">
<span class="detail-label">联系记录: ${shortRecord}</span>
<span class="invite-status ${statusClass}">${statusText}</span>
</div>
</div>
`;
}
// 更新总数显示
function updateTotalCount() {
document.getElementById('totalCount').textContent = `共 ${totalCount} 条`;
}
// 显示加载状态
function showLoadingState() {
if (currentPage === 1) {
document.getElementById('listContent').innerHTML = '<div class="loading">正在加载数据...</div>';
}
}
// 显示错误状态
function showErrorState(message) {
document.getElementById('listContent').innerHTML = `
<div class="error-state">
<div>${message}</div>
<button class="retry-btn" onclick="retryLoad()">重试</button>
</div>
`;
}
// 重试加载
async function retryLoad() {
currentPage = 1;
hasMore = true;
await loadInviteList();
}
// 跳转到详情页
function goToDetail(id) {
console.log('跳转到邀约详情:', id);
window.location.href = `invite-detail.html?id=${id}`;
}
// 返回上一页
function goBack() {
if (window.history.length > 1) {
window.history.back();
} else {
window.location.href = 'index.html';
}
}
// 显示消息提示
function showMessage(message, type = 'info') {
const toast = document.getElementById('messageToast');
toast.textContent = message;
toast.className = `message-toast ${type}`;
setTimeout(() => {
toast.classList.add('show');
}, 100);
setTimeout(() => {
toast.classList.remove('show');
}, 3000);
}
</script>
</body>
</html>