Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
飞
飞鹤小程序
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
FH
飞鹤小程序
Commits
7cedc8e8
Commit
7cedc8e8
authored
Oct 15, 2025
by
spc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jump page/index/index
parent
e53c27a5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
14 deletions
+46
-14
index.js
utils/index.js
+46
-14
No files found.
utils/index.js
View file @
7cedc8e8
// 导入全局store
import
{
useGlobalStore
}
from
"../stores/global"
;
// 跳转类型枚举
// 跳转类型枚举
export
const
JumpType
=
{
export
const
JumpType
=
{
INNER
:
1
,
// 内部小程序页面跳转
INNER
:
1
,
// 内部小程序页面跳转
...
@@ -15,11 +18,40 @@ export const JumpType = {
...
@@ -15,11 +18,40 @@ export const JumpType = {
export
function
jump
({
type
,
url
,
extra
=
{}
})
{
export
function
jump
({
type
,
url
,
extra
=
{}
})
{
switch
(
type
)
{
switch
(
type
)
{
case
JumpType
.
INNER
:
case
JumpType
.
INNER
:
// 内部小程序页面跳转
try
{
uni
.
navigateTo
({
url
,
const
pages
=
getCurrentPages
();
...
extra
,
const
currentPage
=
pages
[
pages
.
length
-
1
];
});
const
currentPath
=
currentPage
.
route
;
if
(
url
.
indexOf
(
'pages/index/index'
)
>=
0
&&
currentPath
.
indexOf
(
'pages/index/index'
)
>=
0
)
{
// 获取全局store
const
globalStore
=
useGlobalStore
();
if
(
url
.
indexOf
(
'home'
)
>=
0
)
{
globalStore
.
setCurTabIndex
(
0
);
}
else
if
(
url
.
indexOf
(
'brand'
)
>=
0
)
{
globalStore
.
setCurTabIndex
(
1
);
}
else
if
(
url
.
indexOf
(
'integral'
)
>=
0
)
{
globalStore
.
setCurTabIndex
(
2
);
}
else
if
(
url
.
indexOf
(
'my'
)
>=
0
)
{
globalStore
.
setCurTabIndex
(
3
);
}
}
else
{
// 内部小程序页面跳转
uni
.
navigateTo
({
url
,
...
extra
,
});
}
}
catch
(
error
)
{
console
.
error
(
'跳转处理错误:'
,
error
);
// 出错时默认执行内部跳转
uni
.
navigateTo
({
url
,
...
extra
,
});
}
break
;
break
;
case
JumpType
.
MINI
:
case
JumpType
.
MINI
:
// 跳转到其他小程序页面
// 跳转到其他小程序页面
...
@@ -36,11 +68,11 @@ export function jump({ type, url, extra = {} }) {
...
@@ -36,11 +68,11 @@ export function jump({ type, url, extra = {} }) {
console
.
log
(
"jumpParams:"
,
jumpParams
);
console
.
log
(
"jumpParams:"
,
jumpParams
);
if
(
extra
.
embedded
||
jumpParams
.
appId
===
'wx4205ec55b793245e'
)
{
// 星妈优选的小程序都为半屏拉起
if
(
extra
.
embedded
||
jumpParams
.
appId
===
'wx4205ec55b793245e'
)
{
// 星妈优选的小程序都为半屏拉起
console
.
log
(
'半屏拉起'
,
jumpParams
)
console
.
log
(
'半屏拉起'
,
jumpParams
)
uni
.
openEmbeddedMiniProgram
(
jumpParams
);
uni
.
openEmbeddedMiniProgram
(
jumpParams
);
}
else
{
}
else
{
console
.
log
(
'直接跳转'
,
jumpParams
)
console
.
log
(
'直接跳转'
,
jumpParams
)
uni
.
navigateToMiniProgram
(
jumpParams
);
uni
.
navigateToMiniProgram
(
jumpParams
);
}
}
break
;
break
;
...
@@ -60,11 +92,11 @@ export function jump({ type, url, extra = {} }) {
...
@@ -60,11 +92,11 @@ export function jump({ type, url, extra = {} }) {
}
}
}
}
export
function
formatDate
(
timestamp
){
export
function
formatDate
(
timestamp
)
{
const
date
=
new
Date
(
timestamp
);
const
date
=
new
Date
(
timestamp
);
if
(
isNaN
(
date
.
getTime
()))
{
if
(
isNaN
(
date
.
getTime
()))
{
console
.
error
(
'无效的时间戳:'
,
timestamp
);
console
.
error
(
'无效的时间戳:'
,
timestamp
);
return
''
;
return
''
;
}
}
const
year
=
date
.
getFullYear
()
const
year
=
date
.
getFullYear
()
...
@@ -136,7 +168,7 @@ export function hideLoading() {
...
@@ -136,7 +168,7 @@ export function hideLoading() {
* @param format 字符串,需要的格式例如:'yyyy/MM/dd hh:mm:ss'
* @param format 字符串,需要的格式例如:'yyyy/MM/dd hh:mm:ss'
* @returns {String}
* @returns {String}
*/
*/
const
dateFormatter
=
(
date
,
format
=
"yyyy/MM/dd"
)
=>
{
const
dateFormatter
=
(
date
,
format
=
"yyyy/MM/dd"
)
=>
{
if
(
!
date
)
return
"-"
;
if
(
!
date
)
return
"-"
;
date
=
new
Date
(
date
=
new
Date
(
typeof
date
===
"string"
&&
isNaN
(
date
)
typeof
date
===
"string"
&&
isNaN
(
date
)
...
@@ -169,5 +201,5 @@ export function hideLoading() {
...
@@ -169,5 +201,5 @@ export function hideLoading() {
return
format
;
return
format
;
};
};
export
{
export
{
dateFormatter
dateFormatter
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment