Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
蒋秀川
/
miniProject
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 10229d1c
authored
Oct 09, 2025
by
陈岩
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat: 解决门店热力、区域热力国际化问题
1 parent
2e65e839
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
106 additions
and
8 deletions
h5/src/utils/i18n.js
h5/src/views/areaHeat/index.vue
h5/src/views/heatMap/index.vue
h5/src/utils/i18n.js
0 → 100644
View file @
10229d1
// 国际化配置文件
const
messages
=
{
zh_CN
:
{
heatMap
:
{
loading
:
'加载中...'
,
loadingForbidClick
:
'加载中...'
,
noFloorPlan
:
'未找到门店平面图'
,
noHeatData
:
'无热力数据'
,
getHeatMapDataFailed
:
'获取热力图数据失败'
,
loadSuccess
:
'加载成功'
},
areaHeat
:
{
getAreaDataFailed
:
'获取区域数据失败'
}
},
zh_TW
:
{
heatMap
:
{
loading
:
'載入中...'
,
loadingForbidClick
:
'載入中...'
,
noFloorPlan
:
'未找到門店平面圖'
,
noHeatData
:
'無熱力數據'
,
getHeatMapDataFailed
:
'獲取熱力圖數據失敗'
,
loadSuccess
:
'載入成功'
},
areaHeat
:
{
getAreaDataFailed
:
'獲取區域數據失敗'
}
},
en_US
:
{
heatMap
:
{
loading
:
'Loading...'
,
loadingForbidClick
:
'Loading...'
,
noFloorPlan
:
'Store floor plan not found'
,
noHeatData
:
'No heat map data'
,
getHeatMapDataFailed
:
'Failed to get heat map data'
,
loadSuccess
:
'Load successful'
},
areaHeat
:
{
getAreaDataFailed
:
'Failed to get area data'
}
},
ja_JP
:
{
heatMap
:
{
loading
:
'読み込み中...'
,
loadingForbidClick
:
'読み込み中...'
,
noFloorPlan
:
'店舗の平面図が見つかりません'
,
noHeatData
:
'熱マップデータがありません'
,
getHeatMapDataFailed
:
'熱マップデータの取得に失敗しました'
,
loadSuccess
:
'読み込み成功'
},
areaHeat
:
{
getAreaDataFailed
:
'エリアデータの取得に失敗しました'
}
}
};
// 获取语言文本
export
function
getI18nText
(
lang
,
key
)
{
// 默认使用中文
const
currentLang
=
lang
||
'zh_CN'
;
// 分割key,例如 'heatMap.loading' => ['heatMap', 'loading']
const
keys
=
key
.
split
(
'.'
);
// 获取对应语言的文本
let
text
=
messages
[
currentLang
];
for
(
const
k
of
keys
)
{
if
(
text
&&
text
[
k
])
{
text
=
text
[
k
];
}
else
{
// 如果找不到对应的文本,返回中文默认值
let
defaultText
=
messages
[
'zh_CN'
];
for
(
const
dk
of
keys
)
{
if
(
defaultText
&&
defaultText
[
dk
])
{
defaultText
=
defaultText
[
dk
];
}
else
{
return
key
;
// 如果默认值也找不到,返回key本身
}
}
return
defaultText
;
}
}
return
text
;
}
export
default
messages
;
\ No newline at end of file
\ No newline at end of file
h5/src/views/areaHeat/index.vue
View file @
10229d1
...
@@ -23,6 +23,7 @@ import { watch, ref } from "vue";
...
@@ -23,6 +23,7 @@ import { watch, ref } from "vue";
import
{
useRoute
}
from
"vue-router"
;
import
{
useRoute
}
from
"vue-router"
;
import
{
Toast
}
from
"vant"
;
import
{
Toast
}
from
"vant"
;
import
heatmap
from
"@/api/heatMap"
;
import
heatmap
from
"@/api/heatMap"
;
import
{
getI18nText
}
from
"@/utils/i18n.js"
;
const
$route
=
useRoute
();
const
$route
=
useRoute
();
...
@@ -103,7 +104,7 @@ const getGateStatistics = async () => {
...
@@ -103,7 +104,7 @@ const getGateStatistics = async () => {
console
.
log
(
domHeight
);
console
.
log
(
domHeight
);
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
"获取区域数据失败:"
,
error
);
console
.
error
(
getI18nText
(
currentLang
.
value
,
'areaHeat.getAreaDataFailed'
)
,
error
);
}
}
};
};
...
@@ -327,16 +328,21 @@ function formatSecondsMin(val) {
...
@@ -327,16 +328,21 @@ function formatSecondsMin(val) {
return
parseInt
(
val
/
60
)
+
"m"
;
return
parseInt
(
val
/
60
)
+
"m"
;
}
}
const
serverIp
=
ref
(
''
)
const
serverIp
=
ref
(
''
)
const
currentLang
=
ref
(
'zh_CN'
)
// 默认语言
watch
(
watch
(
()
=>
$route
.
query
,
()
=>
$route
.
query
,
async
(
newVal
)
=>
{
async
(
newVal
)
=>
{
const
{
token
,
mallId
,
startDate
:
sDate
,
endDate
:
eDate
,
key
,
serverIp
:
httpsIp
}
=
newVal
;
const
{
token
,
mallId
,
startDate
:
sDate
,
endDate
:
eDate
,
key
,
serverIp
:
httpsIp
,
lang
}
=
newVal
;
serverIp
.
value
=
httpsIp
||
'https://store.keliuyun.com'
serverIp
.
value
=
httpsIp
||
'https://store.keliuyun.com'
currentLang
.
value
=
lang
||
'zh_CN'
if
(
token
)
{
if
(
token
)
{
window
.
localStorage
.
setItem
(
"atoken"
,
token
);
window
.
localStorage
.
setItem
(
"atoken"
,
token
);
}
}
if
(
currentLang
.
value
)
{
window
.
localStorage
.
setItem
(
"lang"
,
currentLang
.
value
);
}
startDate
.
value
=
sDate
||
new
Date
().
toISOString
().
split
(
"T"
)[
0
];
startDate
.
value
=
sDate
||
new
Date
().
toISOString
().
split
(
"T"
)[
0
];
endDate
.
value
=
eDate
||
new
Date
().
toISOString
().
split
(
"T"
)[
0
];
endDate
.
value
=
eDate
||
new
Date
().
toISOString
().
split
(
"T"
)[
0
];
if
(
mallId
)
{
if
(
mallId
)
{
...
@@ -345,7 +351,7 @@ watch(
...
@@ -345,7 +351,7 @@ watch(
storeId
.
value
=
mallId
;
storeId
.
value
=
mallId
;
const
url
=
await
getFloorImage
();
const
url
=
await
getFloorImage
();
if
(
!
url
)
{
if
(
!
url
)
{
Toast
.
fail
(
"未找到门店平面图"
);
Toast
.
fail
(
getI18nText
(
currentLang
.
value
,
'heatMap.noFloorPlan'
)
);
return
false
;
return
false
;
}
}
floorImage
.
value
=
`
${
serverIp
.
value
}
/images/
${
url
}
`
;
floorImage
.
value
=
`
${
serverIp
.
value
}
/images/
${
url
}
`
;
...
...
h5/src/views/heatMap/index.vue
View file @
10229d1
...
@@ -18,6 +18,7 @@ import { Toast } from "vant";
...
@@ -18,6 +18,7 @@ import { Toast } from "vant";
import
heatmap
from
"@/api/heatmap"
;
// 假设你的API文件路径
import
heatmap
from
"@/api/heatmap"
;
// 假设你的API文件路径
import
{
heatmapFactory
}
from
"@/utils/heatmap.js"
;
import
{
heatmapFactory
}
from
"@/utils/heatmap.js"
;
import
{
getI18nText
}
from
"@/utils/i18n.js"
;
let
map
=
null
;
// 地图对象
let
map
=
null
;
// 地图对象
const
$route
=
useRoute
();
const
$route
=
useRoute
();
...
@@ -47,7 +48,7 @@ const getChannelList = async (mallId) => {
...
@@ -47,7 +48,7 @@ const getChannelList = async (mallId) => {
channelList
:
channelList
.
value
,
channelList
:
channelList
.
value
,
});
});
}
else
{
}
else
{
Toast
.
fail
(
"无热力数据"
);
Toast
(
getI18nText
(
currentLang
.
value
,
'heatMap.noHeatData'
)
);
}
}
}
else
{
}
else
{
console
.
error
(
"Failed to fetch channel list:"
,
data
.
message
);
console
.
error
(
"Failed to fetch channel list:"
,
data
.
message
);
...
@@ -81,7 +82,7 @@ const getHeatMapData = async (params) => {
...
@@ -81,7 +82,7 @@ const getHeatMapData = async (params) => {
dealHeatData
();
dealHeatData
();
});
});
}
else
{
}
else
{
Toast
.
fail
(
"获取热力图数据失败"
);
Toast
(
getI18nText
(
currentLang
.
value
,
'heatMap.getHeatMapDataFailed'
)
);
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
"Error fetching heat map data:"
,
error
);
console
.
error
(
"Error fetching heat map data:"
,
error
);
...
@@ -217,6 +218,7 @@ function dealHeatData() {
...
@@ -217,6 +218,7 @@ function dealHeatData() {
}
}
uni
.
postMessage
({
uni
.
postMessage
({
type
:
"loadSuccess"
,
type
:
"loadSuccess"
,
message
:
getI18nText
(
currentLang
.
value
,
'heatMap.loadSuccess'
)
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
"Error in dealHeatData:"
,
error
);
console
.
error
(
"Error in dealHeatData:"
,
error
);
...
@@ -247,11 +249,14 @@ function numFormat(val) {
...
@@ -247,11 +249,14 @@ function numFormat(val) {
}
}
const
serverIp
=
ref
(
""
);
const
serverIp
=
ref
(
""
);
const
currentLang
=
ref
(
"zh_CN"
);
// 默认语言
watch
(
watch
(
()
=>
$route
.
query
,
()
=>
$route
.
query
,
async
(
newVal
)
=>
{
async
(
newVal
)
=>
{
const
{
token
,
mallId
,
startDate
:
sDate
,
endDate
:
eDate
,
level
,
serverIp
:
httpsIp
}
=
newVal
;
const
{
token
,
mallId
,
startDate
:
sDate
,
endDate
:
eDate
,
level
,
serverIp
:
httpsIp
,
lang
}
=
newVal
;
serverIp
.
value
=
httpsIp
||
'https://store.keliuyun.com'
serverIp
.
value
=
httpsIp
||
'https://store.keliuyun.com'
currentLang
.
value
=
lang
||
'zh_CN'
;
// 设置当前语言
if
(
token
)
{
if
(
token
)
{
window
.
localStorage
.
setItem
(
"atoken"
,
token
);
window
.
localStorage
.
setItem
(
"atoken"
,
token
);
...
@@ -261,14 +266,14 @@ watch(
...
@@ -261,14 +266,14 @@ watch(
if
(
mallId
)
{
if
(
mallId
)
{
timeLevel
.
value
=
level
||
"rt"
;
// 默认实时
timeLevel
.
value
=
level
||
"rt"
;
// 默认实时
Toast
.
loading
({
Toast
.
loading
({
message
:
"加载中..."
,
message
:
getI18nText
(
currentLang
.
value
,
'heatMap.loading'
)
,
forbidClick
:
true
,
forbidClick
:
true
,
duration
:
0
,
duration
:
0
,
});
});
storeId
.
value
=
mallId
;
storeId
.
value
=
mallId
;
const
url
=
await
getFloorImage
();
const
url
=
await
getFloorImage
();
if
(
!
url
)
{
if
(
!
url
)
{
Toast
.
fail
(
"未找到门店平面图"
);
Toast
(
getI18nText
(
currentLang
.
value
,
'heatMap.noFloorPlan'
)
);
return
false
;
return
false
;
}
}
floorImage
.
value
=
`
${
serverIp
.
value
}
/images/
${
url
}
`
;
floorImage
.
value
=
`
${
serverIp
.
value
}
/images/
${
url
}
`
;
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment