Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mayi-mp-shop
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
程默
mayi-mp-shop
Commits
b32c2621
Commit
b32c2621
authored
May 18, 2021
by
张卓
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
第三方页面扫码登录,商城点击登录兼容
parent
1f3e66a1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
23 deletions
+80
-23
src/api/login.js
+5
-0
src/pages/wxArticle/index.vue
+75
-23
No files found.
src/api/login.js
View file @
b32c2621
...
@@ -15,6 +15,10 @@ console.log(process.env,'-----------------config------')
...
@@ -15,6 +15,10 @@ console.log(process.env,'-----------------config------')
//check unionid
//check unionid
checkUnionid
(
options
){
checkUnionid
(
options
){
return
requestGET
(
`
${
process
.
env
.
OLSHOP_URL
}
/wx/mini_check_union_id`
,
options
)
return
requestGET
(
`
${
process
.
env
.
OLSHOP_URL
}
/wx/mini_check_union_id`
,
options
)
},
// sso登录
getSsoBcakUrl
(
options
)
{
return
requestPOST
(
`
${
process
.
env
.
OLSHOP_URL
}
/common/getSsoCallbackUrl`
,
options
)
}
}
}
}
\ No newline at end of file
src/pages/wxArticle/index.vue
View file @
b32c2621
...
@@ -13,13 +13,12 @@
...
@@ -13,13 +13,12 @@
</
template
>
</
template
>
<
script
>
<
script
>
let
forUrlAddKey
;
let
forUrlAddKey
=
require
(
"mayi-front-tools/forUrlAddKey"
).
default
;
let
getUrlKey
;
let
getUrlKey
=
require
(
"mayi-front-tools/getUrlKey"
).
default
;
if
(
process
.
browser
)
{
let
removeUrlKey
=
require
(
"mayi-front-tools/removeUrlKey"
).
default
;
forUrlAddKey
=
require
(
"mayi-front-tools/forUrlAddKey"
).
default
getUrlKey
=
require
(
"mayi-front-tools/getUrlKey"
).
default
}
import
{
serialize
,
getQueryVariable
,
DFSImg
}
from
"@/utils/index"
;
import
{
serialize
,
getQueryVariable
,
DFSImg
}
from
"@/utils/index"
;
import
login
from
"@/api/login"
;
import
indexApi
from
"@/api/index"
;
export
default
{
export
default
{
data
(){
data
(){
return
{
return
{
...
@@ -29,24 +28,48 @@ export default {
...
@@ -29,24 +28,48 @@ export default {
newWindowHref
:
''
,
//分享页面url
newWindowHref
:
''
,
//分享页面url
}
}
},
},
onLoad
(
options
){
async
onLoad
(
options
){
console
.
log
(
decodeURIComponent
(
options
.
link
),
'地址'
,
wx
.
getStorageSync
(
"sessionid"
),
forUrlAddKey
(
decodeURIComponent
(
options
.
link
),{
token
:
wx
.
getStorageSync
(
"sessionid"
),
jwt
:
1
}))
// this.link = 'https://www.baidu.com/?token=550e48f594414525a1bd0dfda431e370&scene=sso'
if
(
getUrlKey
(
decodeURIComponent
(
options
.
link
),
'login'
)
!=
'1'
)
{
// return
this
.
link
=
decodeURIComponent
(
options
.
link
)
if
(
options
.
scene
)
{
}
else
{
//扫码
if
(
wx
.
getStorageSync
(
"sessionid"
))
{
let
data
=
await
this
.
getParams
(
options
.
scene
);
this
.
link
=
forUrlAddKey
(
console
.
log
(
data
,
888999
,
wx
.
getStorageSync
(
"sessionid"
))
decodeURIComponent
(
options
.
link
),
// debugger
{
if
(
data
.
sso
)
{
token
:
wx
.
getStorageSync
(
"sessionid"
),
if
(
!
wx
.
getStorageSync
(
"sessionid"
))
{
jwt
:
1
wx
.
redirectTo
({
}
url
:
`../login/main?scene=sso&back=
${
data
.
link
}
`
,
)
});
}
else
{
this
.
getSsoBcakUrl
(
decodeURIComponent
(
data
.
link
))
// let link = decodeURIComponent(data.link).replace(
// "${token}",
// wx.getStorageSync("sessionid")
// );
// this.link = decodeURIComponent(link);
}
}
}
else
if
(
options
.
link
){
if
(
getUrlKey
(
decodeURIComponent
(
options
.
link
),
'scene'
)
==
'sso'
)
{
this
.
getSsoBcakUrl
(
decodeURIComponent
(
options
.
link
))
}
else
if
(
getUrlKey
(
decodeURIComponent
(
options
.
link
),
'login'
)
!=
'1'
)
{
this
.
link
=
decodeURIComponent
(
options
.
link
)
}
else
{
}
else
{
let
url
=
`/pages/login/main?scene=sso&back=
${
options
.
link
}
`
;
if
(
wx
.
getStorageSync
(
"sessionid"
))
{
wx
.
navigateTo
({
this
.
link
=
forUrlAddKey
(
url
decodeURIComponent
(
options
.
link
),
})
{
token
:
wx
.
getStorageSync
(
"sessionid"
),
jwt
:
1
}
)
}
else
{
let
url
=
`/pages/login/main?scene=sso&back=
${
options
.
link
}
`
;
wx
.
navigateTo
({
url
})
}
}
}
}
}
},
},
...
@@ -59,6 +82,7 @@ export default {
...
@@ -59,6 +82,7 @@ export default {
}
else
{
}
else
{
url
=
res
.
webViewUrl
;
url
=
res
.
webViewUrl
;
}
}
url
=
removeUrlKey
(
url
,[
'token'
])
//分享页面去掉登录态
//分享页面去掉登录态
if
(
url
.
indexOf
(
"sessionid"
)
>
-
1
)
{
if
(
url
.
indexOf
(
"sessionid"
)
>
-
1
)
{
url
=
url
.
split
(
"?"
)[
0
]
+
"?mixid="
+
this
.
shopId
;
url
=
url
.
split
(
"?"
)[
0
]
+
"?mixid="
+
this
.
shopId
;
...
@@ -91,6 +115,34 @@ export default {
...
@@ -91,6 +115,34 @@ export default {
};
};
},
},
methods
:
{
methods
:
{
getSsoBcakUrl
(
link
)
{
let
op
=
{
callbackUrl
:
link
,
email
:
""
,
fromAppid
:
"VsEOuDJqBnGNyXZJWCQS"
,
// mobilephone: '15821335747',hgFTLLhgnBmeOyCkcbyv
toAppid
:
'hgFTLLhgnBmeOyCkcbyv'
,
// toAppid: getUrlKey(link,'toAppid'),//道可
wxAvatarUrl
:
this
.
$store
.
state
.
userInfo
.
avatarUrl
,
};
login
.
getSsoBcakUrl
(
op
).
then
((
res
)
=>
{
this
.
link
=
res
.
data
.
data
;
console
.
log
(
res
,
this
.
link
,
555444
)
});
},
getParams
(
options
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
indexApi
.
getShareSceneRecord
(
options
)
.
then
((
res
)
=>
{
if
(
res
.
data
.
code
==
"200"
)
{
let
scene
=
JSON
.
parse
(
res
.
data
.
data
.
scene
);
resolve
(
scene
);
}
})
.
catch
((
err
)
=>
{});
});
},
//加载成功
//加载成功
handleLoad
()
{
handleLoad
()
{
console
.
log
(
"网页加载成功"
);
console
.
log
(
"网页加载成功"
);
...
...
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