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