Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
U
uni-pdtravel
Project
Project
Details
Activity
Releases
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
panyongping
uni-pdtravel
Commits
6b03bbe2
Commit
6b03bbe2
authored
Jul 27, 2022
by
潘永坪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
登录和支付优化
parent
a2db5f84
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
111 additions
and
96 deletions
+111
-96
login.vue
pages/login/login.vue
+106
-94
orderPayment.vue
pages/payment/orderPayment/orderPayment.vue
+5
-2
No files found.
pages/login/login.vue
View file @
6b03bbe2
<
template
>
<
template
>
<view>
<view>
</view>
</view>
</
template
>
</
template
>
<
script
>
<
script
>
export
default
{
export
default
{
data
()
{
data
()
{
return
{
return
{}
},
}
onLoad
()
{
},
this
.
login
()
methods
:
{
},
methods
:{
},
//---登录
onLoad
(){
login
(){
let
_this
=
this
let
_this
=
this
uni
.
getProvider
({
uni
.
getProvider
({
service
:
'oauth'
,
service
:
'oauth'
,
success
(
proRes
){
success
(
proRes
)
{
uni
.
login
({
uni
.
login
({
provider
:
proRes
.
provider
[
0
],
provider
:
proRes
.
provider
[
0
],
success
:
function
(
res
)
{
success
:
function
(
res
)
{
if
(
res
.
code
){
if
(
res
.
code
)
{
let
source
=
''
let
source
=
''
if
(
proRes
.
provider
[
0
]
==
'weixin'
){
if
(
proRes
.
provider
[
0
]
==
'weixin'
)
{
source
=
3
source
=
3
}
else
if
(
proRes
.
provider
[
0
]
==
'alipay'
){
}
else
if
(
proRes
.
provider
[
0
]
==
'alipay'
)
{
source
=
4
source
=
4
}
}
let
data
=
{
let
data
=
{
code
:
res
.
code
,
code
:
res
.
code
,
source
,
//微信小程序3,支付宝小程序4
source
//微信小程序3,支付宝小程序4
}
}
_this
.
$request
(
'wechat/wx/getUserInfoByCode'
,
data
).
then
(
res
=>
{
_this
.
$request
(
'wechat/wx/getUserInfoByCode'
,
data
).
then
(
res
=>
{
if
(
res
.
code
==
'00'
){
if
(
res
.
code
==
'00'
)
{
let
openid
=
res
.
data
.
openid
let
openid
=
res
.
data
.
openid
uni
.
setStorageSync
(
'openid'
,
openid
)
uni
.
setStorageSync
(
'openid'
,
openid
)
let
userId
=
res
.
data
.
userId
||
''
let
userId
=
res
.
data
.
userId
||
''
let
datas
=
{
openid
,
source
,
userId
}
let
datas
=
{
openid
,
source
,
userId
}
_this
.
$request
(
'wechatUser/login/findWxUserAndLogin'
,
datas
).
then
((
res
)
=>
{
//通过openid获取token
_this
.
$request
(
'wechatUser/login/findWxUserAndLogin'
,
datas
).
then
(
res
=>
{
if
(
res
.
code
==
'00'
){
//通过openid获取token
let
token
=
res
.
data
.
token
||
''
if
(
res
.
code
==
'00'
)
{
uni
.
setStorageSync
(
'token'
,
token
)
let
token
=
res
.
data
.
token
||
''
let
createUserId
=
res
.
data
.
personId
||
''
uni
.
setStorageSync
(
'token'
,
token
)
uni
.
setStorageSync
(
'createUserId'
,
createUserId
)
let
createUserId
=
res
.
data
.
personId
||
''
let
userId
=
res
.
data
.
userId
||
''
uni
.
setStorageSync
(
'createUserId'
,
createUserId
)
uni
.
setStorageSync
(
'userId'
,
userId
)
let
userId
=
res
.
data
.
userId
||
''
let
enterOptions
=
uni
.
getStorageSync
(
'enterOptions'
)
uni
.
setStorageSync
(
'userId'
,
userId
)
let
queryTotal
=
''
let
enterOptions
=
uni
.
getStorageSync
(
'enterOptions'
)
for
(
let
key
in
enterOptions
.
query
){
let
queryTotal
=
''
queryTotal
+=
'&'
+
key
+
'='
+
enterOptions
.
query
[
key
]
for
(
let
key
in
enterOptions
.
query
)
{
}
queryTotal
+=
'&'
+
key
+
'='
+
enterOptions
.
query
[
key
]
queryTotal
=
queryTotal
.
substr
(
1
)
}
if
(
token
){
queryTotal
=
queryTotal
.
substr
(
1
)
uni
.
redirectTo
({
if
(
token
)
{
url
:
'/'
+
enterOptions
.
path
+
'?'
+
queryTotal
uni
.
redirectTo
({
})
url
:
'/'
+
enterOptions
.
path
+
'?'
+
queryTotal
// uni.navigateBack({
})
// delta:1
// uni.navigateBack({
// })
// delta:1
}
// })
}
else
{
}
uni
.
showToast
({
}
else
{
title
:
res
.
message
+
'请退出并重新登录'
,
uni
.
showToast
({
icon
:
'none'
title
:
res
.
message
+
'请退出并重新登录'
,
})
icon
:
'none'
}
})
}).
catch
((
err
)
=>
{
}
uni
.
showToast
({
})
title
:
'登录失败,请退出并重新登录'
,
.
catch
(
err
=>
{
icon
:
'none'
uni
.
showToast
({
})
title
:
'登录失败,请退出并重新登录'
,
})
icon
:
'none'
}
else
{
})
uni
.
showToast
({
let
timer
=
setTimeout
(()
=>
{
title
:
res
.
message
=
'请退出并重新登录'
,
_this
.
login
()
icon
:
'none'
},
2000
)
})
this
.
$once
(
'hook:beforeDestroy'
,
()
=>
{
}
clearTimeout
(
timer
)
}).
catch
((
err
)
=>
{
})
uni
.
showToast
({
})
title
:
'登录失败,请退出并重新登录'
,
}
else
{
icon
:
'none'
uni
.
showToast
({
})
title
:
res
.
message
+
'请退出并重新登录'
,
})
icon
:
'none'
}
})
}
}
})
})
}
.
catch
(
err
=>
{
})
uni
.
showToast
({
title
:
'登录失败,请退出并重新登录'
,
},
icon
:
'none'
}
})
</
script
>
let
timer
=
setTimeout
(()
=>
{
_this
.
login
()
},
2000
)
this
.
$once
(
'hook:beforeDestroy'
,
()
=>
{
clearTimeout
(
timer
)
})
})
}
}
})
}
})
}
}
}
<
style
>
<
/
script
>
</
style
>
<
style
><
/
style
>
pages/payment/orderPayment/orderPayment.vue
View file @
6b03bbe2
...
@@ -160,9 +160,12 @@ export default {
...
@@ -160,9 +160,12 @@ export default {
title
:
'登录失败'
,
title
:
'登录失败'
,
icon
:
'none'
icon
:
'none'
})
})
setTimeout
(()
=>
{
let
timer
=
setTimeout
(()
=>
{
_this
.
login
()
_this
.
login
()
},
2000
)
},
2000
)
this
.
$once
(
'hook:beforeDestroy'
,
()
=>
{
clearTimeout
(
timer
)
})
})
})
}
}
}
}
...
...
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