Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
J
jd-vx-app
Project
Project
Details
Activity
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
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
Administrator
jd-vx-app
Commits
d1c04132
Commit
d1c04132
authored
Apr 17, 2024
by
肖健
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新js
parent
d36ebe78
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
142 additions
and
618 deletions
+142
-618
fm.min.js
pages/login/fm.min.js
+1
-424
util.js
pages/login/util.js
+141
-194
No files found.
pages/login/fm.min.js
View file @
d1c04132
This diff is collapsed.
Click to expand it.
pages/login/util.js
View file @
d1c04132
let
plugin
=
requirePlugin
(
'loginPlugin'
);
let
plugin
=
requirePlugin
(
"loginPlugin"
);
(
function
()
{
(
function
()
{
if
(
console
.
jdLoginLog
)
{
if
(
console
.
jdLoginLog
)
return
return
;
}
let
normalLog
=
console
.
log
;
let
normalLog
=
console
.
log
;
console
.
jdLoginLog
=
(...
args
)
=>
{
console
.
jdLoginLog
=
(...
args
)
=>
{
args
.
unshift
(
'-------登录插件-------'
);
args
.
unshift
(
'-------登录插件-------'
)
if
(
normalLog
)
{
normalLog
&&
normalLog
(...
args
);
normalLog
(...
args
);
}
}
};
})()
})();
const
utils
=
{
const
utils
=
{
redirectPage
(
url
)
{
redirectPage
(
url
)
{
uni
.
redirectTo
({
wx
.
redirectTo
({
url
url
});
});
},
},
redirectToH5
({
page
,
wvroute
})
{
redirectToH5
({
page
,
wvroute
})
{
let
url
=
plugin
.
formH5Url
({
let
url
=
plugin
.
formH5Url
({
page
:
decodeURIComponent
(
page
),
wvroute
})
page
:
decodeURIComponent
(
page
),
utils
.
redirectPage
(
url
)
wvroute
});
utils
.
redirectPage
(
url
);
},
},
navigateToH5
({
page
,
wvroute
})
{
navigateToH5
({
page
,
wvroute
})
{
let
url
=
plugin
.
formH5Url
({
let
url
=
plugin
.
formH5Url
({
page
:
decodeURIComponent
(
page
),
wvroute
})
page
:
decodeURIComponent
(
page
),
wx
.
navigateTo
({
url
})
wvroute
});
uni
.
navigateTo
({
url
});
},
},
setLoginParamsStorage
(
obj
=
{})
{
setLoginParamsStorage
(
obj
=
{})
{
if
(
obj
.
appid
&&
isNaN
(
Number
(
obj
.
appid
)))
{
if
(
obj
.
appid
&&
isNaN
(
Number
(
obj
.
appid
)))
{
delete
obj
.
appid
;
delete
obj
.
appid
}
}
plugin
.
setLoginStorageSync
(
utils
.
getLoginConfig
(
obj
));
plugin
.
setLoginStorageSync
(
utils
.
getLoginConfig
(
obj
));
},
},
...
@@ -45,157 +35,114 @@ const utils = {
...
@@ -45,157 +35,114 @@ const utils = {
*/
*/
getLoginConfig
(
obj
=
{})
{
getLoginConfig
(
obj
=
{})
{
//兼容缓存中有returnPage, 传递的参数中无,塞缓存时会用缓存中的值,导致不匹配
//兼容缓存中有returnPage, 传递的参数中无,塞缓存时会用缓存中的值,导致不匹配
const
handleUndefinedType
=
(
o
=
{})
=>
{
const
handleUndefinedType
=
(
o
=
{})
=>
{
let
{
pageType
=
'redirectTo'
}
=
o
;
let
{
pageType
=
'redirectTo'
}
=
o
o
.
pageType
=
pageType
;
o
.
pageType
=
pageType
;
return
o
;
return
o
};
}
let
storageConfig
=
plugin
.
getLoginParams
();
let
storageConfig
=
plugin
.
getLoginParams
();
let
config
=
handleUndefinedType
(
utils
.
getDefaultConfig
());
let
config
=
handleUndefinedType
(
utils
.
getDefaultConfig
());
let
loginParams
=
{
let
loginParams
=
{
...
storageConfig
,
...
config
};
...
storageConfig
,
...
config
};
if
(
plugin
.
isObject
(
obj
))
{
if
(
plugin
.
isObject
(
obj
))
{
loginParams
=
{
loginParams
=
{
...
loginParams
,
...
handleUndefinedType
(
obj
)
}
...
loginParams
,
...
handleUndefinedType
(
obj
)
};
}
else
{
}
else
{
console
.
jdLoginLog
(
'登录参数必须为对象'
);
console
.
jdLoginLog
(
'登录参数必须为对象'
)
}
}
return
loginParams
;
return
loginParams
},
},
getDefaultConfig
()
{
getDefaultConfig
()
{
let
lgConfig
;
let
lgConfig
;
try
{
try
{
lgConfig
=
require
(
'./config.js'
);
lgConfig
=
require
(
"./config.js"
);
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
'CatchClause'
,
err
);
console
.
log
(
'CatchClause'
,
err
);
lgConfig
=
{};
lgConfig
=
{};
}
}
return
lgConfig
.
config
||
{};
return
lgConfig
.
config
||
{}
},
},
handleJump
(
p
=
{})
{
handleJump
(
p
=
{})
{
let
{
goback
,
pluginUrl
,
riskUrl
}
=
p
;
let
{
goback
,
pluginUrl
,
riskUrl
}
=
p
;
if
(
goback
)
{
if
(
goback
)
{
utils
.
goBack
();
utils
.
goBack
();
return
;
return
}
}
if
(
pluginUrl
)
{
if
(
pluginUrl
)
{
utils
.
redirectPage
(
pluginUrl
);
utils
.
redirectPage
(
pluginUrl
);
return
;
return
}
if
(
riskUrl
)
{
utils
.
redirectToH5
({
page
:
riskUrl
});
}
}
riskUrl
&&
utils
.
redirectToH5
({
page
:
riskUrl
})
},
},
goBack
()
{
goBack
()
{
let
params
=
plugin
.
getLoginParams
();
let
params
=
plugin
.
getLoginParams
(),
let
{
returnPage
,
pageType
}
=
params
;
{
returnPage
,
pageType
}
=
params
;
if
(
pageType
==
'navigateBack'
)
{
if
(
pageType
==
'navigateBack'
)
{
uni
[
pageType
]();
wx
[
pageType
]();
return
;
return
;
}
}
if
(
!
returnPage
)
{
if
(
!
returnPage
)
{
uni
.
showToast
({
wx
.
showToast
({
title
:
'没有returnPage,无法跳转'
,
title
:
'没有returnPage,无法跳转'
,
icon
:
'none'
icon
:
'none'
});
})
return
;
return
}
}
if
(
pageType
!==
'h5'
)
{
if
(
pageType
!==
'h5'
)
{
returnPage
=
decodeURIComponent
(
returnPage
);
returnPage
=
decodeURIComponent
(
returnPage
);
if
(
pageType
&&
pageType
!=
'rediretTo'
)
{
if
(
pageType
&&
pageType
!=
'rediretTo'
){
uni
[
pageType
]({
wx
[
pageType
]({
url
:
returnPage
})
url
:
returnPage
}
else
{
});
utils
.
redirectPage
(
returnPage
)
}
else
{
utils
.
redirectPage
(
returnPage
);
}
}
return
;
return
;
}
else
{
}
else
{
utils
.
redirectToH5
({
utils
.
redirectToH5
({
page
:
returnPage
})
page
:
returnPage
});
return
;
return
;
}
}
},
},
h5Init
(
options
)
{
h5Init
(
options
)
{
let
p
=
plugin
.
getLoginParams
();
let
p
=
plugin
.
getLoginParams
();
if
(
plugin
.
isEmptyObj
(
p
))
{
if
(
plugin
.
isEmptyObj
(
p
))
utils
.
setLoginParamsStorage
(
options
)
utils
.
setLoginParamsStorage
(
options
);
}
},
},
setCustomNavigation
()
{
setCustomNavigation
()
{
let
{
navigationBarColor
,
navigationBarTitle
}
=
plugin
.
getLoginParams
();
let
{
navigationBarColor
,
navigationBarTitle
}
=
plugin
.
getLoginParams
();
if
(
plugin
.
isObject
(
navigationBarColor
))
{
plugin
.
isObject
(
navigationBarColor
)
&&
wx
.
setNavigationBarColor
(
navigationBarColor
);
uni
.
setNavigationBarColor
(
navigationBarColor
);
plugin
.
isObject
(
navigationBarTitle
)
&&
wx
.
setNavigationBarTitle
(
navigationBarTitle
);
}
if
(
plugin
.
isObject
(
navigationBarTitle
))
{
uni
.
setNavigationBarTitle
(
navigationBarTitle
);
}
},
},
requestWithLoginStatus
(
obj
=
{})
{
requestWithLoginStatus
(
obj
=
{})
{
obj
.
header
=
obj
.
header
||
{};
obj
.
header
=
obj
.
header
||
{};
let
[
GUID
=
''
,
KEY
=
''
,
TOKEN
=
''
,
PIN
=
''
]
=
plugin
.
getJdListStorage
([
'guid'
,
'pt_key'
,
'pt_token'
,
'pt_pin'
]);
let
[
GUID
=
''
,
KEY
=
''
,
TOKEN
=
''
,
PIN
=
''
]
=
plugin
.
getJdListStorage
([
'guid'
,
'pt_key'
,
'pt_token'
,
'pt_pin'
]),
let
_cookie
=
`guid=
${
GUID
}
; pt_pin=
${
encodeURIComponent
(
PIN
)}
; pt_key=
${
KEY
}
; pt_token=
${
TOKEN
}
`
;
_cookie
=
`guid=
${
GUID
}
; pt_pin=
${
encodeURIComponent
(
PIN
)}
; pt_key=
${
KEY
}
; pt_token=
${
TOKEN
}
`
,
let
{
cookie
}
=
obj
.
header
;
{
cookie
}
=
obj
.
header
;
obj
.
header
.
cookie
=
cookie
?
`
${
cookie
}
;
${
_cookie
}
`
:
_cookie
;
obj
.
header
.
cookie
=
cookie
?
`
${
cookie
}
;
${
_cookie
}
`
:
_cookie
;
uni
.
request
(
obj
);
wx
.
request
(
obj
)
},
},
silentauthlogin
(
options
,
goToLogin
,
callback
)
{
silentauthlogin
(
options
,
goToLogin
,
callback
)
{
uni
.
login
({
wx
.
login
({
success
(
res
=
{})
{
success
(
res
=
{})
{
let
{
code
}
=
res
;
let
{
code
}
=
res
;
if
(
code
)
{
if
(
code
)
{
utils
.
setLoginParamsStorage
(
options
);
utils
.
setLoginParamsStorage
(
options
);
plugin
plugin
.
silentauthlogin
({
...
options
,
code
},
goToLogin
)
.
silentauthlogin
(
{
...
options
,
code
},
goToLogin
)
.
then
((
res
)
=>
{
.
then
((
res
)
=>
{
if
(
callback
)
{
callback
&&
callback
({
isSuccess
:
res
.
err_code
==
0
});
callback
({
if
(
goToLogin
&&
res
.
err_code
==
0
){
isSuccess
:
res
.
err_code
==
0
utils
.
handleJump
(
res
)
});
}
if
(
goToLogin
&&
res
.
err_code
==
0
)
{
utils
.
handleJump
(
res
);
}
}
})
})
.
catch
((
res
)
=>
{
.
catch
((
res
)
=>
{
if
(
callback
)
{
callback
&&
callback
({
isSuccess
:
false
});
callback
({
isSuccess
:
false
});
}
console
.
jdLoginLog
(
'请重试一次'
);
console
.
jdLoginLog
(
'请重试一次'
);
});
});
}
else
{
}
else
{
if
(
callback
)
{
callback
&&
callback
({
isSuccess
:
false
});
callback
({
isSuccess
:
false
});
}
console
.
jdLoginLog
(
'wx.login 获取code失败'
);
console
.
jdLoginLog
(
'wx.login 获取code失败'
);
}
}
},
},
fail
()
{
fail
()
{
if
(
callback
)
{
callback
&&
callback
({
isSuccess
:
false
});
callback
({
},
isSuccess
:
false
});
}
}
});
});
}
}
};
}
export
default
utils
;
export
default
utils
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