feat(地图页): 右上角设置成确认按钮
This commit is contained in:
parent
66f4ff209c
commit
c90eae892b
@ -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>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user