Skip to content

Commit e4f85ef

Browse files
Merge pull request #47 from full-ownership/feature/router
Feature/router
2 parents f21fedb + 77299bb commit e4f85ef

File tree

4 files changed

+87
-11
lines changed

4 files changed

+87
-11
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VITE_API_BASE_URL=https://back.newjeaps.com
1+
VITE_API_BASE_URL=http://localhost:8080

src/stores/mapCard.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,46 @@ export const useHouseInfoStore = defineStore('houseInfo', {
2626
console.log('데이터를 가져오는데 실패했습니다.', error);
2727
}
2828
},
29+
30+
// 필터링된 데이터를 가져오는 메서드
31+
async fetchFilteredHouseInfo({
32+
buildingUse,
33+
fromPrice,
34+
toPrice,
35+
fromArea,
36+
toArea,
37+
fromConstructYear,
38+
toConstructYear,
39+
// fromFloor,
40+
// toFloor,
41+
}) {
42+
try {
43+
// URL 쿼리 파라미터를 생성
44+
const queryParams = new URLSearchParams({
45+
buildingUse:buildingUse,
46+
fromPrice: fromPrice?.toString() || '0', // 기본값 0
47+
toPrice: toPrice?.toString() || '10000000', // 기본 최대값
48+
fromArea: fromArea?.toString() || '0', // 기본값 0
49+
toArea: toArea?.toString() || '100', // 기본 최대값
50+
fromConstructYear: fromConstructYear?.toString() || '1990', // 기본 최대값
51+
toConstructYear: toConstructYear?.toString() || '2024', // 기본 최대값
52+
// fromFloor: fromFloor?.toString() || '0', // 기본 최대값
53+
// toFloor: toFloor?.toString() || '40', // 기본 최대값
54+
}).toString();
55+
56+
console.log("필터링된 데이터 호출 URL:", `/api/houseinfos/range?${queryParams}`);
57+
58+
// API 요청
59+
const response = await apiClient.get(`/api/houseinfos/range?${queryParams}`);
60+
this.houseInfos = response.data.data; // 데이터를 상태에 저장
61+
console.log("필터링된 데이터:", response.data.data);
62+
} catch (error) {
63+
console.error('필터링된 데이터를 가져오는데 실패했습니다.', error);
64+
}
65+
},
66+
67+
68+
69+
2970
},
3071
});

src/views/MapView.vue

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,9 @@ document.addEventListener("DOMContentLoaded", () => {
216216
217217
const state = reactive({
218218
가격: [0, 10000000], // 초기값
219-
면적: [0, 10000000],
220-
사용승인일: [0, 10000000],
221-
층수: [0, 10000000],
219+
면적: [0,200],
220+
사용승인일: [1990, 2024],
221+
층수: [0, 40],
222222
});
223223
224224
const isSliderVisible = ref(""); // 현재 열려 있는 슬라이더 필터 이름
@@ -228,15 +228,37 @@ const toggleSlider = (filter) => {
228228
// 이미 열려 있는 슬라이더를 클릭하면 닫음
229229
isSliderVisible.value = "";
230230
} else {
231-
// 다른 슬라이더를 클릭하면 현재 슬라이더를 열고, 나머지는 닫음
232231
isSliderVisible.value = filter;
233232
}
234233
};
235234
236-
const applyFilter = () => {
235+
const applyFilter = async() => {
236+
237237
for (const [key, value] of Object.entries(state)) {
238238
console.log(`${key}: ${value[0]} ~ ${value[1]}`);
239239
//console.log(`${value[0]}`)
240+
// 필터링 조건 구성
241+
const filterParams = {// 전달된 param 값
242+
buildingUse,
243+
fromPrice:state["가격"][0], // "가격"의 최소값
244+
toPrice:state["가격"][1],
245+
fromArea:state["면적"][0],
246+
toArea:state["면적"][1], // "가격"의 최대값
247+
fromConstructYear:state['사용승인일'][0],
248+
toConstructYear:state['사용승인일'][1],
249+
fromFloor:state['층수'][0],
250+
toFloor:state['층수'][1],
251+
};
252+
console.log("필터 파라미터:", filterParams);
253+
// Pinia store의 fetchFilteredHouseInfo 호출
254+
try {
255+
isLoading.value = true; // 로딩 시작
256+
await houseInfoStore.fetchFilteredHouseInfo(filterParams); // 비동기 작업
257+
isLoading.value = false; // 로딩 종료
258+
} catch (error) {
259+
console.error("필터 적용 중 에러:", error);
260+
isLoading.value = false; // 로딩 실패 시에도 종료
261+
}
240262
}
241263
};
242264
@@ -344,7 +366,9 @@ const initFilter = () => {
344366
v-model="state[filter]"
345367
style="width: 100%"
346368
exponential
347-
:max="1000000000">
369+
:max="1000000"
370+
371+
>
348372
<template #suffix>만원</template>
349373
</RangeSlider>
350374
<div class="flex flex-row justify-end">

src/views/MyPageView.vue

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup>
22
import { reactive, ref } from 'vue';
3+
import { useUserStore } from '@/stores/userStore'; // Pinia 스토어 import
34
45
// 탭 데이터 설정
56
const tabs = reactive([
@@ -9,35 +10,45 @@ const tabs = reactive([
910
1011
// 활성화된 탭 상태
1112
const activeTab = ref(tabs[0]); // 기본값: 첫 번째 탭
13+
14+
// 컴포넌트가 마운트될 때 사용자 닉네임 가져오기
15+
onMounted(async () => {
16+
await userStore.fetchUserInfo(); // 닉네임 가져오기
17+
console.log(userStore.userInfos.data.nickname);
18+
});
19+
1220
</script>
1321
<template>
1422
<div class="container mx-auto flex flex-col justify-center items-center mt-8 vh-[100vh] pt-12 bg-whites">
1523
<div class="bg-pink-100 h-[10%]">
16-
<h1 class="text-3xl font-Pretendard font-bold py-4 text-center">MY 다방</h1>
24+
25+
<h1 class="text-3xl font-Pretendard font-bold py-4 text-center">MY 다방2</h1>
1726
</div>
1827
<div class="flex flex-col w-[40%] border-4 border-gray-600 py-12 rounded-lg">
1928
<div>
2029
<span>
21-
30+
2231
</span>
2332
</div>
2433
<div class="">
2534
연결된 소셜계정
2635
</div>
2736
<div class="">
2837
닉네임
38+
{{ userStore.userInfos.data.nickname}}
2939
</div>
3040
<div class="">
3141
이름
42+
{{ userStore.userInfos.data.name}}
3243
</div>
3344
<div class="">
3445
이메일
46+
{{ userStore.userInfos.data.email}}
3547
</div>
3648

3749
</div>
3850

39-
40-
51+
4152
</div>
4253
</template>
4354

0 commit comments

Comments
 (0)