Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
manulife-weapp
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
hookehuyr
2026-02-09 10:48:49 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a7cfea11368d928fc445bb6f58df0c0fac0d4b54
a7cfea11
1 parent
1ce5d786
fix(product): 修复首页图标加载崩溃和金额显示问题
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
25 deletions
src/components/PlanFields/AmountKeyboard.vue
src/pages/index/index.vue
src/components/PlanFields/AmountKeyboard.vue
View file @
a7cfea1
...
...
@@ -286,8 +286,13 @@ const showAmountModal = ref(false)
* @type {ComputedRef<string>}
*/
const
displayValue
=
computed
(()
=>
{
// 优先显示输入过程中的值
// 优先显示输入过程中的值
(格式化)
if
(
inputValue
.
value
)
{
// 尝试解析为数字并格式化,如果解析失败则返回原值
const
num
=
parseFloat
(
inputValue
.
value
)
if
(
!
Number
.
isNaN
(
num
))
{
return
num
.
toFixed
(
2
)
}
return
inputValue
.
value
}
// 如果没有输入值,显示表单的原始值
...
...
@@ -350,7 +355,7 @@ onUnmounted(() => {
/**
* 监听键盘显示状态
*/
watch
(
showKeyboard
,
(
newValue
)
=>
{
watch
(
showKeyboard
,
(
newValue
,
oldValue
)
=>
{
if
(
!
keyboardPopupId
.
value
)
{
return
}
...
...
@@ -365,6 +370,12 @@ watch(showKeyboard, (newValue) => {
deactivatePopup
(
keyboardPopupId
.
value
)
// 同步关闭金额弹窗
showAmountModal
.
value
=
false
// 【修复】如果是从打开状态关闭(用户点击遮罩或关闭按钮),清除临时输入值
// 这样可以避免显示 "123." 这种不完整的值
if
(
oldValue
===
true
)
{
inputValue
.
value
=
''
}
}
}
)
...
...
@@ -390,14 +401,18 @@ const openKeyboard = () => {
const
onInput
=
(
val
)
=>
{
// 如果输入的是小数点,检查是否已经有小数点
if
(
val
===
'.'
&&
inputValue
.
value
.
includes
(
'.'
))
{
// 震动反馈提示
Taro
.
vibrateShort
(
{
type
:
'
light
'
}
)
return
}
// 如果输入的是数字,检查小数点后的位数
if
(
val
>=
'0'
&&
val
<=
'9'
)
{
const
parts
=
inputValue
.
value
.
split
(
'.'
)
// 如果已经有小数点,并且小数点后有2位,则忽略输入
// 如果已经有小数点,并且小数点后有2位,则忽略输入
并震动提示
if
(
parts
.
length
===
2
&&
parts
[
1
]?.
length
>=
2
)
{
// 震动反馈提示已达到最大位数
Taro
.
vibrateShort
(
{
type
:
'
light
'
}
)
return
}
}
...
...
@@ -445,6 +460,8 @@ const onConfirm = () => {
* 关闭键盘认处
*/
const
onClose
=
()
=>
{
// 清除临时输入值,让它回退到原始值(避免显示 "123." 这种不完整的值)
inputValue
.
value
=
''
// 只关闭金额弹窗,让 showKeyboard 自然变化触发 watch 处理 GlobalPopupManager
showAmountModal
.
value
=
false
}
...
...
src/pages/index/index.vue
View file @
a7cfea1
...
...
@@ -203,28 +203,30 @@ const fetchHomeIcons = async () => {
if (res.code === 1 && res.data) {
// 将 API 数据映射为 loopNav 格式
loopNav.value = res.data.map(item => {
// 解析 link 字段,格式: "/pages/category-list/index?cid=3129684"
const [route, queryStr] = item.link.split('?');
const params = {};
// 如果有查询参数,解析为对象
if (queryStr) {
queryStr.split('&').forEach(param => {
const [key, value] = param.split('=');
params[key] = decodeURIComponent(value);
});
}
// 返回导航项对象
return {
id: String(item.id),
icon: item.icon,
name: item.name,
route,
...params // 展开参数(如 cid)
};
});
loopNav.value = res.data
.filter(item => item.link) // 过滤掉 link 为空的项
.map(item => {
// 解析 link 字段,格式: "/pages/category-list/index?cid=3129684"
const [route, queryStr] = item.link.split('?');
const params = {};
// 如果有查询参数,解析为对象
if (queryStr) {
queryStr.split('&').forEach(param => {
const [key, value] = param.split('=');
params[key] = decodeURIComponent(value);
});
}
// 返回导航项对象
return {
id: String(item.id),
icon: item.icon,
name: item.name,
route,
...params // 展开参数(如 cid)
};
});
}
} catch (err) {
console.error('获取首页图标失败:', err);
...
...
Please
register
or
login
to post a comment