176
176
</div >
177
177
</div >
178
178
</div >
179
+
180
+ <!-- 내 뛽기 기록 -->
181
+ <div v-if =" Object.keys(prizeCounts).length > 0" class =" my-prize-history" >
182
+ <h3 >🏆 내 뽑기 기록</h3 >
183
+ <div class =" my-prize-items" >
184
+ <div v-for =" (count, prizeName) in prizeCounts" :key =" prizeName" class =" my-prize-item" >
185
+ <div class =" my-prize-info" >
186
+ <span class =" my-prize-name" >{{ prizeName }}</span >
187
+ <span class =" my-prize-count" >{{ count }}개</span >
188
+ </div >
189
+ <div class =" my-prize-badge" >당첨!</div >
190
+ </div >
191
+ </div >
192
+ <div class =" total-wins" >
193
+ 총 당첨 횟수: <strong >{{ userPrizeHistory.length }}번</strong >
194
+ </div >
195
+ </div >
179
196
</div >
180
197
181
198
<div v-if =" error" class =" error-message" >
@@ -222,14 +239,16 @@ export default {
222
239
showWinPopup: false ,
223
240
winResult: null ,
224
241
isLoggedIn: !! localStorage .getItem (" token" ),
242
+ userPrizeHistory: [], // 사용자 뛽기 기록
243
+ prizeCounts: {}, // 상품별 개수 집계
225
244
};
226
245
},
227
246
mounted () {
228
247
// 상품 목록은 로그인 여부와 관계없이 로드
229
248
this .loadPrizeList ();
230
249
231
250
if (this .isLoggedIn ) {
232
- this .loadUserInfo ();
251
+ this .loadUserInfo (); // 이 안에서 뽑기 기록도 로드됨
233
252
}
234
253
},
235
254
methods: {
@@ -243,6 +262,8 @@ export default {
243
262
const result = await response .json ();
244
263
if (response .status === 200 ) {
245
264
this .userInfo = result .data ;
265
+ // 사용자 정보 로드 후 뽑기 기록 로드
266
+ this .loadUserPrizeHistory ();
246
267
}
247
268
} catch (e) {
248
269
console .error (" 사용자 정보 로드 실패:" , e);
@@ -300,6 +321,10 @@ export default {
300
321
setTimeout (() => {
301
322
this .showWinPopup = true ;
302
323
}, 500 ); // 결과 화면이 잠깐 보인 후 팝업
324
+ // 뛽기 기록 다시 로드
325
+ setTimeout (() => {
326
+ this .loadUserPrizeHistory ();
327
+ }, 1000 );
303
328
}
304
329
// 티켓 개수 업데이트
305
330
this .userInfo .ticketCount -= 1 ;
@@ -330,6 +355,35 @@ export default {
330
355
this .showWinPopup = false ;
331
356
this .winResult = null ;
332
357
},
358
+
359
+ async loadUserPrizeHistory () {
360
+ try {
361
+ const response = await fetch (` ${ API_ROOT } /prizes/user/${ this .userInfo .userId } ` , {
362
+ headers: {
363
+ Authorization: ` Bearer ${ localStorage .getItem (" token" )} ` ,
364
+ },
365
+ });
366
+ const result = await response .json ();
367
+ if (response .status === 200 ) {
368
+ this .userPrizeHistory = result;
369
+ this .calculatePrizeCounts ();
370
+ }
371
+ } catch (e) {
372
+ console .error (" 뛽기 기록 로드 실패:" , e);
373
+ }
374
+ },
375
+
376
+ calculatePrizeCounts () {
377
+ const counts = {};
378
+ this .userPrizeHistory .forEach (record => {
379
+ if (counts[record .prizeName ]) {
380
+ counts[record .prizeName ]++ ;
381
+ } else {
382
+ counts[record .prizeName ] = 1 ;
383
+ }
384
+ });
385
+ this .prizeCounts = counts;
386
+ },
333
387
},
334
388
};
335
389
</script >
@@ -820,6 +874,124 @@ export default {
820
874
}
821
875
}
822
876
877
+ /* 내 뛽기 기록 스타일 */
878
+ .my-prize-history {
879
+ background : rgba (255 , 215 , 0 , 0.08 );
880
+ border : 1px solid rgba (255 , 215 , 0 , 0.25 );
881
+ border-radius : 20px ;
882
+ padding : 25px ;
883
+ backdrop-filter : blur (15px );
884
+ box-shadow : 0 4px 20px rgba (255 , 215 , 0 , 0.1 );
885
+ margin-top : 20px ;
886
+ }
887
+
888
+ .my-prize-history h3 {
889
+ color : #ffd700 ;
890
+ margin : 0 0 20px 0 ;
891
+ text-align : center ;
892
+ font-size : 1.4rem ;
893
+ font-weight : 600 ;
894
+ text-shadow : 0 2px 10px rgba (255 , 215 , 0 , 0.3 );
895
+ }
896
+
897
+ .my-prize-items {
898
+ display : flex ;
899
+ flex-direction : column ;
900
+ gap : 12px ;
901
+ margin-bottom : 20px ;
902
+ }
903
+
904
+ .my-prize-item {
905
+ background : rgba (255 , 215 , 0 , 0.1 );
906
+ border : 1px solid rgba (255 , 215 , 0 , 0.3 );
907
+ border-radius : 12px ;
908
+ padding : 15px ;
909
+ display : flex ;
910
+ justify-content : space-between ;
911
+ align-items : center ;
912
+ transition : all 0.3s ease ;
913
+ position : relative ;
914
+ overflow : hidden ;
915
+ }
916
+
917
+ .my-prize-item ::before {
918
+ content : ' ' ;
919
+ position : absolute ;
920
+ top : 0 ;
921
+ left : -100% ;
922
+ width : 100% ;
923
+ height : 100% ;
924
+ background : linear-gradient (90deg , transparent , rgba (255 , 215 , 0 , 0.2 ), transparent );
925
+ transition : left 0.6s ;
926
+ }
927
+
928
+ .my-prize-item :hover ::before {
929
+ left : 100% ;
930
+ }
931
+
932
+ .my-prize-item :hover {
933
+ transform : translateX (8px );
934
+ border-color : rgba (255 , 215 , 0 , 0.5 );
935
+ background : rgba (255 , 215 , 0 , 0.15 );
936
+ box-shadow : 0 4px 15px rgba (255 , 215 , 0 , 0.2 );
937
+ }
938
+
939
+ .my-prize-info {
940
+ display : flex ;
941
+ justify-content : space-between ;
942
+ align-items : center ;
943
+ flex : 1 ;
944
+ }
945
+
946
+ .my-prize-name {
947
+ color : white ;
948
+ font-weight : 600 ;
949
+ font-size : 1.1rem ;
950
+ }
951
+
952
+ .my-prize-count {
953
+ color : #ffd700 ;
954
+ font-weight : 700 ;
955
+ font-size : 1.2rem ;
956
+ text-shadow : 0 1px 5px rgba (255 , 215 , 0 , 0.3 );
957
+ }
958
+
959
+ .my-prize-badge {
960
+ background : linear-gradient (45deg , #ff6b81 , #ff8a5b );
961
+ color : white ;
962
+ padding : 6px 12px ;
963
+ border-radius : 15px ;
964
+ font-size : 0.9rem ;
965
+ font-weight : 600 ;
966
+ margin-left : 15px ;
967
+ animation : badgeGlow 2s ease-in-out infinite alternate ;
968
+ }
969
+
970
+ @keyframes badgeGlow {
971
+ 0% {
972
+ box-shadow : 0 2px 10px rgba (255 , 107 , 129 , 0.3 );
973
+ }
974
+ 100% {
975
+ box-shadow : 0 4px 20px rgba (255 , 107 , 129 , 0.6 );
976
+ }
977
+ }
978
+
979
+ .total-wins {
980
+ text-align : center ;
981
+ color : #ffd700 ;
982
+ font-size : 1.2rem ;
983
+ padding : 15px ;
984
+ background : rgba (255 , 215 , 0 , 0.1 );
985
+ border-radius : 12px ;
986
+ border : 1px solid rgba (255 , 215 , 0 , 0.2 );
987
+ font-weight : 500 ;
988
+ }
989
+
990
+ .total-wins strong {
991
+ font-size : 1.4rem ;
992
+ text-shadow : 0 2px 10px rgba (255 , 215 , 0 , 0.4 );
993
+ }
994
+
823
995
/* 당첨 팝업 스타일 */
824
996
.win-popup-overlay {
825
997
position : fixed ;
0 commit comments