Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
GaoQuYingJiH5-ASD
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xinzhedeai
GaoQuYingJiH5-ASD
Commits
fe84681d
Commit
fe84681d
authored
Jun 19, 2025
by
xinzhedeai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 代码格式修改; 首页加载顺序代码重构promise
parent
504bc6ea
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
198 additions
and
243 deletions
+198
-243
home.css
home.css
+2
-1
home.html
home.html
+103
-113
home.js
home.js
+38
-74
index.js
sdk/jssdk2/index.js
+55
-55
No files found.
home.css
View file @
fe84681d
...
...
@@ -452,4 +452,5 @@ border-right: 1px solid #eee; */
font-size
:
0.28rem
;
color
:
#333333
;
line-height
:
1.2
;
}
\ No newline at end of file
}
home.html
View file @
fe84681d
This diff is collapsed.
Click to expand it.
home.js
View file @
fe84681d
...
...
@@ -6,6 +6,7 @@ window.onload = function () {
el
:
'
#app
'
,
data
()
{
return
{
isLoading
:
true
,
// 新增:加载状态标记
showPopup4completionDate
:
false
,
// 控制日期选择器弹窗的显示与隐藏
showPicker
:
false
,
...
...
@@ -19,19 +20,18 @@ window.onload = function () {
// maxDate: new Date(new Date().getFullYear() + 10, 11),
maxDate
:
new
Date
(),
userInfo
:
{
userType
:
'
sj1
'
,
// 登录用户type
userType
:
'
consumers
'
,
// 登录用户type
userType
:
''
,
// 登录用户type
userId
:
'
1
'
,
// 登录用户id
userName
:
'
张三
'
,
// 登录用户name
userName
:
''
,
// 登录用户name
deptId
:
'
1
'
,
// 登录用户部门id
deptName
:
'
部门1
'
,
// 登录用户部门name
deptName
:
''
,
// 登录用户部门name
safeLevel
:
'
0
'
,
//0:绿、1:黄、2:红
role
:
'
dudao
'
,
role
:
''
,
roleName
:
''
,
},
showOrg
:
false
,
//是否显示组织
showShop
:
false
,
//是否显示店铺
// 修改默认菜单结构为最小化配置
menuList
:
[],
// 初始化为空数组,等待接口数据填充
...
...
@@ -41,8 +41,6 @@ window.onload = function () {
hiddenCount
:
0
,
//隐患数
hiddenNoReCount
:
0
,
//未整改数
},
page
:
1
,
// 页码
size
:
10
,
// 每页显示的数量
accessType
:
'
manage
'
,
// 访问类型 shop商家 saoma 扫码 manage 管理
remindStatistic
:
[]
}
...
...
@@ -156,11 +154,11 @@ window.onload = function () {
let
url
=
gemhoUtil
.
setParameter
(
`src/_
${
stringifyUrl
}
.html`
)
gemhoUtil
.
navigatePage
(
url
,
'
跳转中...
'
)
},
init
()
{
async
init
()
{
// 在组件挂载后执行
// 调用你的方法
this
.
getUserInfo
()
this
.
getUserData
()
await
this
.
getUserInfo
();
await
this
.
getStatisticData
();
this
.
isLoading
=
false
;
// 数据加载完成后关闭加载状态
},
showPopup
()
{
this
[
'
showPopup4completionDate
'
]
=
true
...
...
@@ -169,7 +167,7 @@ window.onload = function () {
this
.
selectedDate
=
gemhoUtil
.
getTargetDateYMByPara
(
value
)
this
.
showDate
=
gemhoUtil
.
getTargetDateYMByPara
(
value
)
this
.
showPopup4completionDate
=
false
this
.
get
User
Data
()
this
.
get
Statistic
Data
()
},
// 格式化日期显示的函数,根据需要自定义
...
...
@@ -186,37 +184,20 @@ window.onload = function () {
this
.
showPicker
=
false
},
getUserInfo
()
{
vant
.
Toast
.
loading
({
message
:
'
正在加载...
'
,
forbidClick
:
true
,
loadingType
:
'
spinner
'
,
})
setTimeout
(()
=>
{
http2
.
post
(
{
serviceId
:
API_KEY_MAP
[
'
no-page
'
][
'
id
'
],
interfacePublicKey
:
API_KEY_MAP
[
'
no-page
'
][
'
publicKey
'
],
interfacePrivateKey
:
API_KEY_MAP
[
'
no-page
'
][
'
privateKey
'
],
reqParams
:
{
sign
:
9
,
pageNum
:
this
.
page
++
,
// 每次请求增加下一页
pageSize
:
this
.
size
,
sort
:
'
lawId,desc
'
,
},
return
new
Promise
((
resolve
)
=>
{
http2
.
post
({
serviceId
:
API_KEY_MAP
[
'
no-page
'
][
'
id
'
],
interfacePublicKey
:
API_KEY_MAP
[
'
no-page
'
][
'
publicKey
'
],
interfacePrivateKey
:
API_KEY_MAP
[
'
no-page
'
][
'
privateKey
'
],
reqParams
:
{
sign
:
9
,
},
},
(
res
)
=>
{
console
.
log
(
JSON
.
parse
(
res
),
'
JSON.parse(res)
'
)
if
(
!
res
)
{
// 中台返回为undefined 重新请求
vant
.
Toast
.
clear
()
setTimeout
(()
=>
{
this
.
getUserInfo
()
},
0
)
return
}
if
(
res
)
{
var
result
=
JSON
.
parse
(
res
)
if
(
result
.
code
!==
200
&&
result
.
data
==
null
)
{
console
.
log
(
'
getUserInfo=>code200datanull
'
)
return
}
this
.
userInfo
=
{
...
...
@@ -250,52 +231,35 @@ window.onload = function () {
console
.
log
(
'
菜单
'
,
result
.
data
.
modules
)
// 生成最终菜单列表
this
.
menuList
=
result
.
data
.
modules
resolve
();
}
setTimeout
(()
=>
{
this
.
$nextTick
(()
=>
{
vant
.
Toast
.
clear
()
})
},
0
)
}
)
},
0
)
})
});
},
// 获取用户数据的方法
getUserData
()
{
vant
.
Toast
.
loading
({
message
:
'
正在加载...
'
,
forbidClick
:
true
,
loadingType
:
'
spinner
'
,
})
setTimeout
(()
=>
{
http2
.
post
(
{
serviceId
:
API_KEY_MAP
[
'
no-page
'
][
'
id
'
],
interfacePublicKey
:
API_KEY_MAP
[
'
no-page
'
][
'
publicKey
'
],
interfacePrivateKey
:
API_KEY_MAP
[
'
no-page
'
][
'
privateKey
'
],
reqParams
:
{
sign
:
6
,
date
:
this
.
selectedDate
,
merId
:
gemhoUtil
.
getParameter
(
'
merId
'
),
},
getStatisticData
()
{
return
new
Promise
((
resolve
)
=>
{
http2
.
post
({
serviceId
:
API_KEY_MAP
[
'
no-page
'
][
'
id
'
],
interfacePublicKey
:
API_KEY_MAP
[
'
no-page
'
][
'
publicKey
'
],
interfacePrivateKey
:
API_KEY_MAP
[
'
no-page
'
][
'
privateKey
'
],
reqParams
:
{
sign
:
6
,
date
:
this
.
selectedDate
,
merId
:
gemhoUtil
.
getParameter
(
'
merId
'
)
||
''
,
},
},
(
res
)
=>
{
if
(
!
res
)
{
// 中台返回为undefined 重新请求
vant
.
Toast
.
clear
()
setTimeout
(()
=>
{
this
.
getUserData
()
},
0
)
return
}
if
(
res
)
{
var
result
=
JSON
.
parse
(
res
)
console
.
log
(
'
用户Data
'
)
this
.
userData
=
result
.
data
resolve
();
}
}
)
}
,
0
)
}
,
}
);
}
},
//过滤器
filters
:
{
...
...
sdk/jssdk2/index.js
View file @
fe84681d
...
...
@@ -13,35 +13,35 @@ window.onload = function () {
}
else
{
let
accessType
=
gemhoUtil
.
getParameter
(
'
accessType
'
)
if
(
accessType
==
'
saoma
'
)
{
let
param
=
{
accessType
:
accessType
,
merId
:
gemhoUtil
.
getParameter
(
'
merId
'
)
}
// 2025年5月30日08:45:33 添加消费者访问逻辑
console
.
log
(
'
userType
'
,
gemhoUtil
.
getCookie
(
'
userType
'
)
==
'
consumers
'
)
var
url
=
''
if
(
gemhoUtil
.
getCookie
(
'
userType
'
)
==
'
consumers
'
)
{
url
=
gemhoUtil
.
setParameter
(
`./src/_consumer_home.html`
,
param
)
}
else
{
// 非消费者
url
=
gemhoUtil
.
setParameter
(
`./src/_shanghu_home.html`
,
param
)
}
console
.
log
(
'
userType-url
'
,
url
)
gemhoUtil
.
navigatePage
(
url
,
'
跳转中...
'
)
let
param
=
{
accessType
:
accessType
,
merId
:
gemhoUtil
.
getParameter
(
'
merId
'
)
}
// 2025年5月30日08:45:33 添加消费者访问逻辑
console
.
log
(
'
userType
'
,
gemhoUtil
.
getCookie
(
'
userType
'
)
==
'
consumers
'
)
var
url
=
''
if
(
gemhoUtil
.
getCookie
(
'
userType
'
)
==
'
consumers
'
)
{
url
=
gemhoUtil
.
setParameter
(
`./src/_consumer_home.html`
,
param
)
}
else
{
// 非消费者
url
=
gemhoUtil
.
setParameter
(
`./src/_shanghu_home.html`
,
param
)
}
console
.
log
(
'
userType-url
'
,
url
)
gemhoUtil
.
navigatePage
(
url
,
'
跳转中...
'
)
}
else
{
if
(
gemhoUtil
.
getCookie
(
'
userType
'
)
==
'
consumers
'
)
{
vant
.
Dialog
.
alert
({
title
:
'
信息提示
'
,
message
:
'
请扫描商户码访问~
'
,
}).
then
(()
=>
{
// 关闭当前访问页面回到爱山东
lightAppJssdk
.
navigation
.
close
({
success
:
function
(
data
)
{
},
fail
:
function
(
data
)
{
},
})
});
}
else
{
gemhoUtil
.
navigatePage
(
'
home.html
'
,
'
跳转中...
'
)
}
if
(
gemhoUtil
.
getCookie
(
'
userType
'
)
==
'
consumers
'
)
{
vant
.
Dialog
.
alert
({
title
:
'
信息提示
'
,
message
:
'
请扫描商户码访问~
'
,
}).
then
(()
=>
{
// 关闭当前访问页面回到爱山东
lightAppJssdk
.
navigation
.
close
({
success
:
function
(
data
)
{
},
fail
:
function
(
data
)
{
},
})
});
}
else
{
gemhoUtil
.
navigatePage
(
'
home.html
'
,
'
跳转中...
'
)
}
}
}
}
...
...
@@ -121,33 +121,33 @@ function getUserInfo() {
// localStorage.setItem('token', result.token)
if
(
result
.
code
==
200
)
{
gemhoUtil
.
setCookie
(
'
token
'
,
result
.
token
,
1
)
// 存储1天后过期
// 2025-5-30 08:54:47 新增消费者判断逻辑
// gemhoUtil.setCookie('userType', 'consumers') // 存储1天后过期
gemhoUtil
.
setCookie
(
'
userType
'
,
result
.
userType
)
// 存储1天后过期
if
(
gemhoUtil
.
getCookie
(
'
userType
'
)
==
'
consumers
'
)
{
let
merId
=
gemhoUtil
.
getParameter
(
'
merId
'
)
if
(
!
merId
)
{
vant
.
Dialog
.
alert
({
title
:
'
信息提示
'
,
message
:
'
请扫描商户码访问~
'
,
}).
then
(()
=>
{
// 关闭当前访问页面回到爱山东
lightAppJssdk
.
navigation
.
close
({
success
:
function
(
data
)
{
},
fail
:
function
(
data
)
{
},
})
});
return
}
// 消费者扫码访问 添加逻辑 merId传参
let
param
=
{
merId
}
let
url
=
gemhoUtil
.
setParameter
(
`src/_consumer_home.html`
,
param
)
gemhoUtil
.
navigatePage
(
url
,
'
跳转中...
'
)
return
}
// 2025-5-30 08:54:47 新增消费者判断逻辑
// gemhoUtil.setCookie('userType', 'consumers') // 存储1天后过期
gemhoUtil
.
setCookie
(
'
userType
'
,
result
.
userType
)
// 存储1天后过期
if
(
gemhoUtil
.
getCookie
(
'
userType
'
)
==
'
consumers
'
)
{
let
merId
=
gemhoUtil
.
getParameter
(
'
merId
'
)
if
(
!
merId
)
{
vant
.
Dialog
.
alert
({
title
:
'
信息提示
'
,
message
:
'
请扫描商户码访问~
'
,
}).
then
(()
=>
{
// 关闭当前访问页面回到爱山东
lightAppJssdk
.
navigation
.
close
({
success
:
function
(
data
)
{
},
fail
:
function
(
data
)
{
},
})
});
return
}
// 消费者扫码访问 添加逻辑 merId传参
let
param
=
{
merId
}
let
url
=
gemhoUtil
.
setParameter
(
`src/_consumer_home.html`
,
param
)
gemhoUtil
.
navigatePage
(
url
,
'
跳转中...
'
)
return
}
gemhoUtil
.
navigatePage
(
'
home.html
'
,
'
跳转中...
'
)
}
else
{
vant
.
Dialog
.
alert
({
...
...
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