File tree Expand file tree Collapse file tree 4 files changed +27
-47
lines changed Expand file tree Collapse file tree 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 11import { defineStore } from 'pinia' ;
22import axios from 'axios' ;
3+ const BASE_URL = import . meta. env . VITE_API_BASE_URL ;
34
45export const useHouseInfoStore = defineStore ( 'houseInfo' , {
56 state : ( ) => ( {
6- houseInfos : { data : [ ] } , // 초기 상태 설정
7+ houseInfos : { data : [ ] } ,
78 } ) ,
89 actions : {
910 async fetchHouseInfo ( type ) {
1011 try {
12+
1113 const response = await axios . get ( `http://localhost:8080/api/houseinfos/${ type } ` ) ;
1214
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+ //아파트 출력
2318 } catch ( error ) {
2419 console . log ( '데이터를 가져오는데 실패했습니다.' , error ) ;
2520 }
Original file line number Diff line number Diff line change 99 <div class =" ml-2" >
1010 <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" >
1111 {{ 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 >
1313 <div class =" pl-1" >
1414 <span class =" text-sm text-gray-600" >
1515 {{ districtName }}</span >
2121 <span class =" text-sm" >{{ minPropertyPrice }}</span >
2222 <span class =" text-md" >만원</span >
2323 <span class =" text-md" > - </span >
24- <span class =" text-md" >최대 </span >
24+ <span class =" text-md" >최대</span >
2525 <span class =" text-sm" >{{ maxPropertyPrice }}</span >
2626 <span class =" text-md" >만원</span >
2727 </div >
28+
2829 <!-- 버튼 -->
2930 </div >
3031 </div >
3334
3435<script setup>
3536
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-
6237defineProps ({
6338 id: Number , // int → Number
6439 buildingUse: String ,
Original file line number Diff line number Diff line change 6060 <FilterButton ></FilterButton >
6161 </div >
6262 <!-- 목록 영역 추가할 수 있습니다 -->
63- <div class =" p-2" >
63+ <div class =" p-2 overflow-y-auto " >
6464
65- <div v-if =" houseInfosLoaded" >
65+ <!-- < div v-if="houseInfosLoaded"> -- >
6666 <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+
6978 </div >
70- </div >
79+ <!-- < /div> -- >
7180
7281 <!-- 데이터가 로딩 중일 때 표시할 로딩 화면 -->
73- <div v-else >
74- <p >로딩 중...</p >
75- </div >
82+
7683
7784 </div >
7885 </div >
9198import { KakaoMap } from ' vue3-kakao-maps' ;
9299import { ref , onMounted } from ' vue' ;
93100import { useHouseInfoStore } from ' @/stores/mapCard' ; // Pinia store 가져오기
101+ import CardView from ' ./CardView.vue' ;
94102
95103const coordinate = {
96104 lat: 37.566826 ,
@@ -115,4 +123,5 @@ onMounted(async () => {
115123
116124// store에서 houseInfos 가져오기
117125const houseInfos = houseInfoStore .houseInfos ;
126+
118127 </script >
You can’t perform that action at this time.
0 commit comments