Skip to content

Commit f6da4ce

Browse files
Merge pull request #44 from full-ownership/feature/router
Feature/router
2 parents 9482a85 + ec127b3 commit f6da4ce

File tree

4 files changed

+121
-87
lines changed

4 files changed

+121
-87
lines changed

src/router/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const routes = [
2626
component: LoginView,
2727
},
2828
{
29-
path: 'map',
29+
path: 'map/:param', // :param은 동적 라우트 파라미터
3030
name: 'map',
3131
component: MapView,
3232
},

src/views/HeaderView.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<img alt="logo" src="@/assets/img/logo.png" class="w-24 -mr-1" @click="goToHome" />
66
</div>
77
<nav class="md:ml-auto flex flex-wrap items-center text-base justify-center">
8-
<a @click="goToMapView" href="" class="mr-5 hover:text-gray-900">지도</a>
8+
<a @click="goToMapView('아파트')" href="" class="mr-5 hover:text-gray-900">지도</a>
99
<a @click="goToIntroductionView" class="mr-5 hover:text-gray-900">회사소개</a>
1010
<div>
1111
<div v-if="userStore.userInfos.data.nickname">
@@ -39,22 +39,22 @@ const goToHome = () => {
3939
router.push({ name: 'home' });
4040
};
4141
42-
4342
const goToLogin = () => {
4443
console.log('Login button clicked');
4544
router.push({ name: 'login' });
4645
};
4746
48-
const goToMapView = () => {
49-
router.push({name: 'map'});
47+
const goToMapView = (param) => {
48+
//console.log('mapView 등장')
49+
console.log(param)
50+
router.push({ name: 'map', params: {param} } );
5051
}
5152
5253
const goToIntroductionView = () =>{
5354
router.push({name: 'introduction'})
5455
}
5556
5657
const goToMyPage = () => {
57-
console.log("마이페이지로 가자")
5858
router.push({name: 'mypage'})
5959
}
6060

src/views/HomeView.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ const router = useRouter();
1414
const goToNotice = () => {
1515
router.push({ name: "notice" });
1616
};
17+
18+
const goToMapView = (param) => {
19+
//console.log('mapView 등장')
20+
console.log(param)
21+
router.push({ name: 'map', params: {param} } );
22+
}
23+
1724
</script>
1825

1926
<template>
@@ -56,7 +63,7 @@ const goToNotice = () => {
5663
<div class="flex flex-col justify-around w-full">
5764
<div class="grid grid-cols-9 gap-3 w-full">
5865
<!-- 아파트 카드 -->
59-
<div class="card bg-white h-40 col-span-3 row-span-2 rounded-lg p-6 cursor-pointer">
66+
<div class="card bg-white h-40 col-span-3 row-span-2 rounded-lg p-6 cursor-pointer" @click="goToMapView('아파트')">
6067
<div class="font-PretendardSemiBold text-xl mb-2">아파트</div>
6168
<p class="font-PretendardRegular text-xs text-gray-700 mb-1">아파트 아파트 ~! 아파트는 hold on 아시죠?</p>
6269
<p class="font-PretendardRegular text-xs text-gray-700">풍부한 단지정보 및 실시간 랭킹까지-</p>
@@ -66,7 +73,7 @@ const goToNotice = () => {
6673
</div>
6774

6875
<!-- 연립 다세대 카드 -->
69-
<div class="card bg-white h-40 col-span-2 row-span-2 rounded-lg p-6 cursor-pointer">
76+
<div class="card bg-white h-40 col-span-2 row-span-2 rounded-lg p-6 cursor-pointer" @click="goToMapView('연립다세대')">
7077
<div class="font-PretendardSemiBold text-xl mb-1">연립 다세대</div>
7178
<p class="font-PretendardRegular text-xs text-gray-700 mb-1">오피스텔 정보</p>
7279
<p class="font-PretendardRegular text-xs text-gray-700 mb-1">오피스텔 정보 여기 다!</p>
@@ -78,7 +85,7 @@ const goToNotice = () => {
7885
<div class="card bg-white h-50 col-span-4 row-span-3 rounded-lg p-8"></div>
7986

8087
<!-- 단독/다가구 카드 -->
81-
<div class="card bg-white h-40 col-span-2 row-span-2 rounded-lg p-8 cursor-pointer">
88+
<div class="card bg-white h-40 col-span-2 row-span-2 rounded-lg p-8 cursor-pointer" @click="goToMapView('단독다가구')">
8289
<div class="font-PretendardSemiBold text-xl mb-2">단독/다가구</div>
8390
<p class="font-PretendardRegular text-xs text-gray-700 mb-1">오피스텔 정보</p>
8491
<p class="font-PretendardRegular text-xs text-gray-700 mb-1">오피스텔 정보 여기 다!</p>
@@ -88,7 +95,7 @@ const goToNotice = () => {
8895
</div>
8996

9097
<!-- 오피스텔 카드 -->
91-
<div class="card bg-white h-40 col-span-3 row-span-2 rounded-lg p-8 cursor-pointer">
98+
<div class="card bg-white h-40 col-span-3 row-span-2 rounded-lg p-8 cursor-pointer" @click="goToMapView('오피스텔')">
9299
<div class="font-PretendardSemiBold text-xl mb-2">오피스텔</div>
93100
<p class="font-PretendardRegular text-xs text-gray-700 mb-1">오피스텔 정보</p>
94101
<p class="font-PretendardRegular text-xs text-gray-700 mb-1">오피스텔 정보 여기 다!</p>

src/views/MapView.vue

Lines changed: 104 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import Button from "@/Component/Button/Button.vue";
88
import "vue-range-slider/dist/vue-range-slider.css";
99
import RangeSlider from "vue-simple-range-slider";
1010
import "vue-simple-range-slider/css";
11+
import { useRoute } from 'vue-router';
12+
1113
1214
const map = ref(null); // Kakao Map 객체
1315
const polygons = ref([]); // 생성된 폴리곤 객체 배열
@@ -170,9 +172,18 @@ const fetchData = async (type) => {
170172
171173
};
172174
175+
const route = useRoute();
176+
// params로 전달된 "param" 값
177+
178+
179+
// 문자열로 변환된 buildingUse
180+
const buildingUse = route.params.param;
181+
182+
console.log('전달된 파라미터:', buildingUse); // 디버깅용
183+
173184
onMounted(async () => {
174185
isLoading.value = false;
175-
await fetchData("아파트"); // 데이터 로드
186+
await fetchData(buildingUse); // 데이터 로드
176187
isLoading.value = true;
177188
});
178189
@@ -184,18 +195,17 @@ watch(
184195
{ immediate: true } // 즉시 실행
185196
);
186197
187-
188198
// store에서 houseInfos 가져오기
189199
const houseInfos = computed(() => houseInfoStore.houseInfos);
190200
191201
// DOMContentLoaded 이벤트는 HTML 문서의 모든 콘텐츠가 완전히 로드되었을 때 발생함
192202
document.addEventListener("DOMContentLoaded", () => {
203+
193204
const filterButton = document.getElementById("filterButton");
194205
const rangeSlider = document.getElementById("rangeSlider");
195206
196207
// 이제 filterButton이 존재하므로 이벤트 리스너를 안전하게 추가할 수 있습니다.
197208
filterButton.addEventListener("click", () => {
198-
console.log("클릭");
199209
if (rangeSlider.classList.contains("hidden")) {
200210
rangeSlider.classList.remove("hidden");
201211
} else {
@@ -204,14 +214,42 @@ document.addEventListener("DOMContentLoaded", () => {
204214
});
205215
});
206216
207-
// 슬라이더 값을 반응형으로 관리
208217
const state = reactive({
209-
value: [10, 100],
210-
value2: [10, 100]
218+
가격: [0, 10000000], // 초기값
219+
면적: [0, 10000000],
220+
사용승인일: [0, 10000000],
221+
층수: [0, 10000000],
211222
});
212223
213-
</script>
224+
const isSliderVisible = ref(""); // 현재 열려 있는 슬라이더 필터 이름
225+
226+
const toggleSlider = (filter) => {
227+
if (isSliderVisible.value === filter) {
228+
// 이미 열려 있는 슬라이더를 클릭하면 닫음
229+
isSliderVisible.value = "";
230+
} else {
231+
// 다른 슬라이더를 클릭하면 현재 슬라이더를 열고, 나머지는 닫음
232+
isSliderVisible.value = filter;
233+
}
234+
};
214235
236+
const applyFilter = () => {
237+
for (const [key, value] of Object.entries(state)) {
238+
console.log(`${key}: ${value[0]} ~ ${value[1]}`);
239+
//console.log(`${value[0]}`)
240+
}
241+
};
242+
243+
const initFilter = () => {
244+
for (const [key, value] of Object.entries(state)) {
245+
value[0] = 0;
246+
value[1] = 10000000;
247+
console.log(`${key}: ${value[0]} ~ ${value[1]}`);
248+
//console.log(`${value[0]}`)
249+
}
250+
}
251+
252+
</script>
215253

216254
<template>
217255
<div class="flex flex-row items-center w-full h-[100vh] pt-20">
@@ -251,63 +289,77 @@ const state = reactive({
251289

252290
<!-- 지도 및 필터 영역 -->
253291
<div class="flex flex-col justify-start w-full h-full">
254-
255292
<!-- 필터 전체 버튼 -->
256293
<div class="flex flex-row items-center py-4 h-14 border-b border-gray-200">
257-
258294
<!--검색 창-->
259295
<div class="relative w-[370px] ml-4 mr-2">
260296
<input
261297
type="text"
262298
placeholder="찾고자하는 아파트 이름을 입력하세요"
263-
class="w-full h-8 px-4 pr-10 text-sm text-gray-700 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"
264-
/>
299+
class="w-full h-8 px-4 pr-10 text-sm text-gray-700 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500"/>
300+
<button
301+
type="button"
302+
class="absolute inset-y-0 right-0 flex items-center px-3 text-gray-500 hover:text-gray-700">
303+
<svg
304+
class="w-4 h-4"
305+
aria-hidden="true"
306+
xmlns="http://www.w3.org/2000/svg"
307+
fill="none"
308+
viewBox="0 0 20 20">
309+
<path
310+
stroke="currentColor"
311+
stroke-linecap="round"
312+
stroke-linejoin="round"
313+
stroke-width="2"
314+
d="M19 19l-4-4m0-7A7 7 0 1 1 1 8a7 7 0 0 1 14 0Z"/>
315+
</svg>
316+
</button>
317+
</div>
318+
319+
<div v-for="(filter, index) in filters" :key="index" class="relative inline-block text-left ml-2">
320+
<!-- 버튼 -->
265321
<button
266322
type="button"
267-
class="absolute inset-y-0 right-0 flex items-center px-3 text-gray-500 hover:text-gray-700">
268-
<svg
269-
class="w-4 h-4"
270-
aria-hidden="true"
271-
xmlns="http://www.w3.org/2000/svg"
272-
fill="none"
273-
viewBox="0 0 20 20">
274-
<path
275-
stroke="currentColor"
276-
stroke-linecap="round"
277-
stroke-linejoin="round"
278-
stroke-width="2"
279-
d="M19 19l-4-4m0-7A7 7 0 1 1 1 8a7 7 0 0 1 14 0Z"/>
280-
</svg>
323+
@click="toggleSlider(filter)"
324+
class="flex flex-row items-center w-full h-8 border border-gray-300 shadow-sm pl-2 text-xs font-medium text-gray-700 hover:bg-gray-50 focus:outline-none">
325+
<div>{{ filter }}</div>
326+
<svg
327+
class="h-4 w-6 text-gray-800"
328+
xmlns="http://www.w3.org/2000/svg"
329+
viewBox="0 0 20 20"
330+
fill="currentColor"
331+
aria-hidden="true">
332+
<path
333+
fill-rule="evenodd"
334+
d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 011.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
335+
clip-rule="evenodd"
336+
/>
337+
</svg>
281338
</button>
282-
</div>
283-
284-
<div v-for="(filter, index) in filters" :key="index" class="relative inline-block text-left ml-2">
285-
<!-- 버튼 -->
286-
<button id="filterButton" type="button"
287-
class=" flex flex-row items-center w-full h-8 border border-gray-300 shadow-sm pl-2 text-xs font-medium text-gray-700 hover:bg-gray-50 focus:outline-none">
288-
<div> {{ filter }} </div>
289-
<svg class="h-4 w-6 text-gray-800" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
290-
<path fill-rule="evenodd" d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 011.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" clip-rule="evenodd" />
291-
</svg>
339+
<!-- 슬라이더 -->
340+
<div
341+
v-if="isSliderVisible === filter"
342+
class="absolute z-10 w-[220px] top-10 left-0 border-2 border-gray-200 bg-white" >
343+
<RangeSlider
344+
v-model="state[filter]"
345+
style="width: 100%"
346+
exponential
347+
:max="1000000000">
348+
<template #suffix>만원</template>
349+
</RangeSlider>
350+
<div class="flex flex-row justify-end">
351+
<button class="bg-blue-600 rounded-lg mb-2 mx-2 p-2 text-white text-xs" @click=applyFilter >
352+
적용
292353
</button>
293-
<!-- 아이콘 -->
294-
<div
295-
class="bg-white absolute z-10 w-[200px] h-[120px] top-10 left-0 border-2 border-gray-200"
296-
v-if="isSliderVisible">
297-
<RangeSlider
298-
v-model="state.value"
299-
style="width: 100%"
300-
exponential
301-
:max="1000000000">
302-
<template #suffix>만원</template>
303-
</RangeSlider>
304-
<span>{{ state.value[0] }} 만원</span> -
305-
<span>{{ state.value[1] }} 만원</span>
306-
</div>
354+
</div>
355+
<!-- <div class="flex flex-row justify-between bg-blue-400 px-4">
356+
<span class="">{{ state[filter][0] }}만원</span>
357+
<span class="">{{ state[filter][1] }}만원</span>
358+
</div> -->
307359
</div>
308-
360+
</div>
309361
<button type="button" class="relative inline-block text-left ml-2 h-8 px-2 py-2 bg-white border border-gray-300 shadow-sm focus:ring-indigo-500">
310-
<svg class="h-4 w-4" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24">
362+
<svg class="h-4 w-4" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24" @click="initFilter">
311363
<path d="M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8z"/>
312364
</svg>
313365
</button>
@@ -325,30 +377,7 @@ const state = reactive({
325377
<!-- 목록 영역 추가할 수 있습니다 -->
326378
<div class="p-2 overflow-auto">
327379
<div class="text-center mt-2">
328-
<!-- <span>최소: {{ state.value[0] }} 만원</span> -
329-
<span>최대: {{ state.value[1] }} 만원</span>
330-
331-
<span>최소: {{ state.value2[0] }} 만원</span> -
332-
<span>최대: {{ state.value2[1] }} 만원</span> -->
333-
<!-- <RangeSlider
334-
v-model="state.value"
335-
style="width: 100%"
336-
exponential
337-
:max="1000000000"
338-
>
339-
<template #suffix>만원</template>
340-
</RangeSlider> -->
341-
342-
<RangeSlider
343-
v-model="state.value2"
344-
style="width: 100%"
345-
exponential
346-
:max="1000000000"
347-
>
348-
<template #suffix>만원</template>
349-
</RangeSlider>
350-
</div>
351-
380+
</div>
352381
<div v-for="house in houseInfos" :key="house.id">
353382
<CardView
354383
:id="house.id"
@@ -379,8 +408,6 @@ const state = reactive({
379408
</div>
380409
</template>
381410

382-
383-
384411
<style>
385412
.polygon-label {
386413
background: white;

0 commit comments

Comments
 (0)