File tree 4 files changed +27
-47
lines changed
4 files changed +27
-47
lines changed Original file line number Diff line number Diff line change
1
+ BASE_URL = http://localhost:8080/api
Original file line number Diff line number Diff line change 1
1
import { defineStore } from 'pinia' ;
2
2
import axios from 'axios' ;
3
+ const BASE_URL = import . meta. env . VITE_API_BASE_URL ;
3
4
4
5
export const useHouseInfoStore = defineStore ( 'houseInfo' , {
5
6
state : ( ) => ( {
6
- houseInfos : { data : [ ] } , // 초기 상태 설정
7
+ houseInfos : { data : [ ] } ,
7
8
} ) ,
8
9
actions : {
9
10
async fetchHouseInfo ( type ) {
10
11
try {
12
+
11
13
const response = await axios . get ( `http://localhost:8080/api/houseinfos/${ type } ` ) ;
12
14
13
- // 응답이 정상적으로 왔는지 확인
14
- if ( response . data && Array . isArray ( response . data ) && response . data . length > 0 ) {
15
- this . houseInfos = response . data ;
16
- //console.log(this.houseInfos.data[0].buildingUse); // 데이터가 존재할 때만 접근
17
-
18
- const valueArray = this . houseInfos . data . map ( item => item . value ) ;
19
- console . log ( valueArray ) ;
20
- } else {
21
- console . error ( '빈 데이터 또는 잘못된 데이터 구조:' , response . data ) ;
22
- }
15
+ this . houseInfos . data = response . data . data ;
16
+
17
+ //아파트 출력
23
18
} catch ( error ) {
24
19
console . log ( '데이터를 가져오는데 실패했습니다.' , error ) ;
25
20
}
Original file line number Diff line number Diff line change 9
9
<div class =" ml-2" >
10
10
<span class =" inline-flex mb-1 items-center text-xxs w-auto text-gray-600 border-2 border-gray-200 bg-white rounded-lg px-2 text-center" >
11
11
{{ buildingUse }}</span >
12
- <h5 class =" text-lg font-bold text-gray-800 pl-1" >아파트 이름 </h5 >
12
+ <h5 class =" text-lg font-bold text-gray-800 pl-1" >{{ buildingName }} </h5 >
13
13
<div class =" pl-1" >
14
14
<span class =" text-sm text-gray-600" >
15
15
{{ districtName }}</span >
21
21
<span class =" text-sm" >{{ minPropertyPrice }}</span >
22
22
<span class =" text-md" >만원</span >
23
23
<span class =" text-md" > - </span >
24
- <span class =" text-md" >최대 </span >
24
+ <span class =" text-md" >최대</span >
25
25
<span class =" text-sm" >{{ maxPropertyPrice }}</span >
26
26
<span class =" text-md" >만원</span >
27
27
</div >
28
+
28
29
<!-- 버튼 -->
29
30
</div >
30
31
</div >
33
34
34
35
<script setup>
35
36
36
- // export default {
37
- // props: {
38
- // image: {
39
- // type: String,
40
- // required: true,
41
- // },
42
- // title: {
43
- // type: String,
44
- // required: true,
45
- // },
46
- // description: {
47
- // type: String,
48
- // required: true,
49
- // },
50
- // buttonText: {
51
- // type: String,
52
- // default: "Click Me",
53
- // },
54
- // },
55
- // methods: {
56
- // onButtonClick() {
57
- // this.$emit("button-click");
58
- // },
59
- // },
60
- // };
61
-
62
37
defineProps ({
63
38
id: Number , // int → Number
64
39
buildingUse: String ,
Original file line number Diff line number Diff line change 60
60
<FilterButton ></FilterButton >
61
61
</div >
62
62
<!-- 목록 영역 추가할 수 있습니다 -->
63
- <div class =" p-2" >
63
+ <div class =" p-2 overflow-y-auto " >
64
64
65
- <div v-if =" houseInfosLoaded" >
65
+ <!-- < div v-if="houseInfosLoaded"> -- >
66
66
<div v-for =" (house, index) in houseInfos.data" :key =" index" >
67
- <p >{{ house.name }}</p >
68
- <p >{{ house.price }}</p >
67
+
68
+ <CardView
69
+ :id =" house.id"
70
+ :buildingUse =" house.buildingUse"
71
+ :buildingName =" house.buildingName"
72
+ :districtName =" house.districtName"
73
+ :legalName =" house.legalName"
74
+ :minPropertyPrice =" house.minPropertyPrice"
75
+ :maxPropertyPrice =" house.maxPropertyPrice"
76
+ />
77
+
69
78
</div >
70
- </div >
79
+ <!-- < /div> -- >
71
80
72
81
<!-- 데이터가 로딩 중일 때 표시할 로딩 화면 -->
73
- <div v-else >
74
- <p >로딩 중...</p >
75
- </div >
82
+
76
83
77
84
</div >
78
85
</div >
91
98
import { KakaoMap } from ' vue3-kakao-maps' ;
92
99
import { ref , onMounted } from ' vue' ;
93
100
import { useHouseInfoStore } from ' @/stores/mapCard' ; // Pinia store 가져오기
101
+ import CardView from ' ./CardView.vue' ;
94
102
95
103
const coordinate = {
96
104
lat: 37.566826 ,
@@ -115,4 +123,5 @@ onMounted(async () => {
115
123
116
124
// store에서 houseInfos 가져오기
117
125
const houseInfos = houseInfoStore .houseInfos ;
126
+
118
127
</script >
You can’t perform that action at this time.
0 commit comments