# xinf-pc
**Repository Path**: xiaole9924/xinf-pc
## Basic Information
- **Project Name**: xinf-pc
- **Description**: 🧀 v3+ts+bt 百度地图找房
使用技术 : hooks 全局弹框、vue-baidu-map地图找房、from表单验证封装、axios封装
- **Primary Language**: Unknown
- **License**: MulanPSL-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 7
- **Forks**: 2
- **Created**: 2021-06-28
- **Last Updated**: 2025-02-27
## Categories & Tags
**Categories**: Uncategorized
**Tags**: 地图找房, vue-baidu-map
## README
```
欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,本文纯手打 [小乐] 专权。
持续更新中...
```
### 搜索房源 使用技术 vue3+ts+vuex+axios
运行项目: yarn install yarn serve
### 区级搜索 地图找房展示

### 公交、学校、医院周边搜索

### 小区房源搜索

### vue3 hooks 登录动画弹框封装

```typescript
import { onMounted , onUnmounted ,nextTick } from 'vue'
import { useStore } from 'vuex'
const uesLoginModel = () => {
const store = useStore()
const bindLogin = ()=> {
console.log(store.state.isLogin)
}
onMounted(()=> {
const doms = document.querySelectorAll('.isLogin');
nextTick(():void => {
doms.forEach(dom => {
dom.addEventListener('click',bindLogin)
})
})
})
onUnmounted(() => {
console.log(123)
})
}
export default uesLoginModel
```
### form 表单验证封装 父组件
```vue
```
### 表单子组件 input验证封装
```vue
```
###.封装axios+vuex
``` typescript
import axios from 'axios'
import { Commit } from 'vuex'
export const getAndCommit = async (url: string, payload: any,commit: Commit ,mutationName?: string) => {
const { data } = await axios.get(url,{params: payload})
mutationName && commit(mutationName, data)
return data
}
export const get = async (url: string, payload: any) => {
const { data } = await axios.get(url+payload)
return data
}
export const postAndCommit = async (url: string, payload: any,commit: Commit ,mutationName?: string) => {
const { data } = await axios.post(url,payload)
mutationName && commit(mutationName, data)
return data
}
export default {
getAndCommit, postAndCommit,get
}
```
###.封装登录接口
```typescript
import { types } from '../types'
const state = {
isLogin: false,
number: 1,
loginType: 'login',
row: {}
}
const getters = {
}
const mutations = {
[types.HANDLER_LOGIN](state: any, data: any) {
state.loginType = data.type
state.isLogin = data.bol
},
[types.CHANGE_LOGINTYPE](state: any, str: string) {
state.loginType = str
},
[types.GET_DATA](state: any, data: any) {
state.row = data
}
}
const actions = {
// fetchData({ commit }) {
// getAndCommit('/houseList', types.GET_DATA, commit)
// }
}
export default {
namespaced: true, //命名空间
state,
getters,
mutations,
actions
}
```
### 封装 常用查询接口
``` typescript
import {getAndCommit , postAndCommit} from '@/api/https'
import { arrToObj, objToArr } from '../../../hooks/help'
import { types } from '../types'
const state = {
houseList: [1,2,3]
}
const mutations = {
[types.GET_HOUSELIST](state, data) {
state.houseList = data.data
}
}
const actions = {
houseList({ commit } ,payload) {
return getAndCommit('houseList',payload,commit)
},
newsList({ commit } ,payload) {
return getAndCommit('api/getArticle',payload,commit)
}
,
houseDetail({ commit } ,payload) {
return getAndCommit('house',payload,commit)
}
}
const getters = {
getHouseList: (state) => {
return objToArr(state.houseList)
}
}
export default {
namespaced: true, //命名空间
state,mutations,getters,actions
}
```
### 调用常用接口 通过vuex调用
``` typescript
```