feat(地图页): 右上角设置成确认按钮

This commit is contained in:
hzj 2025-09-18 11:57:13 +08:00
parent 66f4ff209c
commit c90eae892b

View File

@ -6,7 +6,7 @@
<MobileHeader title="Country&Region">
<template v-slot:extraFunction>
<div style="display: flex; justify-content: center; align-items: center; width: 10%">
<img src="../assets/icon/selected.png" alt="" style="width: 100%" />
<img src="../assets/icon/selected.png" alt="" style="width: 100%" @click="confirm" />
</div>
</template>
</MobileHeader>
@ -76,26 +76,29 @@
</template>
<script setup>
import { computed, onMounted, ref } from 'vue'
import { computed, ref } from 'vue'
import MobileHeader from '../components/MobileHeader.vue'
import { useRoute } from 'vue-router'
import { useRoute, useRouter } from 'vue-router'
import { useCountryStore } from '@/stores/country'
import { storeToRefs } from 'pinia'
const route = useRoute()
const router = useRouter()
const countryStore = useCountryStore()
const { list: countryList, selectedCountry } = storeToRefs(countryStore) //
// const { list: countryList, selectedCountry } = storeToRefs(countryStore) //store
const countryList = ref(countryStore.list)
const selectedCountry = ref(countryStore.selectedCountry)
const groupIndex = ref(-1) //
const countryIndex = ref(-1) //
//
const selectC = (gIndex, cIndex, country) => {
groupIndex.value = gIndex
countryIndex.value = cIndex
countryStore.setCountry(country)
} //
selectedCountry.value = country
}
//
const groupedCountries = computed(() => {
const groups = {}
countryList.value.forEach((item) => {
@ -130,16 +133,12 @@ const groupedCountries = computed(() => {
return resCountryList
})
onMounted(() => {
const countryListStr = sessionStorage.getItem('countryList')
selectedCountry.value = sessionStorage.getItem('selectedCountry')
if (countryListStr) {
countryList.value = JSON.parse(countryListStr)
//
// sessionStorage.removeItem('tempCountryList');
}
})
//
const confirm = () => {
console.log('点击确认按钮')
countryStore.setCountry(selectedCountry.value)
router.go(-1)
}
</script>
<style scoped>