-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1048 lines (929 loc) · 51.6 KB
/
index.html
File metadata and controls
1048 lines (929 loc) · 51.6 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
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
<title>幸福小区</title>
<script src="js/Taildwind-browser@4.js"></script>
<script src="js/lucide.js"></script>
<script src="js/jquery-3.7.1.min.js"></script>
<style>
/* 隐藏滚动条 */
.no-scrollbar::-webkit-scrollbar {
display: none;
}
.no-scrollbar {
-ms-overflow-style: none;
scrollbar-width: none;
}
/* iOS 弹性滚动 */
.ios-scroll {
-webkit-overflow-scrolling: touch;
}
/* 简单的淡入动画 */
.fade-in {
animation: fadeIn 0.3s ease-out;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
/* 隐藏元素通用类 */
.hidden-force {
display: none !important;
}
</style>
</head>
<body class="bg-[#F5F7FA] font-sans text-slate-800 pb-28 select-none overflow-x-hidden min-h-screen">
<div id="view-login" class="page-view absolute inset-0 z-[100] bg-white flex flex-col justify-center px-8 hidden-force">
<div class="mb-12">
<div class="w-16 h-16 bg-[#3B82F6] rounded-2xl flex items-center justify-center text-white mb-6 shadow-lg shadow-blue-200">
<i data-lucide="home" width="32" height="32"></i>
</div>
<h1 class="text-3xl font-bold text-slate-900 mb-2">欢迎回家</h1>
<p class="text-slate-500">登录您的幸福小区账号</p>
</div>
<form id="login-form" class="space-y-6">
<div>
<label class="block text-sm font-medium text-slate-700 mb-2">手机号</label>
<input type="tel" id="login-phone" class="w-full bg-slate-50 border border-slate-200 rounded-xl px-4 py-3.5 outline-none focus:border-[#3B82F6] focus:ring-1 focus:ring-[#3B82F6] transition-all" placeholder="请输入手机号">
</div>
<div>
<label class="block text-sm font-medium text-slate-700 mb-2">密码</label>
<div class="relative">
<input type="password" id="login-password" class="w-full bg-slate-50 border border-slate-200 rounded-xl px-4 py-3.5 pr-12 outline-none focus:border-[#3B82F6] focus:ring-1 focus:ring-[#3B82F6] transition-all" placeholder="请输入密码">
<button type="button" onclick="togglePasswordVisibility()" class="absolute right-4 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600 focus:outline-none p-1">
<i id="eye-icon" data-lucide="eye" width="20" height="20"></i>
</button>
</div>
</div>
<div class="flex items-center justify-between text-sm">
<label class="flex items-center gap-2 text-slate-600">
<input type="checkbox" class="rounded border-slate-300 text-[#3B82F6] focus:ring-[#3B82F6]">
记住我
</label>
<button type="button" onclick="showForgotModal()" class="text-[#3B82F6] font-medium hover:text-blue-600 transition-colors">忘记密码?</button>
</div>
<button type="submit" id="btn-login-submit" class="w-full bg-[#3B82F6] text-white rounded-xl py-4 font-bold text-lg shadow-lg shadow-blue-200 active:scale-[0.98] transition-all flex items-center justify-center gap-2">
<span>登录</span>
<i data-lucide="arrow-right" width="20" height="20"></i>
</button>
</form>
</div>
<div id="view-home" class="page-view fade-in">
<header class="px-6 pt-12 pb-4 flex justify-between items-start">
<div>
<div class="flex items-center gap-2 mb-1">
<h1 class="text-3xl font-bold text-slate-900">幸福小区</h1>
<div id="home-building" class="bg-[#6BBDF5] text-white text-xs font-medium px-2.5 py-1 rounded-full shadow-sm">
加载中...
</div>
</div>
<h2 id="home-greeting" class="text-3xl font-light text-slate-900">您好,业主。</h2>
</div>
<div class="w-12 h-12 rounded-full overflow-hidden border-2 border-white shadow-md">
<img class="user-avatar-img w-full h-full object-cover"
src="img/default_avatar.png"
onerror="this.src='img/default_avatar.png'"
alt="Profile">
</div>
</header>
<section class="mt-4">
<div class="px-6 mb-4">
<h3 class="text-xl font-bold text-slate-900">尽我们所能为您服务</h3>
</div>
<div class="flex overflow-x-auto pb-8 gap-4 snap-x mandatory no-scrollbar ios-scroll">
<div onclick="window.location.href='property_repair.html'" class="ml-6 min-w-[150px] w-[42%] bg-white rounded-[2rem] p-5 flex flex-col justify-between h-56 shadow-[0_4px_20px_rgb(0,0,0,0.03)] snap-start shrink-0 active:scale-95 transition-transform duration-200">
<div class="text-rose-400 mb-4">
<i data-lucide="hammer" width="40" height="40" stroke-width="1.5"></i>
</div>
<div>
<h4 class="text-xl font-bold mb-1 text-rose-400">物业维修</h4>
<p class="text-gray-400 text-xs leading-relaxed">轻松上报需要维修的设施</p>
</div>
</div>
<div onclick="switchTab('life')" class="min-w-[150px] w-[42%] bg-white rounded-[2rem] p-5 flex flex-col justify-between h-56 shadow-[0_4px_20px_rgb(0,0,0,0.03)] snap-start shrink-0 active:scale-95 transition-transform duration-200">
<div class="text-amber-400 mb-4">
<i data-lucide="receipt" width="40" height="40" stroke-width="1.5"></i>
</div>
<div>
<h4 class="text-xl font-bold mb-1 text-amber-400">费用缴纳</h4>
<p class="text-gray-400 text-xs leading-relaxed">轻松缴纳生活费用</p>
</div>
</div>
<div onclick="window.location.href='access_control.html'" class="min-w-[150px] w-[42%] bg-white rounded-[2rem] p-5 flex flex-col justify-between h-56 shadow-[0_4px_20px_rgb(0,0,0,0.03)] snap-start shrink-0 active:scale-95 transition-transform duration-200">
<div class="text-emerald-400 mb-4">
<i data-lucide="lock" width="40" height="40" stroke-width="1.5"></i>
</div>
<div>
<h4 class="text-xl font-bold mb-1 text-emerald-400">门禁管理</h4>
<p class="text-gray-400 text-xs leading-relaxed">轻松远程开门、上锁</p>
</div>
</div>
<div class="w-6 shrink-0"></div>
</div>
</section>
<section class="px-6 mt-2">
<h3 class="text-2xl font-bold text-slate-900 mb-4">公告</h3>
<div id="announcement-list" class="flex flex-col gap-4">
<div class="bg-white rounded-2xl p-4 shadow-sm animate-pulse">
<div class="h-4 bg-gray-200 rounded w-3/4 mb-2"></div>
<div class="h-3 bg-gray-100 rounded w-1/4"></div>
</div>
</div>
</section>
</div>
<div id="view-life" class="page-view hidden fade-in">
<header class="px-6 pt-12 pb-6 flex justify-between items-center">
<h1 class="text-4xl font-bold text-slate-900">生活</h1>
<div class="w-12 h-12 rounded-full overflow-hidden border-2 border-white shadow-md">
<img class="user-avatar-img w-full h-full object-cover"
src="img/default_avatar.png"
onerror="this.src='img/default_avatar.png'"
alt="Profile">
</div>
</header>
<div class="space-y-8 px-6">
<section>
<h3 class="text-xl font-bold text-slate-900 mb-4">费用缴纳</h3>
<div class="bg-white rounded-[2rem] p-6 shadow-[0_4px_20px_rgb(0,0,0,0.03)] relative overflow-hidden h-64 flex flex-col justify-center">
<div class="absolute -right-8 bottom-4 text-amber-50 opacity-60 pointer-events-none">
<i data-lucide="receipt" width="200" height="200" stroke-width="1.5"></i>
</div>
<div class="relative z-10">
<p class="text-slate-900 text-lg mb-2 font-medium">您一共需要缴纳:</p>
<div id="bill-total" class="text-[3.5rem] font-bold text-slate-900 mb-8 font-mono tracking-tight leading-none">
¥0.00
</div>
<div class="flex gap-3">
<button id="btn-pay-trigger" class="bg-[#6BBDF5] active:bg-[#5aa8db] text-white px-8 py-2.5 rounded-full text-sm font-medium shadow-sm transition-colors">去支付</button>
<button onclick="window.location.href='bill_details.html'" class="bg-[#86EFAC] active:bg-[#74dfa0] text-emerald-800 px-8 py-2.5 rounded-full text-sm font-medium shadow-sm transition-colors">查看详细</button>
</div>
</div>
</div>
</section>
<section class="pb-6">
<div class="flex justify-between items-center mb-4">
<h3 class="text-xl font-bold text-slate-900">物业维修</h3>
<button onclick="window.location.href='property_repair.html'" class="text-sm text-[#3B82F6] font-medium flex items-center gap-1 active:opacity-70 transition-opacity">
查看更多 <i data-lucide="chevron-right" width="16" height="16"></i>
</button>
</div>
<div id="repair-list" class="flex flex-col gap-4">
<div class="bg-white rounded-[1.2rem] p-5 shadow-sm animate-pulse h-20"></div>
</div>
</section>
</div>
</div>
<div id="view-community" class="page-view hidden fade-in relative">
<header class="px-6 pt-12 pb-6 flex justify-between items-center">
<h1 class="text-4xl font-bold text-slate-900">社区</h1>
<div class="w-12 h-12 rounded-full overflow-hidden border-2 border-white shadow-md">
<img class="user-avatar-img w-full h-full object-cover"
src="img/default_avatar.png"
onerror="this.src='img/default_avatar.png'"
alt="Profile">
</div>
</header>
<div id="community-list" class="px-6 pb-28 space-y-4">
</div>
<button onclick="window.location.href='community_create.html'" class="fixed bottom-24 right-6 w-14 h-14 bg-[#1e40af] text-white rounded-full flex items-center justify-center shadow-[0_4px_14px_rgba(30,64,175,0.4)] active:scale-90 transition-transform z-40">
<i data-lucide="pencil" width="24" height="24"></i>
</button>
</div>
<div id="view-me" class="page-view hidden fade-in min-h-screen">
<div class="pt-16 px-6 mb-6">
<div class="bg-white rounded-[2rem] p-6 flex items-center gap-5 shadow-sm">
<div class="w-24 h-24 rounded-full overflow-hidden shrink-0 border-4 border-slate-50">
<img class="user-avatar-img w-full h-full object-cover"
src="img/default_avatar.png"
onerror="this.src='img/default_avatar.png'"
alt="User Profile">
</div>
<div>
<h2 id="me-name" class="text-4xl font-bold text-slate-900 mb-2">--</h2>
<p id="me-phone" class="text-slate-600 text-sm mb-1 font-medium tracking-wide">手机号:--</p>
<p id="me-room" class="text-slate-600 text-sm font-medium tracking-wide">房号:--</p>
</div>
</div>
</div>
<div class="px-6 space-y-4">
<button onclick="openEditProfileModal()" class="w-full bg-white rounded-[1.5rem] p-5 flex items-center gap-4 shadow-sm active:scale-[0.98] transition-transform">
<div class="text-slate-800">
<i data-lucide="pencil" width="24" height="24" stroke-width="2"></i>
</div>
<span class="text-lg font-medium text-slate-800">编辑个人资料</span>
</button>
<button onclick="openChangePasswordModal()" class="w-full bg-white rounded-[1.5rem] p-5 flex items-center gap-4 shadow-sm active:scale-[0.98] transition-transform">
<div class="text-slate-800">
<i data-lucide="lock" width="24" height="24" stroke-width="2"></i>
</div>
<span class="text-lg font-medium text-slate-800">修改密码</span>
</button>
</div>
<div class="px-6 mt-16">
<button id="btn-logout" class="w-full bg-[#15549e] text-white rounded-full py-4 text-lg font-bold shadow-lg shadow-blue-900/10 active:scale-[0.98] transition-transform">
退出登录
</button>
</div>
</div>
<div id="bottom-nav" class="fixed bottom-6 left-6 right-6 z-50 hidden-force">
<nav class="bg-white/95 backdrop-blur-md rounded-[2rem] shadow-[0_8px_30px_rgb(0,0,0,0.08)] px-6 py-3 flex justify-between items-center border border-white/50">
<button onclick="switchTab('home')" class="nav-item home-btn relative flex flex-col items-center gap-1 w-12 text-[#3B82F6] -translate-y-1 transition-all duration-300">
<i data-lucide="home" width="24" height="24" stroke-width="2.5"></i>
<span class="text-[10px] font-medium">首页</span>
<span class="indicator absolute -bottom-2 left-1/2 -translate-x-1/2 w-1 h-1 bg-[#3B82F6] rounded-full"></span>
</button>
<button onclick="switchTab('life')" class="nav-item life-btn relative flex flex-col items-center gap-1 w-12 text-gray-400 transition-all duration-300">
<i data-lucide="smile" width="24" height="24" stroke-width="2"></i>
<span class="text-[10px] font-medium">生活</span>
<span class="indicator absolute -bottom-2 left-1/2 -translate-x-1/2 w-1 h-1 bg-[#3B82F6] rounded-full hidden"></span>
</button>
<button onclick="switchTab('community')" class="nav-item community-btn relative flex flex-col items-center gap-1 w-12 text-gray-400 transition-all duration-300">
<i data-lucide="users" width="24" height="24" stroke-width="2"></i>
<span class="text-[10px] font-medium">社区</span>
<span class="indicator absolute -bottom-2 left-1/2 -translate-x-1/2 w-1 h-1 bg-[#3B82F6] rounded-full hidden"></span>
</button>
<button onclick="switchTab('me')" class="nav-item me-btn relative flex flex-col items-center gap-1 w-12 text-gray-400 transition-all duration-300">
<i data-lucide="user" width="24" height="24" stroke-width="2"></i>
<span class="text-[10px] font-medium">我的</span>
<span class="indicator absolute -bottom-2 left-1/2 -translate-x-1/2 w-1 h-1 bg-[#3B82F6] rounded-full hidden"></span>
</button>
</nav>
</div>
<div id="forgot-modal" class="fixed inset-0 bg-black/40 z-[110] hidden flex items-center justify-center fade-in">
<div class="bg-white rounded-[2rem] p-6 w-[85%] max-w-sm shadow-2xl">
<div class="flex flex-col items-center text-center">
<div class="w-12 h-12 bg-blue-50 text-[#3B82F6] rounded-full flex items-center justify-center mb-4">
<i data-lucide="info" width="24" height="24"></i>
</div>
<h3 class="text-xl font-bold text-slate-900 mb-2">温馨提示</h3>
<p class="text-slate-500 text-sm mb-6 leading-relaxed">
为了您的账号安全,如需重置密码,<br>请联系物业中心协助您进行修改。
</p>
<button onclick="hideForgotModal()" class="w-full bg-[#3B82F6] text-white rounded-xl py-3 font-bold text-sm shadow-md shadow-blue-200 active:scale-95 transition-all">
知道了
</button>
</div>
</div>
</div>
<div id="edit-profile-modal" class="fixed inset-0 bg-black/40 z-[110] hidden flex flex-col justify-end fade-in">
<div class="bg-white rounded-t-[2rem] p-6" onclick="event.stopPropagation()">
<div class="flex justify-between items-center mb-6">
<h3 class="text-xl font-bold text-slate-900">编辑资料</h3>
<button onclick="$('#edit-profile-modal').addClass('hidden')" class="text-slate-400 hover:text-slate-600">
<i data-lucide="x" width="24" height="24"></i>
</button>
</div>
<div class="flex flex-col items-center mb-6 relative">
<div class="w-24 h-24 rounded-full overflow-hidden border-4 border-slate-100 relative group cursor-pointer" onclick="$('#avatar-input').click()">
<img id="edit-avatar-preview" src="img/default_avatar.png" class="w-full h-full object-cover">
<div class="absolute inset-0 bg-black/30 hidden group-hover:flex items-center justify-center">
<i data-lucide="camera" class="text-white" width="24" height="24"></i>
</div>
</div>
<p class="text-xs text-slate-400 mt-2">点击更换头像</p>
<input type="file" id="avatar-input" class="hidden" accept="image/*">
</div>
<div class="space-y-4 mb-6">
<div>
<label class="block text-sm font-medium text-slate-700 mb-2">真实姓名</label>
<input type="text" id="edit-real-name" class="w-full bg-slate-50 border border-slate-200 rounded-xl px-4 py-3.5 outline-none focus:border-[#3B82F6] transition-all">
</div>
</div>
<button onclick="submitEditProfile()" class="w-full bg-[#3B82F6] text-white rounded-xl py-4 font-bold text-lg shadow-lg shadow-blue-200 active:scale-[0.98] transition-all">
保存修改
</button>
</div>
</div>
<div id="change-password-modal" class="fixed inset-0 bg-black/40 z-[110] hidden flex flex-col justify-end fade-in">
<div class="bg-white rounded-t-[2rem] p-6" onclick="event.stopPropagation()">
<div class="flex justify-between items-center mb-6">
<h3 class="text-xl font-bold text-slate-900">修改密码</h3>
<button onclick="$('#change-password-modal').addClass('hidden')" class="text-slate-400 hover:text-slate-600">
<i data-lucide="x" width="24" height="24"></i>
</button>
</div>
<div class="space-y-4 mb-6">
<div>
<label class="block text-sm font-medium text-slate-700 mb-2">原密码</label>
<input type="password" id="old-password" class="w-full bg-slate-50 border border-slate-200 rounded-xl px-4 py-3.5 outline-none focus:border-[#3B82F6] transition-all" placeholder="请输入当前密码">
</div>
<div>
<label class="block text-sm font-medium text-slate-700 mb-2">新密码</label>
<input type="password" id="new-password" class="w-full bg-slate-50 border border-slate-200 rounded-xl px-4 py-3.5 outline-none focus:border-[#3B82F6] transition-all" placeholder="请输入新密码">
</div>
<div>
<label class="block text-sm font-medium text-slate-700 mb-2">确认新密码</label>
<input type="password" id="confirm-new-password" class="w-full bg-slate-50 border border-slate-200 rounded-xl px-4 py-3.5 outline-none focus:border-[#3B82F6] transition-all" placeholder="请再次输入新密码">
</div>
</div>
<button id="btn-submit-password" onclick="submitChangePassword()" class="w-full bg-[#3B82F6] text-white rounded-xl py-4 font-bold text-lg shadow-lg shadow-blue-200 active:scale-[0.98] transition-all flex items-center justify-center">
确认修改
</button>
</div>
</div>
<div id="payment-method-modal" class="fixed inset-0 bg-black/40 z-[110] hidden flex flex-col justify-end fade-in" onclick="closePaymentModal()">
<div class="bg-white rounded-t-[2rem] p-6" onclick="event.stopPropagation()">
<div class="flex justify-between items-center mb-6">
<h3 class="text-xl font-bold text-slate-900">选择支付方式</h3>
<button onclick="closePaymentModal()" class="text-slate-400 hover:text-slate-600">
<i data-lucide="x" width="24" height="24"></i>
</button>
</div>
<div class="space-y-4 mb-6">
<div onclick="selectPaymentMethod('alipay')" class="flex items-center justify-between p-4 rounded-xl border border-slate-100 hover:border-blue-200 active:bg-blue-50 cursor-pointer transition-all">
<div class="flex items-center gap-4">
<div class="w-10 h-10 bg-[#1677FF] rounded-full flex items-center justify-center text-white">
<span class="font-bold text-xs">支</span>
</div>
<span class="font-bold text-slate-800">支付宝</span>
</div>
<i data-lucide="chevron-right" class="text-slate-300" width="20" height="20"></i>
</div>
<div onclick="selectPaymentMethod('wxpay')" class="flex items-center justify-between p-4 rounded-xl border border-slate-100 hover:border-green-200 active:bg-green-50 cursor-pointer transition-all">
<div class="flex items-center gap-4">
<div class="w-10 h-10 bg-[#07C160] rounded-full flex items-center justify-center text-white">
<i data-lucide="message-circle" width="20" height="20"></i>
</div>
<span class="font-bold text-slate-800">微信支付</span>
</div>
<i data-lucide="chevron-right" class="text-slate-300" width="20" height="20"></i>
</div>
</div>
</div>
</div>
<div id="payment-confirm-modal" class="fixed inset-0 bg-black/40 z-[120] hidden flex items-center justify-center fade-in">
<div class="bg-white rounded-[2rem] p-6 w-[85%] max-w-sm shadow-2xl">
<h3 class="text-xl font-bold text-slate-900 mb-4 text-center">确认支付</h3>
<p class="text-slate-500 text-sm mb-8 text-center">
您确定要使用 <span id="confirm-method-text" class="font-bold text-slate-800"></span> 现在支付吗?
</p>
<div class="flex gap-4">
<button onclick="$('#payment-confirm-modal').addClass('hidden')" class="flex-1 py-3 rounded-xl bg-slate-100 text-slate-600 font-bold text-sm">
取消
</button>
<button onclick="confirmPayment()" class="flex-1 py-3 rounded-xl bg-[#3B82F6] text-white font-bold text-sm shadow-md shadow-blue-200 active:scale-95 transition-all">
立即支付
</button>
</div>
</div>
</div>
<script>
// === 1. API 配置 ===
const API_BASE = 'https://happy.kudosd.icu/api/v1';
const DEBUG_MODE = false;
// === 2. 5+App 存储封装 ===
const AppStorage = {
setItem: function(key, value) {
if (window.plus) {
plus.storage.setItem(key, String(value));
} else {
localStorage.setItem(key, value);
}
},
getItem: function(key) {
if (window.plus) {
return plus.storage.getItem(key);
} else {
return localStorage.getItem(key);
}
},
removeItem: function(key) {
if (window.plus) {
plus.storage.removeItem(key);
} else {
localStorage.removeItem(key);
}
},
clear: function() {
if (window.plus) {
plus.storage.clear();
} else {
localStorage.clear();
}
}
};
// 辅助函数:生成头像完整URL
function getAvatarUrl(url) {
if (!url) return 'img/default_avatar.png';
if (url.startsWith('http') || url.startsWith('data:')) return url;
// 处理相对路径
const prefix = API_BASE.endsWith('/') ? API_BASE : (API_BASE + '/');
const cleanUrl = url.startsWith('/') ? url.substring(1) : url;
return prefix + cleanUrl;
}
// 统一请求封装 (增强版 Debug:显示完整 JSON 字符串)
const request = async (endpoint, method = 'GET', data = null, optionalToken = null) => {
const token = optionalToken || AppStorage.getItem('token');
// 处理 FormData 或 JSON
let processData = true;
let contentType = 'application/json; charset=UTF-8';
let body = data;
if (data instanceof FormData) {
processData = false;
contentType = false;
body = data;
} else if (data) {
body = JSON.stringify(data);
}
// === Debug 模式:详细打印发送的数据 ===
if (DEBUG_MODE) {
console.group(`📡 [API Request] ${method} ${endpoint}`);
console.log('🔗 URL:', `${API_BASE}${endpoint}`);
console.log('🔑 Headers:', {
'Authorization': `Bearer ${token ? token.substring(0, 10) + '...' : 'None'}`,
'Content-Type': contentType
});
if (data) {
if (data instanceof FormData) {
console.log('📦 Payload (FormData):', data);
console.log('⚠️ FormData 内容无法转换为 JSON 字符串,请查看 Network 标签页的 Payload');
} else {
// 1. 打印对象 (方便交互查看)
console.log('📦 Payload (Object):', data);
// 2. 打印完整 JSON 字符串 (方便复制)
try {
console.log('📝 Payload (Raw JSON):', JSON.stringify(data, null, 2));
} catch(e) {
console.log('❌ JSON Stringify Error:', e);
}
}
}
console.groupEnd();
}
return $.ajax({
url: `${API_BASE}${endpoint}`,
method: method,
processData: processData,
contentType: contentType,
headers: { 'Authorization': `Bearer ${token}` },
data: body
}).then(response => {
// === Debug 模式:详细打印接收的数据 ===
if (DEBUG_MODE) {
console.groupCollapsed(`✅ [API Response] ${method} ${endpoint}`);
// 1. 打印对象
console.log('📥 Response (Object):', response);
// 2. 打印完整 JSON 字符串
try {
console.log('📝 Response (Raw JSON):', JSON.stringify(response, null, 2));
} catch(e) {
console.log('❌ Response Stringify Error:', e);
}
console.groupEnd();
}
return response;
}).catch(err => {
if (DEBUG_MODE) {
console.group(`❌ [API Error] ${method} ${endpoint}`);
console.error('Error Object:', err);
console.error('Status:', err.status, err.statusText);
// 尝试解析错误响应的 JSON
try {
if(err.responseText) {
const errJson = JSON.parse(err.responseText);
console.log('📝 Error Response (Raw JSON):', JSON.stringify(errJson, null, 2));
} else {
console.log('📝 Error Response (Text):', err.responseText);
}
} catch(e) {
console.log('📝 Error Response (Text):', err.responseText);
}
console.groupEnd();
}
console.error(`API请求失败: ${endpoint}`, err);
throw err;
});
};
// === 3. 页面初始化逻辑 ===
let currentBillId = 'all_unpaid';
let selectedPaymentMethod = '';
let currentUserId = null; // 存储当前用户ID
let currentOwnerId = null; // [新增] 存储当前业主ID,用于修改姓名等操作
$(document).ready(function() {
if (window.lucide) lucide.createIcons();
bindEvents();
if (window.plus) {
checkAuthAndInit();
} else {
document.addEventListener('plusready', function(){
console.log("5+App环境就绪: plusready");
checkAuthAndInit();
}, false);
const isApp = navigator.userAgent.indexOf("Html5Plus") > -1;
if (!isApp) {
console.log("非App环境,使用浏览器模式初始化");
checkAuthAndInit();
}
}
});
function checkAuthAndInit() {
const token = AppStorage.getItem('token');
const userInfoStr = AppStorage.getItem('user_info');
if (token && userInfoStr) {
try {
const user = JSON.parse(userInfoStr);
// 保存ID供编辑资料使用
currentUserId = user.id;
if (user.role === 'property' || user.role === 'admin') {
window.location.replace('property_dashboard.html');
return;
}
} catch(e) {
console.error('用户信息解析失败', e);
handleLogout();
return;
}
$('#view-login').addClass('hidden-force');
$('#bottom-nav').removeClass('hidden-force');
// === 根据URL hash跳转指定Tab ===
const hash = window.location.hash.replace('#', '');
const validTabs = ['home', 'life', 'community', 'me'];
const initialTab = validTabs.includes(hash) ? hash : 'home';
switchTab(initialTab);
loadAllData();
} else {
showLoginView();
}
}
function showLoginView() {
$('.page-view').addClass('hidden');
$('#view-login').removeClass('hidden-force hidden');
$('#bottom-nav').addClass('hidden-force');
}
function handleLogout() {
AppStorage.removeItem('token');
AppStorage.removeItem('user_info');
$('#home-building').text('加载中...');
$('#home-greeting').text('您好,业主。');
showLoginView();
}
function loadAllData() {
loadUserInfo().catch(err => {
if (err.status === 401 || err.status === 422 || (err.responseJSON && err.responseJSON.msg === "Subject must be a string")) {
alert("登录状态已失效,请重新登录");
handleLogout();
}
});
loadAnnouncements();
loadBills();
loadRepairs();
loadCommunityPosts();
}
async function loadUserInfo() {
const [userRes, ownerRes] = await Promise.all([request('/auth/me'), request('/owners/me')]);
const user = userRes.data;
const owner = ownerRes.data;
// 更新全局 ID
currentUserId = user.id;
currentOwnerId = owner.id; // [新增] 保存业主ID
$('#home-building').text(`${owner.building || '未录入'}栋`);
const hour = new Date().getHours();
let greeting = '您好';
if (hour < 6) greeting = '深夜好';
else if (hour < 9) greeting = '早上好';
else if (hour < 12) greeting = '上午好';
else if (hour < 14) greeting = '中午好';
else if (hour < 18) greeting = '下午好';
else greeting = '晚上好';
$('#home-greeting').text(`${greeting},${user.real_name || '业主'}。`);
// 使用 getAvatarUrl 处理头像
const avatarUrl = getAvatarUrl(user.avatar_url);
$('.user-avatar-img').attr('src', avatarUrl);
$('#me-name').text(user.real_name);
$('#me-phone').text(`手机号:${user.phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2')}`);
$('#me-room').text(`房号:${owner.unit || '-'}单元${owner.building || '-'}栋${owner.room || '-'}号房`);
}
// === 编辑个人资料功能 ===
window.openEditProfileModal = function() {
// 预填充当前姓名和头像
const currentName = $('#me-name').text();
// 直接从DOM获取已处理过的头像URL
const currentAvatar = $('.user-avatar-img').first().attr('src');
$('#edit-real-name').val(currentName);
$('#edit-avatar-preview').attr('src', currentAvatar);
$('#edit-profile-modal').removeClass('hidden');
if (window.lucide) lucide.createIcons();
}
// 监听头像文件选择
$('#avatar-input').change(function(e) {
const file = e.target.files[0];
if (file) {
// 本地预览
const reader = new FileReader();
reader.onload = function(e) {
$('#edit-avatar-preview').attr('src', e.target.result);
}
reader.readAsDataURL(file);
}
});
window.submitEditProfile = async function() {
const newName = $('#edit-real-name').val();
const file = $('#avatar-input')[0].files[0];
if (!newName) return alert("姓名不能为空");
try {
// 1. 如果有新头像,使用 POST /users/avatar 直接上传 (保持不变)
if (file) {
const formData = new FormData();
formData.append('file', file);
await request('/users/avatar', 'POST', formData);
}
// 2. [修改] 更新真实姓名,改用 PUT /owners/{id}
if (currentOwnerId && newName !== $('#me-name').text()) {
await request(`/owners/${currentOwnerId}`, 'PUT', { real_name: newName });
}
alert("资料修改成功");
$('#edit-profile-modal').addClass('hidden');
loadUserInfo(); // 刷新显示
} catch (e) {
let errorMsg = "修改失败";
if (e.responseJSON && e.responseJSON.message) {
errorMsg = e.responseJSON.message;
}
alert(errorMsg);
}
}
// === 修改密码功能 (已修复) ===
window.openChangePasswordModal = function() {
// 清空所有输入框
$('#old-password').val('');
$('#new-password').val('');
$('#confirm-new-password').val('');
// 重置按钮状态
const $btn = $('#btn-submit-password');
$btn.prop('disabled', false).text('确认修改').removeClass('bg-gray-400').addClass('bg-[#3B82F6]');
$('#change-password-modal').removeClass('hidden');
}
window.submitChangePassword = async function() {
// 增加 trim() 防止用户复制粘贴带空格
const oldPass = $('#old-password').val().trim();
const newPass = $('#new-password').val().trim();
const confirmPass = $('#confirm-new-password').val().trim();
const $btn = $('#btn-submit-password');
// 1. 基础校验
if (!oldPass || !newPass || !confirmPass) {
return alert("请填写完整的密码信息");
}
// 2. 一致性校验
if (newPass !== confirmPass) {
return alert("两次输入的新密码不一致,请重新输入");
}
// 3. 简单长度校验
if (newPass.length < 6) {
return alert("新密码长度不能少于6位");
}
if (oldPass === newPass) {
return alert("新密码不能与原密码相同");
}
// 4. 设置 Loading 状态 (防止重复点击)
$btn.prop('disabled', true).text('修改中...').removeClass('bg-[#3B82F6]').addClass('bg-gray-400');
try {
// 发送请求
await request('/auth/password', 'PUT', {
old_password: oldPass,
new_password: newPass
});
// 成功处理
alert("密码修改成功,请重新登录");
$('#change-password-modal').addClass('hidden');
handleLogout(); // 强制登出
} catch (e) {
// 失败处理
let msg = "修改失败,请稍后重试";
// 优先使用后端返回的具体信息
if (e.responseJSON && e.responseJSON.message) {
msg = e.responseJSON.message;
// 【关键修复】后端返回 500 + "修改密码失败" 通常意味着原密码错误
if (e.status === 500 && msg === "修改密码失败") {
msg = "原密码不正确,请检查后重试";
}
}
else if (e.responseJSON && e.responseJSON.code === 400) {
msg = "原密码错误或新密码格式不符";
}
alert(msg);
// 恢复按钮状态
$btn.prop('disabled', false).text('确认修改').removeClass('bg-gray-400').addClass('bg-[#3B82F6]');
}
}
// === 密码显示/隐藏切换功能 ===
window.togglePasswordVisibility = function() {
const input = document.getElementById('login-password');
const icon = document.getElementById('eye-icon');
if (input.type === 'password') {
input.type = 'text';
icon.setAttribute('data-lucide', 'eye-off');
} else {
input.type = 'password';
icon.setAttribute('data-lucide', 'eye');
}
if (window.lucide) lucide.createIcons();
}
async function loadAnnouncements() {
try {
const res = await request('/announcements?page=1&page_size=5');
const list = res.data.items || res.data.list || [];
const $container = $('#announcement-list');
$container.empty();
list.forEach(item => {
// API 文档示例 priority: 2 (紧急?)
const isUrgent = item.priority > 1;
const badgeColor = isUrgent ? 'bg-[#D94545]' : 'bg-[#3B82F6]';
const badgeText = isUrgent ? '紧急' : '通知';
const html = `
<div onclick="openAnnouncementDetail(${item.id})" class="bg-white rounded-2xl p-4 flex items-center gap-4 shadow-sm active:bg-gray-50 transition-colors cursor-pointer">
<div class="shrink-0 px-3 py-1 rounded-full text-xs font-medium text-white ${badgeColor}">${badgeText}</div>
<div class="flex-1 overflow-hidden">
<h4 class="text-slate-800 text-sm font-medium truncate mb-1">${item.title}</h4>
<p class="text-gray-400 text-xs">${item.created_at.split('T')[0]}</p>
</div>
</div>`;
$container.append(html);
});
} catch (e) { console.error("加载公告失败", JSON.stringify(e)); }
}
async function loadBills() {
try {
const res = await request('/bills?status=unpaid');
const list = res.data.items || res.data.list || [];
let total = 0;
list.forEach(bill => total += parseFloat(bill.amount));
$('#bill-total').text(`¥${total.toFixed(2)}`);
} catch (e) { console.error("加载账单失败", JSON.stringify(e)); }
}
async function loadRepairs() {
try {
const res = await request('/repairs?page=1&page_size=3');
const list = res.data.items || res.data.list || [];
const $container = $('#repair-list');
$container.empty();
if (list.length === 0) {
$container.html('<div class="text-center text-slate-400 text-sm py-4">暂无维修记录</div>');
return;
}
list.forEach(item => {
let statusClass, statusText;
if (item.status === 'completed') {
statusClass = 'bg-[#86EFAC] text-[#14532D]';
statusText = '已处理';
} else if (item.status === 'processing' || item.status === 'assigned') {
statusClass = 'bg-[#FDE047] text-[#854D0E]';
statusText = '处理中';
} else {
statusClass = 'bg-slate-100 text-slate-500';
statusText = '待处理';
}
const html = `
<div onclick="window.location.href='property_repair.html?id=${item.id}'"
class="bg-white rounded-[1.2rem] p-5 flex items-center justify-between shadow-[0_2px_10px_rgb(0,0,0,0.02)] active:scale-[0.98] transition-transform cursor-pointer">
<div><h4 class="text-slate-800 font-medium mb-1">${item.title}</h4><p class="text-gray-400 text-xs">${item.created_at.split('T')[0]}</p></div>
<span class="${statusClass} text-xs font-medium px-4 py-1.5 rounded-full">${statusText}</span>
</div>`;
$container.append(html);
});
} catch (e) { console.error("加载报修失败", JSON.stringify(e)); }
}
async function loadCommunityPosts() {
try {
const res = await request('/community/posts?page=1&page_size=10');
const list = res.data.items || res.data.list || [];
const $container = $('#community-list');
$container.empty();
const typeMap = {
'second_hand': { text: '二手', color: 'bg-[#FCD34D]' },
'rent': { text: '出租', color: 'bg-[#86EFAC]' },
'vote': { text: '投票', color: 'bg-[#F43F5E]' },
'lost_found': { text: '失物认领', color: 'bg-[#8B5CF6]' },
'complaint': { text: '投诉', color: 'bg-[#FF6B6B]' },
'discuss': { text: '讨论', color: 'bg-[#14B8A6]' },
'help': { text: '求助', color: 'bg-[#84CC16]' }
};
list.forEach(item => {
const typeInfo = typeMap[item.type] || { text: '其他', color: 'bg-gray-400' };
const html = `
<div onclick="window.location.href='community_post.html?id=${item.id}'"
class="bg-white rounded-[1.2rem] p-5 flex items-center justify-between shadow-sm active:scale-[0.98] transition-transform cursor-pointer">
<div class="flex-1 pr-2"><h4 class="text-slate-800 font-medium mb-1 text-sm line-clamp-1">${item.title}</h4><p class="text-gray-400 text-xs">${item.created_at.split('T')[0]}</p></div>
<span class="${typeInfo.color} text-white text-xs font-medium px-4 py-1.5 rounded-full shrink-0">${typeInfo.text}</span>
</div>`;
$container.append(html);
});
} catch (e) { console.error("加载社区帖子失败", JSON.stringify(e)); }
}
// === 支付流程逻辑 ===
window.showPaymentMethodModal = function(billId = 'all_unpaid') {
currentBillId = billId;
$('#payment-method-modal').removeClass('hidden');
if (window.lucide) lucide.createIcons();
}
window.closePaymentModal = function() {
$('#payment-method-modal').addClass('hidden');
}
window.selectPaymentMethod = function(method) {
selectedPaymentMethod = method;
$('#payment-method-modal').addClass('hidden');
const methodName = method === 'alipay' ? '支付宝' : '微信支付';
$('#confirm-method-text').text(methodName);
$('#payment-confirm-modal').removeClass('hidden');
}
window.confirmPayment = async function() {
$('#payment-confirm-modal').addClass('hidden');
const endpoint = selectedPaymentMethod === 'alipay' ? '/payment/alipay/create' : '/payment/wxpay/create';
try {
const res = await request(endpoint, 'POST', { bill_id: currentBillId });
if (res.code === 200) {
if (res.data.pay_url) {
if (window.plus) {
plus.runtime.openURL(res.data.pay_url);
} else {
window.location.href = res.data.pay_url;
}
} else if (res.data.code_url) {
alert('请截图扫码支付 (模拟)');
}
} else {
alert(res.message || '创建支付订单失败');
}
} catch (e) {
console.error(e);
alert('支付请求出错: ' + (e.message || '网络错误'));
}
}
// 绑定事件
function bindEvents() {
$('#login-form').submit(async function(e) {
e.preventDefault();
const phone = $('#login-phone').val();
const password = $('#login-password').val();
const $btn = $('#btn-login-submit');
$btn.prop('disabled', true).html('<span>登录中...</span>');
try {
// 1. 尝试登录
const res = await request('/auth/login', 'POST', { phone, password });
if (res.code === 200) {
const tempToken = res.data.token;
// 2. Token 有效性验证
try {
await request('/auth/me', 'GET', null, tempToken);
AppStorage.setItem('token', tempToken);
AppStorage.setItem('user_info', JSON.stringify(res.data.user));
setTimeout(() => {
checkAuthAndInit();
}, 100);
} catch (verifyErr) {
console.error("Token 验证失败:", JSON.stringify(verifyErr));
let errorMsg = "登录异常:服务端下发的 Token 无效";
if (verifyErr.responseJSON && verifyErr.responseJSON.msg) {
errorMsg += ` (${verifyErr.responseJSON.msg})`;
}
alert(errorMsg);
}
} else {
alert(res.message || '登录失败');
}
} catch(e) {
console.error("登录请求异常:", JSON.stringify(e));
let msg = '网络错误,请稍后重试';
if (e.responseJSON && e.responseJSON.message) msg = e.responseJSON.message;