2023-11-28 18:35:14 +08:00
|
|
|
<script setup>
|
2023-11-30 11:24:07 +08:00
|
|
|
import { defineProps, defineEmits, ref, nextTick, onMounted, } from "vue"
|
2023-11-28 18:35:14 +08:00
|
|
|
import { useRouter } from 'vue-router'
|
2023-12-04 18:51:43 +08:00
|
|
|
import { useAppStore } from "@/store/app.js";
|
|
|
|
|
2023-11-28 18:35:14 +08:00
|
|
|
const router = useRouter()
|
2023-11-29 18:49:31 +08:00
|
|
|
const emit = defineEmits(['offAreaList']);
|
|
|
|
const choseArea = ref(false);
|
2023-11-28 18:35:14 +08:00
|
|
|
|
2023-12-04 18:51:43 +08:00
|
|
|
const props = defineProps({
|
|
|
|
list: {
|
|
|
|
type: Object,
|
|
|
|
default: () => []
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
// const list = ref([
|
|
|
|
// {
|
|
|
|
// name: '泸县',
|
|
|
|
// pinyin: 'luxian',
|
|
|
|
// },
|
|
|
|
// // {
|
|
|
|
// // name: '江阳区',
|
|
|
|
// // pinyin: 'jiangyang',
|
|
|
|
// // },
|
|
|
|
// // {
|
|
|
|
// // name: '龙马潭区',
|
|
|
|
// // pinyin: 'longma',
|
|
|
|
// // },
|
|
|
|
// // {
|
|
|
|
// // name: '纳溪区',
|
|
|
|
// // pinyin: 'naxi',
|
|
|
|
// // },
|
|
|
|
// // {
|
|
|
|
// // name: '合江县',
|
|
|
|
// // pinyin: 'hejiang',
|
|
|
|
// // },
|
|
|
|
// // {
|
|
|
|
// // name: '叙永县',
|
|
|
|
// // pinyin: 'xuyong',
|
|
|
|
// // },
|
|
|
|
// // {
|
|
|
|
// // name: '古蔺县',
|
|
|
|
// // pinyin: 'gulin',
|
|
|
|
// // },
|
|
|
|
// ])
|
2023-11-28 18:35:14 +08:00
|
|
|
|
2023-11-30 11:24:07 +08:00
|
|
|
const appStore = useAppStore();
|
|
|
|
|
2023-11-28 18:35:14 +08:00
|
|
|
// 选镇
|
|
|
|
const choseTownFn = (item) => {
|
2023-12-04 18:51:43 +08:00
|
|
|
if (item.code.length == 6) {
|
|
|
|
appStore.setMapInfo('luxian');
|
|
|
|
appStore.setAddress({
|
|
|
|
areaCode: item.code,
|
|
|
|
streetCode: ''
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
appStore.setAddress({
|
|
|
|
areaCode: appStore.address.areaCode,
|
|
|
|
streetCode: item.code
|
|
|
|
})
|
|
|
|
}
|
2023-12-05 18:39:17 +08:00
|
|
|
emit('offAreaList', item);
|
2023-11-28 18:35:14 +08:00
|
|
|
}
|
|
|
|
|
2023-11-29 18:49:31 +08:00
|
|
|
const open = () => {
|
|
|
|
choseArea.value = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
const close = () => {
|
|
|
|
choseArea.value = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const show = () => {
|
|
|
|
choseArea.value = !choseArea.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
defineExpose({
|
|
|
|
open, close, show
|
|
|
|
})
|
2023-11-30 11:24:07 +08:00
|
|
|
|
|
|
|
onMounted(() => {
|
2023-12-04 18:51:43 +08:00
|
|
|
// list.value.forEach(item => {
|
|
|
|
// if (item.pinyin == appStore.map_info) {
|
|
|
|
// choseTownFn(item)
|
|
|
|
// }
|
|
|
|
// })
|
2023-11-30 11:24:07 +08:00
|
|
|
})
|
2023-11-29 18:49:31 +08:00
|
|
|
|
2023-11-28 18:35:14 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<transition name="fade">
|
2023-11-29 18:49:31 +08:00
|
|
|
<div class="address" v-show="choseArea == true">
|
2023-11-28 18:35:14 +08:00
|
|
|
<div
|
|
|
|
class="address-li"
|
|
|
|
@click="choseTownFn(item)"
|
|
|
|
v-for="(item, index) in list"
|
|
|
|
:key="index"
|
|
|
|
>
|
|
|
|
{{ item.name }}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</transition>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.address {
|
|
|
|
left: 1vw;
|
|
|
|
top: 18px;
|
|
|
|
position: absolute;
|
|
|
|
width: 10vw;
|
|
|
|
height: 18vh;
|
|
|
|
background-color: #001e32;
|
|
|
|
color: #c7dbe3;
|
|
|
|
z-index: 9999;
|
|
|
|
overflow-y: auto;
|
|
|
|
box-sizing: border-box;
|
|
|
|
padding: 5px;
|
|
|
|
|
|
|
|
.address-li {
|
|
|
|
padding: 2px 5px;
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
border-bottom: 0.1px solid #0e293c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.address::-webkit-scrollbar {
|
|
|
|
width: 10px;
|
|
|
|
background-color: #153041;
|
|
|
|
}
|
|
|
|
|
|
|
|
.address::-webkit-scrollbar-track {
|
|
|
|
background-color: #153041;
|
|
|
|
}
|
|
|
|
|
|
|
|
::-webkit-scrollbar-thumb {
|
|
|
|
background-color: #4ab9d0;
|
|
|
|
border-radius: 5px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.fade-enter-active,
|
|
|
|
.fade-leave-active {
|
|
|
|
transition: opacity 0.5s;
|
|
|
|
}
|
|
|
|
.fade-enter,
|
|
|
|
.fade-leave-to {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
</style>
|