fix(地图): 完成地图页面及其功能
This commit is contained in:
parent
d962fe9102
commit
f730e2461f
@ -19,6 +19,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"airwallex-payment-elements": "^1.131.0",
|
"airwallex-payment-elements": "^1.131.0",
|
||||||
|
"pinia": "^3.0.3",
|
||||||
"vue": "^3.5.18",
|
"vue": "^3.5.18",
|
||||||
"vue-router": "^4.5.1"
|
"vue-router": "^4.5.1"
|
||||||
},
|
},
|
||||||
|
|||||||
BIN
src/assets/icon/selected.png
Normal file
BIN
src/assets/icon/selected.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
29
src/main.js
29
src/main.js
@ -1,17 +1,17 @@
|
|||||||
import './assets/main.css'
|
import "./assets/main.css";
|
||||||
import { logEnvInfo } from './utils/env.js'
|
import { logEnvInfo } from "./utils/env.js";
|
||||||
import { versionChecker } from './utils/versionChecker.js'
|
import { versionChecker } from "./utils/versionChecker.js";
|
||||||
|
import { createPinia } from "pinia";
|
||||||
import { createApp } from 'vue'
|
import { createApp } from "vue";
|
||||||
import App from './App.vue'
|
import App from "./App.vue";
|
||||||
import router from './router'
|
import router from "./router";
|
||||||
|
|
||||||
// 初始化环境信息
|
// 初始化环境信息
|
||||||
logEnvInfo()
|
logEnvInfo();
|
||||||
|
|
||||||
// 版本检查
|
// 版本检查
|
||||||
if (versionChecker.checkVersion()) {
|
if (versionChecker.checkVersion()) {
|
||||||
console.log('检测到新版本,正在更新...')
|
console.log("检测到新版本,正在更新...");
|
||||||
// 可以选择显示一个更新提示
|
// 可以选择显示一个更新提示
|
||||||
// if (confirm('检测到新版本,是否立即更新?')) {
|
// if (confirm('检测到新版本,是否立即更新?')) {
|
||||||
// versionChecker.forceReload()
|
// versionChecker.forceReload()
|
||||||
@ -19,10 +19,11 @@ if (versionChecker.checkVersion()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 初始化权限系统
|
// 初始化权限系统
|
||||||
console.debug('🔐 Permission system initialized')
|
console.debug("🔐 Permission system initialized");
|
||||||
|
const pinia = createPinia();
|
||||||
|
const app = createApp(App);
|
||||||
|
|
||||||
const app = createApp(App)
|
app.use(router);
|
||||||
|
app.use(pinia);
|
||||||
|
|
||||||
app.use(router)
|
app.mount("#app");
|
||||||
|
|
||||||
app.mount('#app')
|
|
||||||
|
|||||||
@ -185,6 +185,12 @@ const router = createRouter({
|
|||||||
component: () => import("../views/RechargeFreightAgent.vue"),
|
component: () => import("../views/RechargeFreightAgent.vue"),
|
||||||
meta: { requiresAuth: true },
|
meta: { requiresAuth: true },
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "/map",
|
||||||
|
name: "map",
|
||||||
|
component: () => import("../views/map.vue"),
|
||||||
|
meta: { requiresAuth: true },
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: "/pay-result",
|
path: "/pay-result",
|
||||||
name: "pay-result",
|
name: "pay-result",
|
||||||
|
|||||||
16
src/stores/country.js
Normal file
16
src/stores/country.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { defineStore } from "pinia";
|
||||||
|
|
||||||
|
export const useCountryStore = defineStore("country", {
|
||||||
|
state: () => ({
|
||||||
|
list: [],
|
||||||
|
selectedCountry: {},
|
||||||
|
}),
|
||||||
|
actions: {
|
||||||
|
setCountryList(data) {
|
||||||
|
this.list = data;
|
||||||
|
},
|
||||||
|
setCountry(country) {
|
||||||
|
this.selectedCountry = country;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
@ -30,6 +30,7 @@ export const PAGES = {
|
|||||||
ADMIN_CENTER: "/admin-center",
|
ADMIN_CENTER: "/admin-center",
|
||||||
RECHARGE_STANDARD: "/recharge-standard",
|
RECHARGE_STANDARD: "/recharge-standard",
|
||||||
PAY_RESULT: "/pay-result",
|
PAY_RESULT: "/pay-result",
|
||||||
|
MAP: "/map",
|
||||||
};
|
};
|
||||||
|
|
||||||
// 🎯 核心改变:基于身份的权限配置
|
// 🎯 核心改变:基于身份的权限配置
|
||||||
@ -106,6 +107,7 @@ export const ROLE_PERMISSIONS = {
|
|||||||
PUBLIC_PAGES: [
|
PUBLIC_PAGES: [
|
||||||
PAGES.NOT_APP, // 错误页面
|
PAGES.NOT_APP, // 错误页面
|
||||||
PAGES.PAY_RESULT, // 支付成功页面
|
PAGES.PAY_RESULT, // 支付成功页面
|
||||||
|
PAGES.MAP, // 地图选择页面
|
||||||
"/recharge",
|
"/recharge",
|
||||||
"/recharge-freight-agent",
|
"/recharge-freight-agent",
|
||||||
],
|
],
|
||||||
|
|||||||
@ -141,6 +141,7 @@ import MobileHeader from "../components/MobileHeader.vue";
|
|||||||
import { onMounted, ref, computed } from "vue";
|
import { onMounted, ref, computed } from "vue";
|
||||||
import { searchUser } from "@/api/userInfo";
|
import { searchUser } from "@/api/userInfo";
|
||||||
// import { getUserIdentity } from "@/api/wallet";
|
// import { getUserIdentity } from "@/api/wallet";
|
||||||
|
import { showError, showWarning, showInfo, showSuccess } from "@/utils/toast.js";
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="fullPage">
|
||||||
<!-- 顶部 -->
|
<!-- 顶部 -->
|
||||||
<MobileHeader title="Recharge">
|
<MobileHeader title="Recharge">
|
||||||
<template v-slot:extraFunction>
|
<template v-slot:extraFunction>
|
||||||
@ -72,7 +72,7 @@
|
|||||||
|
|
||||||
<div style="width: 100%; display: flex; justify-content: space-between; margin: 10px 0">
|
<div style="width: 100%; display: flex; justify-content: space-between; margin: 10px 0">
|
||||||
<div style="font-weight: 600">Select a country:</div>
|
<div style="font-weight: 600">Select a country:</div>
|
||||||
<div style="font-weight: 500; color: rgba(0, 0, 0, 0.4)">
|
<div style="font-weight: 500; color: rgba(0, 0, 0, 0.4)" @click="goMap">
|
||||||
<img src="../assets/icon/Vector.png" alt="" style="width: 10px" />
|
<img src="../assets/icon/Vector.png" alt="" style="width: 10px" />
|
||||||
{{ selectedCountry.countryName }}
|
{{ selectedCountry.countryName }}
|
||||||
</div>
|
</div>
|
||||||
@ -142,7 +142,11 @@ import { goAirwallex } from "@/utils/payment";
|
|||||||
import { showError, showWarning, showInfo, showSuccess } from "@/utils/toast.js";
|
import { showError, showWarning, showInfo, showSuccess } from "@/utils/toast.js";
|
||||||
|
|
||||||
import { useRoute } from "vue-router";
|
import { useRoute } from "vue-router";
|
||||||
|
import router from "@/router";
|
||||||
|
import { useCountryStore } from "@/stores/country";
|
||||||
|
import { storeToRefs } from "pinia";
|
||||||
|
|
||||||
|
const countryStore = useCountryStore();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
const languageList = ref([
|
const languageList = ref([
|
||||||
@ -161,9 +165,10 @@ const listBt = () => {
|
|||||||
const applicationId = ref("1963531459019739137");
|
const applicationId = ref("1963531459019739137");
|
||||||
const userProfile = ref({}); //用户信息
|
const userProfile = ref({}); //用户信息
|
||||||
const type = ref(""); //用户身份
|
const type = ref(""); //用户身份
|
||||||
const countryList = ref([]); //国家信息
|
|
||||||
const regionId = ref(""); //区域id
|
const regionId = ref(""); //区域id
|
||||||
const selectedCountry = ref({}); //选中的国家
|
|
||||||
|
const { list: countryList, selectedCountry } = storeToRefs(countryStore); //国家信息
|
||||||
|
|
||||||
const channels = ref([]); //支付渠道
|
const channels = ref([]); //支付渠道
|
||||||
const selectedChannelName = ref(""); //选中的支付渠道
|
const selectedChannelName = ref(""); //选中的支付渠道
|
||||||
@ -171,6 +176,11 @@ const selectedChannelName = ref(""); //选中的支付渠道
|
|||||||
const commodityList = ref([]); //商品列表
|
const commodityList = ref([]); //商品列表
|
||||||
const selectedCommodity = ref({}); //选中的商品
|
const selectedCommodity = ref({}); //选中的商品
|
||||||
|
|
||||||
|
// 前往地图页
|
||||||
|
const goMap = () => {
|
||||||
|
router.push({ path: "/map" });
|
||||||
|
};
|
||||||
|
|
||||||
const goPay = async (item, commodity) => {
|
const goPay = async (item, commodity) => {
|
||||||
selectedCommodity.value = commodity;
|
selectedCommodity.value = commodity;
|
||||||
let payData = {
|
let payData = {
|
||||||
@ -230,8 +240,11 @@ onMounted(async () => {
|
|||||||
if (userInfo.body && userInfo.body.regionId && userInfo.body.countryList.length != 0) {
|
if (userInfo.body && userInfo.body.regionId && userInfo.body.countryList.length != 0) {
|
||||||
userProfile.value = { ...userInfo.body.userProfile, type: "GOLD" };
|
userProfile.value = { ...userInfo.body.userProfile, type: "GOLD" };
|
||||||
|
|
||||||
countryList.value = userInfo.body.countryList;
|
countryStore.setCountryList(userInfo.body.countryList);
|
||||||
selectedCountry.value = userInfo.body.countryList[0];
|
if (JSON.stringify(selectedCountry.value) == "{}") {
|
||||||
|
countryStore.setCountry(userInfo.body.countryList[0]);
|
||||||
|
}
|
||||||
|
|
||||||
regionId.value = userInfo.body.regionId;
|
regionId.value = userInfo.body.regionId;
|
||||||
|
|
||||||
let appCommodityCardParams = {
|
let appCommodityCardParams = {
|
||||||
@ -249,6 +262,14 @@ onMounted(async () => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
.fullPage {
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
background-image: url(../assets/images/secondBg.png);
|
||||||
|
background-size: 100% 100%;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
.slide-fade-enter-active {
|
.slide-fade-enter-active {
|
||||||
transition: all 0.3s ease-out;
|
transition: all 0.3s ease-out;
|
||||||
}
|
}
|
||||||
|
|||||||
151
src/views/map.vue
Normal file
151
src/views/map.vue
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
<template>
|
||||||
|
<div class="fullPage">
|
||||||
|
<div>
|
||||||
|
<!-- 顶部 -->
|
||||||
|
<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%" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</MobileHeader>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 内容 -->
|
||||||
|
<div style="padding: 10px">
|
||||||
|
<div style="font-weight: 510; color: rgba(0, 0, 0, 0.4)">Select your country</div>
|
||||||
|
|
||||||
|
<div v-for="(countries, gIndex) in groupedCountries" :key="gIndex">
|
||||||
|
<div style="font-weight: 400; color: rgba(0, 0, 0, 0.4)">{{ countries.letter }}</div>
|
||||||
|
<div
|
||||||
|
style="
|
||||||
|
margin: 10px 0;
|
||||||
|
border-radius: 12px;
|
||||||
|
box-shadow: 0 0 4px 0 #00000050;
|
||||||
|
padding: 10px;
|
||||||
|
background-color: white;
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-for="(country, cIndex) in countries.countries"
|
||||||
|
:key="cIndex"
|
||||||
|
style="
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
margin: 10px 0;
|
||||||
|
"
|
||||||
|
@click="selectC(gIndex, cIndex, country)"
|
||||||
|
>
|
||||||
|
<div style="display: flex; align-items: center">
|
||||||
|
<img
|
||||||
|
:src="country.country.nationalFlag"
|
||||||
|
alt=""
|
||||||
|
style="height: 16px; margin-right: 10px"
|
||||||
|
/>
|
||||||
|
{{ country.countryName }}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
style="
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
border: 1px solid rgba(0, 0, 0, 0.4);
|
||||||
|
border-radius: 50%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style="
|
||||||
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background-color: rgba(187, 146, 255, 1);
|
||||||
|
"
|
||||||
|
v-if="groupIndex == gIndex && countryIndex == cIndex"
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { computed, onMounted, ref } from "vue";
|
||||||
|
import MobileHeader from "../components/MobileHeader.vue";
|
||||||
|
import { useRoute } from "vue-router";
|
||||||
|
import { useCountryStore } from "@/stores/country";
|
||||||
|
import { storeToRefs } from "pinia";
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
|
|
||||||
|
const countryStore = useCountryStore();
|
||||||
|
const { list: countryList, selectedCountry } = storeToRefs(countryStore); //国家信息
|
||||||
|
|
||||||
|
const groupIndex = ref(-1); //选中的首字母区域
|
||||||
|
const countryIndex = ref(-1); //选中区域的第几个
|
||||||
|
|
||||||
|
const selectC = (gIndex, cIndex, country) => {
|
||||||
|
groupIndex.value = gIndex;
|
||||||
|
countryIndex.value = cIndex;
|
||||||
|
countryStore.setCountry(country);
|
||||||
|
}; //选择国家
|
||||||
|
|
||||||
|
const groupedCountries = computed(() => {
|
||||||
|
const groups = {};
|
||||||
|
countryList.value.forEach((item) => {
|
||||||
|
let firstLetter = item.countryName.charAt(0)?.toUpperCase() || "#"; //获取首字母转大写
|
||||||
|
const normalizedLetter = /[A-Z]/.test(firstLetter) ? firstLetter : "#"; //处理特殊字符
|
||||||
|
|
||||||
|
if (!groups.hasOwnProperty(normalizedLetter)) {
|
||||||
|
groups[normalizedLetter] = [];
|
||||||
|
}
|
||||||
|
groups[normalizedLetter].push(item);
|
||||||
|
});
|
||||||
|
|
||||||
|
let resCountryList = Object.keys(groups)
|
||||||
|
.sort()
|
||||||
|
.map((letter) => ({
|
||||||
|
letter,
|
||||||
|
countries: groups[letter].sort((a, b) => a.countryName.localeCompare(b.countryName)),
|
||||||
|
}));
|
||||||
|
|
||||||
|
let firstLetter = selectedCountry.value.countryName.charAt(0)?.toUpperCase() || "#"; //当前选中的国家的首字母
|
||||||
|
resCountryList.forEach((resitem, gIndex) => {
|
||||||
|
if (resitem.letter == firstLetter) {
|
||||||
|
resitem.countries.forEach((citem, cIndex) => {
|
||||||
|
if (citem.countryName == selectedCountry.value.countryName) {
|
||||||
|
groupIndex.value = gIndex;
|
||||||
|
countryIndex.value = cIndex;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return resCountryList;
|
||||||
|
});
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
const countryListStr = sessionStorage.getItem("countryList");
|
||||||
|
selectedCountry.value = sessionStorage.getItem("selectedCountry");
|
||||||
|
if (countryListStr) {
|
||||||
|
countryList.value = JSON.parse(countryListStr);
|
||||||
|
|
||||||
|
// 可选:清除临时存储
|
||||||
|
// sessionStorage.removeItem('tempCountryList');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.fullPage {
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
background-image: url(../assets/images/secondBg.png);
|
||||||
|
background-size: 100% 100%;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Loading…
x
Reference in New Issue
Block a user