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
39b54803
Commit
39b54803
authored
Jun 05, 2023
by
肖健
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新京东登录插件到1.7.0
parent
fa17e386
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
281 additions
and
312 deletions
+281
-312
manifest.json
manifest.json
+1
-1
config.js
pages/login/config.js
+11
-16
fm.min.js
pages/login/fm.min.js
+123
-156
index.vue
pages/login/index/index.vue
+86
-76
util.js
pages/login/util.js
+50
-48
web-view.vue
pages/login/web-view/web-view.vue
+3
-6
wv-common.vue
pages/login/wv-common/wv-common.vue
+7
-9
No files found.
manifest.json
View file @
39b54803
...
...
@@ -74,7 +74,7 @@
},
"plugins"
:
{
"loginPlugin"
:
{
"version"
:
"1.
5.4
"
,
"version"
:
"1.
7.0
"
,
"provider"
:
"wxefe655223916819e"
}
}
...
...
pages/login/config.js
View file @
39b54803
...
...
@@ -17,22 +17,17 @@ export let config = {
// 埋点插件的名字 例如:'log-plugin'
selfTipsDialog
:
false
,
// 是否弹窗展示协议授权,默认为false,如果为true,author必须为false
author
:
true
,
hiddenLoginType
:
''
,
//隐藏按钮 1为 帐密方式;2为微信手机号快捷登录
// loginConfig: {
// jdLoginBtnStyle: 'color:red',
// // 登录/注册按钮样式
// wxBtnStyle: 'color:red',
// // 微信快捷登录按钮样式
// userPlaceholder: '',
// // 帐密登录的 placeholder
// loginBtnStyle: 'color:#fff',
// // 帐密登录界面登录按钮样式
// tabStyle: 'color:green',
// //帐密和手机号登录tab样式
// currentTabStyle: 'border-color:green' //帐密和手机号登录tab选中
// } // selfTips: [{ //无特殊需求不需要配置
author
:
true
// hiddenLoginType:'', //隐藏按钮 1为 帐密方式;2为微信手机号快捷登录
// loginConfig:{
// jdLoginBtnStyle: 'color:red', // 登录/注册按钮样式
// wxBtnStyle:'color:red', // 微信快捷登录按钮样式
// userPlaceholder:'', // 帐密登录的 placeholder
// loginBtnStyle: 'color:red', // 帐密登录界面登录按钮样式
// tabStyle:'color:green',//帐密和手机号登录tab样式
// currentTabStyle:'border-color:green'//帐密和手机号登录tab选中
// }
// selfTips: [{ //无特殊需求不需要配置
// tip:'我是测试1',
// url: 'm.jd.com'
// }, {
...
...
pages/login/fm.min.js
View file @
39b54803
This diff is collapsed.
Click to expand it.
pages/login/index/index.vue
View file @
39b54803
<
template
>
<
block
>
<index
@
smsloginres=
"smsloginResListener"
:config=
"config"
:checkboxChecked=
"checkboxChecked"
/>
<
view
style=
"height: 100%"
>
<index
@
s
howauthor=
"showLoad"
@
s
msloginres=
"smsloginResListener"
:config=
"config"
:checkboxChecked=
"checkboxChecked"
/>
<view
v-if=
"config.hiddenLoginType != 2"
>
<button
v-if=
"!stopClick && checkboxChecked"
...
...
@@ -15,13 +15,20 @@
<button
class=
"phone-btn"
:style=
"config.loginConfig && config.loginConfig.wxBtnStyle"
v-else
@
tap=
"needAuthor"
>
微信手机号快捷登录
</button>
</view>
<!-- 弹窗类型展示协议授权 -->
<view
class=
"dialog-tips"
v-if=
"
config.
selfTipsDialog"
>
<view
class=
"dialog-tips"
v-if=
"selfTipsDialog"
>
<view>
<instruction
class=
"no-fix"
:config=
"config"
@
changecheck=
"changeCheckbox"
/>
<p>
<button
class=
"phone-btn bg-btn"
@
tap=
"reject"
>
拒绝
</button>
<button
v-if=
"!stopClick && checkboxChecked"
class=
"phone-btn"
open-type=
"getPhoneNumber"
@
getphonenumber=
"getPhoneNumber"
>
同意
</button>
</p>
<instruction
class=
"no-fix"
type=
"modal"
:config=
"config"
@
changecheck=
"changeCheckbox"
/>
<button
v-if=
"smsBtn"
class=
"phone-btn phone-modal"
:style=
"config.loginConfig && config.loginConfig.wxBtnStyle"
open-type=
"getPhoneNumber"
@
getphonenumber=
"getPhoneNumber"
>
确认
</button>
<index
v-if=
"userBtn"
type=
"modal"
@
showauthor=
"showLoad"
@
smsloginres=
"smsloginResListener"
:config=
"config"
:checkboxChecked=
"true"
/>
<view
class=
"cancel"
@
tap=
"reject"
>
我再想想
</view>
</view>
</view>
<!-- 底部展示协议授权 -->
...
...
@@ -29,15 +36,13 @@
<view>
<canvas
class=
"f8be360ead1f4a3d9afb5e312b845ebb"
canvas-id=
"fbfd3ec3c4ab4213b9a09b5c5e769ceb"
></canvas>
</view>
</
block
>
</
view
>
</
template
>
<
script
>
import
util
from
'../util.js'
;
let
plugin
=
requirePlugin
(
'loginPlugin'
);
let
fm
=
require
(
'../fm.min.js'
);
let
config
=
util
.
getLoginConfig
();
export
default
{
components
:
{},
...
...
@@ -46,19 +51,24 @@ export default {
config
,
stopClick
:
false
,
checkboxChecked
:
!
config
.
author
,
selfTipsDialog
:
false
,
detail
:
''
,
code
:
''
,
userBtn
:
false
,
smsBtn
:
false
,
wxBtnStyle
:
''
};
},
onLoad
(
options
)
{
plugin
.
onLoginSuccess
((
data
)
=>
{
console
.
jdLoginLog
(
data
,
'登录成功'
);
});
let
{
riskFail
}
=
options
;
this
.
config
=
util
.
getLoginConfig
(
options
)
//风控失败不重置缓存
this
.
config
=
util
.
getLoginConfig
(
options
)
//风控失败不重置缓存
if
(
!
riskFail
)
{
util
.
setLoginParamsStorage
(
options
);
}
plugin
.
setLog
({
url
:
'pages/login/index/index'
,
pageId
:
'WLogin_Diversion'
...
...
@@ -72,34 +82,38 @@ export default {
},
methods
:
{
smsloginResListener
(
res
=
{})
{
if
(
this
.
checkboxChecked
)
{
if
(
this
.
checkboxChecked
||
this
.
userBtn
)
{
util
.
handleJump
(
res
.
detail
);
}
else
{
this
.
showLoad
();
this
.
showLoad
(
'useBtn'
);
}
},
showLoad
()
{
uni
.
showToast
({
title
:
'请阅读并勾选页面底部协议'
,
icon
:
'none'
,
duration
:
3000
});
showLoad
(
type
)
{
// wx.showToast({
// title: '请阅读并勾选页面底部协议',
// icon: "none",
// duration: 3000
// })
// if(type.detail){
// console.log(type.detail)
// }
this
.
selfTipsDialog
=
true
;
this
[
type
.
detail
||
type
]
=
true
;
},
changeCheckbox
(
e
)
{
this
.
checkboxChecked
=
e
.
detail
this
.
checkboxChecked
=
e
.
detail
;
},
needAuthor
()
{
if
(
!
this
.
checkboxChecked
)
{
this
.
showLoad
();
this
.
showLoad
(
'smsBtn'
);
}
},
getPhoneNumber
(
event
=
{})
{
let
{
stopClick
}
=
this
;
if
(
stopClick
)
{
uni
.
showToast
({
icon
:
'none'
,
...
...
@@ -107,24 +121,21 @@ export default {
});
return
;
}
this
.
stopClick
=
true
this
.
stopClick
=
true
;
let
{
detail
}
=
event
;
let
{
iv
,
encryptedData
}
=
detail
;
plugin
.
clickLog
({
event
,
eid
:
'WLogin_Diversion_Wechat'
});
if
(
!
iv
||
!
encryptedData
)
{
this
.
stopClick
=
false
this
.
stopClick
=
false
;
return
;
}
uni
.
showLoading
({
title
:
'加载中'
});
this
.
detail
=
detail
this
.
detail
=
detail
this
.
mobileLogin
();
plugin
.
clickLog
({
event
,
...
...
@@ -135,16 +146,13 @@ export default {
mobileLogin
()
{
let
{
code
,
detail
}
=
this
;
let
{
iv
,
encryptedData
}
=
detail
;
if
(
!
code
||
!
iv
||
!
encryptedData
)
{
return
;
}
const
startClick
=
()
=>
{
uni
.
hideLoading
();
this
.
stopClick
=
false
this
.
stopClick
=
false
};
plugin
.
WXMobileLogin
({
iv
,
...
...
@@ -155,21 +163,18 @@ export default {
if
([
32
,
33
].
indexOf
(
res
.
err_code
)
>=
0
)
{
return
plugin
.
loginRequest
({});
}
if
(
res
.
err_code
==
124
)
{
return
this
.
getWxcode
();
}
// 风控提示用户去浏览器解除 重新获取code
return
res
;
})
.
then
((
res
)
=>
{
let
{
pt_key
,
rsa_modulus
,
guid
}
=
res
;
if
(
!
pt_key
&&
rsa_modulus
&&
guid
)
{
// login 返回
res
.
pluginUrl
=
plugin
.
formatPluginPage
(
'main'
);
}
// startClick()
}
// startClick()
util
.
handleJump
(
res
);
})
.
catch
((
res
)
=>
{
...
...
@@ -181,7 +186,7 @@ export default {
getWxcode
()
{
uni
.
login
({
success
:
(
res
=
{})
=>
{
this
.
code
=
res
.
code
this
.
code
=
res
.
code
}
});
},
...
...
@@ -198,15 +203,15 @@ export default {
// 拒绝协议
reject
()
{
let
{
rejectReturnPage
,
rejectPageType
}
=
this
.
config
;
if
(
rejectReturnPage
)
{
uni
[
`
${
rejectPageType
}
`
||
'rejectTo'
](
{
url
:
rejectReturnPage
});
}
else
{
uni
.
navigateBack
()
;
}
// let {rejectReturnPage, rejectPageType} = this.data
.config;
// if(rejectReturnPage){
// wx[`${rejectPageType}` || 'rejectTo']({url:rejectReturnPage})
// }else
{
// wx.navigateBack()
// }
this
.
selfTipsDialog
=
false
;
this
.
userBtn
=
false
;
this
.
smsBtn
=
false
;
}
}
};
...
...
@@ -243,46 +248,51 @@ export default {
left
:
0
;
width
:
100%
;
height
:
100%
;
background-color
:
rgba
(
0
,
0
,
0
,
0.
8
);
background-color
:
rgba
(
0
,
0
,
0
,
0.
6
);
}
.dialog-tips
>
view
{
position
:
absolute
;
border-radius
:
16
rpx
;
width
:
8
0%
;
padding
:
60
rpx
4
0
rpx
;
width
:
7
0%
;
padding
:
40
rpx
2
0
rpx
;
background-color
:
#fff
;
top
:
50%
;
left
:
50%
;
transform
:
translate
(
-50%
,
-50%
);
}
.dialog-tips
view
button
{
display
:
inline-block
;
width
:
45%
;
margin
:
0
;
}
.dialog-tips
view
button
.phone-btn
{
margin-left
:
10%
;
}
.dialog-tips
view
button
.bg-btn
{
background
:
rgba
(
242
,
242
,
242
,
1
);
border-radius
:
50
rpx
;
color
:
rgba
(
136
,
136
,
136
,
1
);
margin
:
0
;
/* .dialog-tips view button{
display: inline-block;
width: 45%;
margin:0;
} */
.dialog-tips
view
.cancel
{
font-size
:
30
rpx
;
color
:
rgba
(
100
,
101
,
102
,
1
);
text-align
:
center
;
margin-top
:
30
rpx
;
}
.dialog-tips
.no-fix
>
view
{
position
:
static
;
margin-bottom
:
20
rpx
;
text-align
:
left
;
}
.dialog-tips
.no-fix
>
view
>
view
{
font-size
:
28
rpx
;
line-height
:
50
rpx
;
color
:
#1269e2
;
}
.dialog-tips
.no-fix
>
view
>
view
:first-child
{
color
:
#000
;
}
.dialog-tips
.no-fix
>
view
>
text
:last-child
{
display
:
block
;
/* .dialog-tips .no-fix>view>view{
font-size: 28rpx;
line-height: 50rpx;
color: #1269E2;
} */
/* .dialog-tips .no-fix>view>text:last-child{
display: block;
} */
.phone-modal
{
padding
:
0
;
width
:
320
rpx
;
height
:
64
rpx
;
line-height
:
64
rpx
;
background
:
rgba
(
81
,
169
,
56
,
1
);
border-radius
:
32
rpx
;
margin
:
0
0
0
calc
(
50%
-
160
rpx
)
!important
;
color
:
#fff
;
text-align
:
center
;
}
</
style
>
pages/login/util.js
View file @
39b54803
let
plugin
=
requirePlugin
(
'loginPlugin'
);
(
function
()
{
if
(
console
.
jdLoginLog
)
return
;
if
(
console
.
jdLoginLog
)
{
return
;
}
let
normalLog
=
console
.
log
;
console
.
jdLoginLog
=
(...
args
)
=>
{
args
.
unshift
(
'-------登录插件-------'
);
normalLog
&&
normalLog
(...
args
);
if
(
normalLog
)
{
normalLog
(...
args
);
}
};
})();
const
utils
=
{
redirectPage
(
url
)
{
uni
.
redirectTo
({
url
});
},
redirectToH5
({
page
,
wvroute
})
{
let
url
=
plugin
.
formH5Url
({
page
:
decodeURIComponent
(
page
),
...
...
@@ -24,7 +24,6 @@ const utils = {
});
utils
.
redirectPage
(
url
);
},
navigateToH5
({
page
,
wvroute
})
{
let
url
=
plugin
.
formH5Url
({
page
:
decodeURIComponent
(
page
),
...
...
@@ -34,11 +33,12 @@ const utils = {
url
});
},
setLoginParamsStorage
(
obj
=
{})
{
if
(
obj
.
appid
&&
isNaN
(
Number
(
obj
.
appid
)))
{
delete
obj
.
appid
;
}
plugin
.
setLoginStorageSync
(
utils
.
getLoginConfig
(
obj
));
},
/*
首页存缓存逻辑(兼容不适用loginConfig直接存缓存):
同名参数优先级:url 中参数 > loginConfig > 缓存中
...
...
@@ -50,60 +50,56 @@ const utils = {
o
.
pageType
=
pageType
;
return
o
;
};
let
storageConfig
=
plugin
.
getLoginParams
();
let
config
=
handleUndefinedType
(
utils
.
getDefaultConfig
());
let
loginParams
=
{
...
storageConfig
,
...
config
};
let
loginParams
=
{
...
storageConfig
,
...
config
};
if
(
plugin
.
isObject
(
obj
))
{
loginParams
=
{
...
loginParams
,
...
handleUndefinedType
(
obj
)
};
loginParams
=
{
...
loginParams
,
...
handleUndefinedType
(
obj
)
};
}
else
{
console
.
jdLoginLog
(
'登录参数必须为对象'
);
}
return
loginParams
;
},
getDefaultConfig
()
{
let
lgConfig
;
try
{
lgConfig
=
require
(
'./config.js'
);
}
catch
(
err
)
{
console
.
log
(
'CatchClause'
,
err
);
console
.
log
(
'CatchClause'
,
err
);
lgConfig
=
{};
}
return
lgConfig
.
config
||
{};
},
handleJump
(
p
=
{})
{
let
{
goback
,
pluginUrl
,
riskUrl
}
=
p
;
if
(
goback
)
{
utils
.
goBack
();
return
;
}
if
(
pluginUrl
)
{
utils
.
redirectPage
(
pluginUrl
);
return
;
}
riskUrl
&&
if
(
riskUrl
)
{
utils
.
redirectToH5
({
page
:
riskUrl
});
}
},
goBack
()
{
let
params
=
plugin
.
getLoginParams
(),
{
returnPage
,
pageType
}
=
params
;
let
params
=
plugin
.
getLoginParams
();
let
{
returnPage
,
pageType
}
=
params
;
if
(
pageType
==
'navigateBack'
)
{
uni
[
pageType
]();
return
;
}
if
(
!
returnPage
)
{
uni
.
showToast
({
title
:
'没有returnPage,无法跳转'
,
...
...
@@ -111,10 +107,8 @@ const utils = {
});
return
;
}
if
(
pageType
!==
'h5'
)
{
returnPage
=
decodeURIComponent
(
returnPage
);
if
(
pageType
&&
pageType
!=
'rediretTo'
)
{
uni
[
pageType
]({
url
:
returnPage
...
...
@@ -122,7 +116,6 @@ const utils = {
}
else
{
utils
.
redirectPage
(
returnPage
);
}
return
;
}
else
{
utils
.
redirectToH5
({
...
...
@@ -131,67 +124,76 @@ const utils = {
return
;
}
},
h5Init
(
options
)
{
let
p
=
plugin
.
getLoginParams
();
if
(
plugin
.
isEmptyObj
(
p
))
utils
.
setLoginParamsStorage
(
options
);
if
(
plugin
.
isEmptyObj
(
p
))
{
utils
.
setLoginParamsStorage
(
options
);
}
},
setCustomNavigation
()
{
let
{
navigationBarColor
,
navigationBarTitle
}
=
plugin
.
getLoginParams
();
plugin
.
isObject
(
navigationBarColor
)
&&
uni
.
setNavigationBarColor
(
navigationBarColor
);
plugin
.
isObject
(
navigationBarTitle
)
&&
uni
.
setNavigationBarTitle
(
navigationBarTitle
);
if
(
plugin
.
isObject
(
navigationBarColor
))
{
uni
.
setNavigationBarColor
(
navigationBarColor
);
}
if
(
plugin
.
isObject
(
navigationBarTitle
))
{
uni
.
setNavigationBarTitle
(
navigationBarTitle
);
}
},
requestWithLoginStatus
(
obj
=
{})
{
obj
.
header
=
obj
.
header
||
{};
let
[
GUID
=
''
,
KEY
=
''
,
TOKEN
=
''
,
PIN
=
''
]
=
plugin
.
getJdListStorage
([
'guid'
,
'pt_key'
,
'pt_token'
,
'pt_pin'
])
,
_cookie
=
`guid=
${
GUID
}
; pt_pin=
${
encodeURIComponent
(
PIN
)}
; pt_key=
${
KEY
}
; pt_token=
${
TOKEN
}
`
,
{
cookie
}
=
obj
.
header
;
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
}
`
;
let
{
cookie
}
=
obj
.
header
;
obj
.
header
.
cookie
=
cookie
?
`
${
cookie
}
;
${
_cookie
}
`
:
_cookie
;
uni
.
request
(
obj
);
},
silentauthlogin
(
options
,
goToLogin
,
callback
)
{
uni
.
login
({
success
(
res
=
{})
{
let
{
code
}
=
res
;
if
(
code
)
{
utils
.
setLoginParamsStorage
(
options
);
plugin
.
silentauthlogin
({
...
options
,
code
},
goToLogin
)
.
silentauthlogin
(
{
...
options
,
code
},
goToLogin
)
.
then
((
res
)
=>
{
callback
&&
if
(
callback
)
{
callback
({
isSuccess
:
res
.
err_code
==
0
});
}
if
(
goToLogin
&&
res
.
err_code
==
0
)
{
utils
.
handleJump
(
res
);
}
})
.
catch
((
res
)
=>
{
callback
&&
if
(
callback
)
{
callback
({
isSuccess
:
false
});
}
console
.
jdLoginLog
(
'请重试一次'
);
});
}
else
{
callback
&&
if
(
callback
)
{
callback
({
isSuccess
:
false
});
}
console
.
jdLoginLog
(
'wx.login 获取code失败'
);
}
},
fail
()
{
callback
&&
if
(
callback
)
{
callback
({
isSuccess
:
false
});
}
}
});
}
...
...
pages/login/web-view/web-view.vue
View file @
39b54803
<
template
>
<
block
>
<
view
style=
"height: 100%"
>
<web-view
/>
</
block
>
</
view
>
</
template
>
<
script
>
...
...
@@ -18,9 +18,9 @@ export default {
// success: res => {
// }
// })
util
.
setCustomNavigation
();
let
{
token
,
islogin
}
=
options
;
if
(
Number
(
islogin
)
===
0
)
{
// wx.showModal({
// title: '提示',
...
...
@@ -34,7 +34,6 @@ export default {
util
.
redirectPage
(
'/pages/login/index/index?riskFail=1'
);
return
;
}
this
.
handleBackFromH5
(
token
);
},
methods
:
{
...
...
@@ -45,7 +44,6 @@ export default {
})
.
then
((
res
=
{})
=>
{
let
{
goback
,
err_msg
}
=
res
;
if
(
goback
)
{
plugin
.
gobackLog
({
route
:
7
...
...
@@ -53,7 +51,6 @@ export default {
util
.
goBack
();
return
;
}
if
(
err_msg
)
{
uni
.
showModal
({
title
:
'提示'
,
...
...
pages/login/wv-common/wv-common.vue
View file @
39b54803
<
template
>
<
block
>
<
view
style=
"height: 100%"
>
<web-view
:src=
"url"
/>
</
block
>
</
view
>
</
template
>
<
script
>
...
...
@@ -17,10 +17,9 @@ export default {
onLoad
:
function
(
options
=
{})
{
let
{
h5_url
=
''
}
=
options
;
util
.
h5Init
(
options
);
this
.
h5_url
=
h5_url
this
.
h5_url
=
h5_url
util
.
setCustomNavigation
();
this
.
_genToken
();
this
.
genTokenFun
();
},
onShareAppMessage
:
function
()
{
let
{
h5_url
}
=
this
;
...
...
@@ -30,7 +29,7 @@ export default {
};
},
methods
:
{
_genToke
n
()
{
genTokenFu
n
()
{
let
{
h5_url
}
=
this
;
plugin
.
genToken
({
...
...
@@ -38,16 +37,15 @@ export default {
})
.
then
((
res
)
=>
{
let
{
isSuccess
,
err_code
,
url
,
tokenkey
,
err_msg
}
=
res
;
if
(
isSuccess
&&
!
err_code
)
{
this
.
url
=
`
${
url
}
?to=
${
h5_url
}
&tokenkey=
${
tokenkey
}
`
this
.
url
=
`
${
url
}
?to=
${
h5_url
}
&tokenkey=
${
tokenkey
}
`
}
else
{
uni
.
showModal
({
title
:
'提示'
,
content
:
err_msg
||
'页面跳转失败,请重试'
,
success
:
(
res
)
=>
{
if
(
res
.
confirm
)
{
this
.
_genToke
n
();
this
.
genTokenFu
n
();
}
}
});
...
...
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