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
2372d2b0
Commit
2372d2b0
authored
Apr 11, 2025
by
lei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add:固定token
parent
6a8a586a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
114 additions
and
111 deletions
+114
-111
index.html
index.html
+4
-1
index.js
index.js
+3
-1
http.js
sdk/http.js
+4
-4
index.js
sdk/jssdk2/index.js
+103
-105
No files found.
index.html
View file @
2372d2b0
...
@@ -29,7 +29,10 @@
...
@@ -29,7 +29,10 @@
<body>
<body>
<!-- 获取授权用户信息 本地token等操作 -->
<!-- 获取授权用户信息 本地token等操作 -->
<!-- <script type="text/javascript" src="sdk/jssdk2/index.js"></script> -->
<script
type=
"text/javascript"
src=
"sdk/jssdk2/index.js"
></script>
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
gemhoUtil
.
setCookie
(
gemhoUtil
.
setCookie
(
'
token
'
,
'
token
'
,
...
...
index.js
View file @
2372d2b0
...
@@ -94,6 +94,8 @@ window.onload = function () {
...
@@ -94,6 +94,8 @@ window.onload = function () {
hiddenCount
:
0
,
//隐患数
hiddenCount
:
0
,
//隐患数
hiddenNoReCount
:
0
,
//未整改数
hiddenNoReCount
:
0
,
//未整改数
},
},
page
:
1
,
// 页码
size
:
10
,
// 每页显示的数量
}
}
},
},
mounted
()
{
mounted
()
{
...
@@ -174,7 +176,7 @@ window.onload = function () {
...
@@ -174,7 +176,7 @@ window.onload = function () {
interfacePublicKey
:
API_KEY_MAP
[
'
no-page
'
][
'
publicKey
'
],
interfacePublicKey
:
API_KEY_MAP
[
'
no-page
'
][
'
publicKey
'
],
interfacePrivateKey
:
API_KEY_MAP
[
'
no-page
'
][
'
privateKey
'
],
interfacePrivateKey
:
API_KEY_MAP
[
'
no-page
'
][
'
privateKey
'
],
reqParams
:
{
reqParams
:
{
sign
:
'
9
'
,
sign
:
1
,
pageNum
:
this
.
page
++
,
// 每次请求增加下一页
pageNum
:
this
.
page
++
,
// 每次请求增加下一页
pageSize
:
this
.
size
,
pageSize
:
this
.
size
,
...
...
sdk/http.js
View file @
2372d2b0
...
@@ -23,8 +23,8 @@ var http2 = {
...
@@ -23,8 +23,8 @@ var http2 = {
JSON
.
stringify
(
params
.
reqParams
),
JSON
.
stringify
(
params
.
reqParams
),
params
.
interfacePublicKey
params
.
interfacePublicKey
)
)
//
console.log('http请求普通参数前', params.reqParams)
console
.
log
(
'
http请求普通参数前
'
,
params
.
reqParams
)
//
console.log('http请求参数加密后', data)
console
.
log
(
'
http请求参数加密后
'
,
data
)
const
extraData
=
{
const
extraData
=
{
// 公共请求头设置
// 公共请求头设置
// header: {
// header: {
...
@@ -49,8 +49,8 @@ var http2 = {
...
@@ -49,8 +49,8 @@ var http2 = {
// 用于接口传递的额外参数 如文件流等){
// 用于接口传递的额外参数 如文件流等){
extraData
.
fileList
=
params
.
fileList
extraData
.
fileList
=
params
.
fileList
}
}
//
console.log('http请求额外参数', JSON.stringify(extraData))
console
.
log
(
'
http请求额外参数
'
,
JSON
.
stringify
(
extraData
))
//
console.log('http2方法进来了~extraData', extraData)
console
.
log
(
'
http2方法进来了~extraData
'
,
extraData
)
// vaildInterfacefn("gqyjglptxiefn", params.serviceId, data, "1", "https://" + urldomaincreatesign, "https://" + urldomaingateway).then((value) => {
// vaildInterfacefn("gqyjglptxiefn", params.serviceId, data, "1", "https://" + urldomaincreatesign, "https://" + urldomaingateway).then((value) => {
vaildInterfacefn
(
vaildInterfacefn
(
...
...
sdk/jssdk2/index.js
View file @
2372d2b0
const
appword
=
"
aKd20dbGdFvmuwrt
"
// 固定值
const
appword
=
'
aKd20dbGdFvmuwrt
'
// 固定值
window
.
onload
=
function
()
{
window
.
onload
=
function
()
{
// vant.Toast.loading({
// vant.Toast.loading({
// message: '加载中...',
// message: '加载中...',
// forbidClick: true,
// forbidClick: true,
// loadingType: 'spinner',
// loadingType: 'spinner',
// });
// });
// if(!localStorage.getItem('token')){
// if(!localStorage.getItem('token')){
if
(
!
gemhoUtil
.
getCookie
(
'
token
'
)){
if
(
!
gemhoUtil
.
getCookie
(
'
token
'
))
{
getUserInfo
()
getUserInfo
()
}
}
}
}
function
getUserInfo
()
{
function
getUserInfo
()
{
vant
.
Toast
.
loading
({
vant
.
Toast
.
loading
({
message
:
'
授权中...
'
,
message
:
'
授权中...
'
,
forbidClick
:
true
,
forbidClick
:
true
,
loadingType
:
'
spinner
'
,
loadingType
:
'
spinner
'
,
});
})
lightAppJssdk
.
user
.
getUserInfoWithEncryptedParamByAppId
({
lightAppJssdk
.
user
.
getUserInfoWithEncryptedParamByAppId
({
appId
:
"
whsdsjzxsfrzdjqwsczptsr
"
,
//"gqyjglptxiefn", // 接入方在成功创建应用后自动生成
appId
:
'
gqyjglptxiefn
'
,
//"gqyjglptxiefn", // 接入方在成功创建应用后自动生成
success
:
async
(
data
)
=>
{
success
:
async
(
data
)
=>
{
if
(
data
==
'
未登录
'
)
onLoginApp
()
if
(
data
==
'
未登录
'
)
onLoginApp
()
else
{
else
{
// 2025-1-14 新增逻辑:获取用户票据,用于后续接口传参使用
// 2025-1-14 新增逻辑:获取用户票据,用于后续接口传参使用
const
ticketInfo
=
await
getTicket
()
const
ticketInfo
=
await
getTicket
()
if
(
ticketInfo
.
ticket
){
if
(
ticketInfo
.
ticket
)
{
gemhoUtil
.
setCookie
(
'
ticket
'
,
ticketInfo
.
ticket
)
gemhoUtil
.
setCookie
(
'
ticket
'
,
ticketInfo
.
ticket
)
}
else
{
}
else
{
vant
.
Dialog
.
alert
({
vant
.
Dialog
.
alert
({
title
:
'
信息提示
'
,
title
:
'
信息提示
'
,
message
:
'
未获取到用户票据信息
'
message
:
'
未获取到用户票据信息
'
,
})
})
return
return
}
}
if
(
typeof
data
==
'
string
'
)
if
(
typeof
data
==
'
string
'
)
data
=
JSON
.
parse
(
data
)
data
=
JSON
.
parse
(
data
)
// console.log('用户授权请求成功的数据', data)
// console.log('用户授权请求成功的数据', data)
// 对于该方法的返回结果,需要进行两步解密才能得到明文用户信息,
// 对于该方法的返回结果,需要进行两步解密才能得到明文用户信息,
// 先对返回结果进行sm2解密,需要用到 接入方在创建应用时,选择应用的加密方式为sm2,并成功创建应用后,拿到的应用私钥来进行解密
// 先对返回结果进行sm2解密,需要用到 接入方在创建应用时,选择应用的加密方式为sm2,并成功创建应用后,拿到的应用私钥来进行解密
const
sm2_privateKey
=
'
145e8920d0ec9b60eaaa73a208e711a68e8aa614b786e45d3eb7eca850ba7843
'
const
sm2_privateKey
=
'
145e8920d0ec9b60eaaa73a208e711a68e8aa614b786e45d3eb7eca850ba7843
'
let
sm2_encrypt_result
=
data
.
data
let
sm2_encrypt_result
=
data
.
data
let
sm2_decrypt_result
=
sm2_Decrypt
(
sm2_encrypt_result
,
sm2_privateKey
)
let
sm2_decrypt_result
=
sm2_Decrypt
(
sm2_encrypt_result
,
sm2_privateKey
)
...
@@ -52,96 +51,95 @@ function getUserInfo() {
...
@@ -52,96 +51,95 @@ function getUserInfo() {
// aes解密需要用到 appword , 为固定值,使用示例代码中的即可
// aes解密需要用到 appword , 为固定值,使用示例代码中的即可
let
aes_encrypt_result
=
sm2_decrypt_result
.
data
let
aes_encrypt_result
=
sm2_decrypt_result
.
data
let
aes_decrypt_result
=
aes_Decrypt
(
aes_encrypt_result
,
appword
)
let
aes_decrypt_result
=
aes_Decrypt
(
aes_encrypt_result
,
appword
)
if
(
!
aes_decrypt_result
){
if
(
!
aes_decrypt_result
)
{
// console.log('授权用户信息为空')
// console.log('授权用户信息为空')
return
return
}
}
let
tempResult
=
JSON
.
parse
(
aes_decrypt_result
)
let
tempResult
=
JSON
.
parse
(
aes_decrypt_result
)
// console.log('授权用户信息', tempResult)
// console.log('授权用户信息', tempResult)
let
reqParammm
=
{
let
reqParammm
=
{
sex
:
tempResult
.
sex
,
sex
:
tempResult
.
sex
,
mobile
:
tempResult
.
mobile
,
mobile
:
tempResult
.
mobile
,
name
:
tempResult
.
name
,
name
:
tempResult
.
name
,
loginname
:
tempResult
.
loginname
loginname
:
tempResult
.
loginname
,
// sex: 1,//aes_decrypt_result.sex,
// sex: 1,//aes_decrypt_result.sex,
// mobile: '18368232323',//aes_decrypt_result.mobile,
// mobile: '18368232323',//aes_decrypt_result.mobile,
// name: '123',// aes_decrypt_result.name,
// name: '123',// aes_decrypt_result.name,
// loginname: 'zjb'// aes_decrypt_result.loginname
// loginname: 'zjb'// aes_decrypt_result.loginname
}
}
// 请求获取高区应急后台真是token,传参,授权获取的用户信息
// 请求获取高区应急后台真是token,传参,授权获取的用户信息
http2
.
post
(
http2
.
post
({
{
serviceId
:
'
gqyjglptbind
'
,
serviceId
:
'
gqyjglptbind
'
,
interfacePublicKey
:
"
0450567ffc64139658baa28c5c9bc0415200b476baa3bcc3f9dc9dbbf8dbcff2fb5e93319127685469c84784d235220c0347e695fbf66c5ffede33e645bea8b3f0
"
,
interfacePublicKey
:
interfacePrivateKey
:
"
00b92f5f2a7c40cb07d225f2e90df9b8b23569658e4f9e04dd0a4bf4a5b374063b
"
,
'
0450567ffc64139658baa28c5c9bc0415200b476baa3bcc3f9dc9dbbf8dbcff2fb5e93319127685469c84784d235220c0347e695fbf66c5ffede33e645bea8b3f0
'
,
reqParams
:
reqParammm
interfacePrivateKey
:
},
function
(
res
){
'
00b92f5f2a7c40cb07d225f2e90df9b8b23569658e4f9e04dd0a4bf4a5b374063b
'
,
if
(
res
){
reqParams
:
reqParammm
,
// console.log('sdk2用户信息绑定接口回调数据', JSON.parse(res))
},
var
result
=
JSON
.
parse
(
res
)
function
(
res
)
{
// 存储后台返回token存储本地localstorage
if
(
res
)
{
// localStorage.setItem('token', result.token)
// console.log('sdk2用户信息绑定接口回调数据', JSON.parse(res))
gemhoUtil
.
setCookie
(
'
token
'
,
result
.
token
,
1
)
// 存储1天后过期
var
result
=
JSON
.
parse
(
res
)
}
// 存储后台返回token存储本地localstorage
vant
.
Toast
.
clear
()
// localStorage.setItem('token', result.token)
})
gemhoUtil
.
setCookie
(
'
token
'
,
result
.
token
,
1
)
// 存储1天后过期
}
vant
.
Toast
.
clear
()
}
)
}
}
},
},
fail
:
function
(
data
)
{
fail
:
function
(
data
)
{},
})
}
});
}
}
/**
/**
* 获取用户票据
* 获取用户票据
*/
*/
function
getTicket
(){
function
getTicket
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
lightAppJssdk
.
user
.
getTicketWithoutDialog
({
lightAppJssdk
.
user
.
getTicketWithoutDialog
({
success
:
function
(
res
)
{
success
:
function
(
res
)
{
//成功回调
//成功回调
console
.
log
(
JSON
.
stringify
(
res
)
+
1
)
console
.
log
(
JSON
.
stringify
(
res
)
+
1
)
var
jsonData
=
JSON
.
parse
(
res
)
var
jsonData
=
JSON
.
parse
(
res
)
if
(
jsonData
.
retcode
==
"
000000
"
)
{
if
(
jsonData
.
retcode
==
'
000000
'
)
{
var
dataValueObj
=
JSON
.
parse
(
jsonData
.
data
)
var
dataValueObj
=
JSON
.
parse
(
jsonData
.
data
)
// var ticket = dataValueObj.ticket //解析出用户票据信息
// var ticket = dataValueObj.ticket //解析出用户票据信息
// userType = dataValueObj.usertype //解析保存用户类型(个人法人)
// userType = dataValueObj.usertype //解析保存用户类型(个人法人)
// gemhoUtil.setCookie('ticket', ticket)
// gemhoUtil.setCookie('ticket', ticket)
resolve
(
dataValueObj
);
// 成功时调用 外层直接通过.ticket拿到票据值
resolve
(
dataValueObj
)
// 成功时调用 外层直接通过.ticket拿到票据值
}
else
{
}
else
{
resolve
(
jsonData
);
// 未获取到票据时,则直接返回响应对象,外层做逻辑处理
resolve
(
jsonData
)
// 未获取到票据时,则直接返回响应对象,外层做逻辑处理
}
}
},
},
fail
:
function
(
res
)
{
fail
:
function
(
res
)
{
//错误返回
//错误返回
console
.
log
(
JSON
.
stringify
(
res
))
console
.
log
(
JSON
.
stringify
(
res
))
resolve
(
res
);
// 成功时调用
resolve
(
res
)
// 成功时调用
}
},
})
})
})
});
}
}
/**
/**
* 使用jssdk调用登录页面
* 使用jssdk调用登录页面
*/
*/
function
onLoginApp
()
{
function
onLoginApp
()
{
lightAppJssdk
.
user
.
loginapp
({
lightAppJssdk
.
user
.
loginapp
({
success
:
function
(
data
)
{
success
:
function
(
data
)
{
if
(
data
==
"
未登录
"
)
{
if
(
data
==
'
未登录
'
)
{
//取消登录或登录失败,关闭页面
//取消登录或登录失败,关闭页面
oncloseWindow
()
oncloseWindow
()
}
else
{
}
else
{
getUserInfo
()
getUserInfo
()
}
}
},
},
fail
:
function
(
data
)
{
fail
:
function
(
data
)
{
//关闭页面
//关闭页面
oncloseWindow
()
oncloseWindow
()
}
}
,
})
})
}
}
...
@@ -150,8 +148,8 @@ function onLoginApp() {
...
@@ -150,8 +148,8 @@ function onLoginApp() {
*/
*/
function
oncloseWindow
()
{
function
oncloseWindow
()
{
lightAppJssdk
.
navigation
.
close
({
lightAppJssdk
.
navigation
.
close
({
success
:
function
(
data
)
{},
success
:
function
(
data
)
{},
fail
:
function
(
data
)
{}
fail
:
function
(
data
)
{},
})
})
}
}
...
@@ -162,7 +160,7 @@ function aes_Decrypt(word, key) {
...
@@ -162,7 +160,7 @@ function aes_Decrypt(word, key) {
var
str
=
CryptoJS
.
enc
.
Base64
.
stringify
(
srcs
)
//变为Base64编码的字符串
var
str
=
CryptoJS
.
enc
.
Base64
.
stringify
(
srcs
)
//变为Base64编码的字符串
var
decrypt
=
CryptoJS
.
AES
.
decrypt
(
str
,
key
,
{
var
decrypt
=
CryptoJS
.
AES
.
decrypt
(
str
,
key
,
{
mode
:
CryptoJS
.
mode
.
ECB
,
mode
:
CryptoJS
.
mode
.
ECB
,
spadding
:
CryptoJS
.
pad
.
Pkcs7
spadding
:
CryptoJS
.
pad
.
Pkcs7
,
})
})
return
decrypt
.
toString
(
CryptoJS
.
enc
.
Utf8
)
return
decrypt
.
toString
(
CryptoJS
.
enc
.
Utf8
)
}
}
...
@@ -170,4 +168,4 @@ function aes_Decrypt(word, key) {
...
@@ -170,4 +168,4 @@ function aes_Decrypt(word, key) {
// sm2解密,需要创建加密应用时的私钥
// sm2解密,需要创建加密应用时的私钥
function
sm2_Decrypt
(
word
,
key
)
{
function
sm2_Decrypt
(
word
,
key
)
{
return
SM
.
decrypt
(
word
,
key
)
return
SM
.
decrypt
(
word
,
key
)
}
}
\ 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