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
7d93cbf7
Commit
7d93cbf7
authored
Apr 29, 2021
by
程默
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix 登录getuserinfo
parent
9af24415
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
66 deletions
+19
-66
src/pages/login/index.vue
+19
-66
No files found.
src/pages/login/index.vue
View file @
7d93cbf7
...
...
@@ -4,14 +4,8 @@
<image
class=
"img"
mode=
"aspectFit"
:src=
"logoUrl"
/>
<p
class=
"shopName"
v-if=
"shopName"
>
{{
shopName
}}
</p>
<div
class=
"btn_info"
>
<button
class=
"btn"
lang=
"zh_CN"
open-type=
"getUserInfo"
@
getuserinfo=
"getUserInfo
"
>
微信一键登录
</button>
<button
class=
"btn"
lang=
"zh_CN"
@
click=
"getUserProfile
"
>
微信一键登录
</button>
</div>
<!--
<div>
{{
testd
}}
</div>
<div>
{{
test_sessionId
}}
</div>
--sessionId
<div>
{{
unionId
}}
</div>
--unionId
<div>
{{
test_isHaveUnion
}}
</div>
--isHaveUnion-->
<!--
<div
class=
"enterpriseLogin"
@
click=
"eLogin"
>
账号登录
</div>
-->
</div>
<div
class=
"toCLogin1"
v-if=
"isShowPhone"
>
<div
class=
"btn_info1"
>
...
...
@@ -32,13 +26,8 @@ import { wx_decode } from "@/utils/wxIndex.js";
import
login
from
"@/api/login"
;
import
shop
from
"@/api/shop"
;
import
indexApi
from
"@/api/index.js"
;
var
WXBizDataCrypt
=
require
(
"@/utils/WXBizDataCrypt"
);
const
app
=
getApp
();
export
default
{
name
:
'login'
,
components
:
{
// card
},
data
()
{
return
{
code
:
""
,
...
...
@@ -68,9 +57,9 @@ export default {
test_isHaveUnion
:
""
,
test_unionId
:
""
,
fromType
:
''
,
//来源类型 mini:小程序跳转到当前登录页
scene
:
''
//场景
};
},
created
()
{},
onShow
()
{
wx
.
checkSession
({
success
:
()
=>
{
...
...
@@ -99,6 +88,7 @@ export default {
},
onLoad
(
options
)
{
Object
.
assign
(
this
.
$data
,
this
.
$options
.
data
());
//mpvue 的混合周期 使用小程序生命周期数据未初始化
options
.
scene
&&
(
this
.
scene
=
options
.
scene
)
if
(
options
.
back
)
{
this
.
backPath
=
options
.
back
;
}
...
...
@@ -171,32 +161,20 @@ export default {
})
}
},
getUser
Info
:
function
(
e
)
{
this
.
backParams
=
this
.
defalutBackParams
wx
.
showLoading
({
title
:
"加载中"
});
if
(
e
.
target
.
errMsg
==
"getUserInfo:ok"
)
{
getUser
Profile
(
)
{
// 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
// 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
wx
.
getUserProfile
({
desc
:
'用于完善会员资料'
,
// 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success
:
(
e
)
=>
{
this
.
init
()
.
then
(
res
=>
{
console
.
log
(
"promise"
,
res
);
//存入openid
try
{
wx
.
setStorageSync
(
'openid'
,
res
.
data
.
data
.
openid
)
}
catch
(
e
)
{
console
.
log
(
'存入openid失败'
,
e
)
}
wx
.
getStorage
({
key
:
"openid"
,
success
(
res
)
{
console
.
log
(
"promise_openid1"
,
res
)
},
fail
(
err
){
console
.
log
(
"promise_openid2"
,
err
)
}
})
//
if
(
res
.
data
.
data
.
isHaveUnion
==
"true"
)
{
//有账号
this
.
backParams
+=
`&sessionid=
${
...
...
@@ -217,9 +195,10 @@ export default {
this
.
appid
=
res
.
data
.
data
.
appid
;
this
.
session_key
=
res
.
data
.
data
.
session_key
;
this
.
openid
=
res
.
data
.
data
.
openid
;
this
.
unionId
=
res
.
data
.
data
.
unionId
||
''
;
this
.
isShow
=
true
;
//checkLogin
//checkLogind
this
.
checkLogin
(
e
);
})
.
catch
(
err
=>
{
...
...
@@ -227,46 +206,19 @@ export default {
wx
.
hideLoading
();
wx
.
showToast
({
title
:
err
,
icon
:
"none"
});
});
}
else
{
wx
.
hideLoading
();
wx
.
showToast
({
title
:
"获取用户信息失败"
,
icon
:
"none"
});
}
})
},
checkLogin
(
e
)
{
console
.
log
(
this
.
isHaveUnion
,
e
)
this
.
userInfo
=
e
.
userInfo
;
this
.
$store
.
commit
(
'setUserInfo'
,
this
.
userInfo
)
if
(
this
.
isHaveUnion
)
{
wx
.
hideLoading
();
//是会员 直接登录
// 0318写直播改后面注释逻辑相同
// wx.reLaunch({
// url: `../index/main?from=login&backpath=${
// this.backPath
// }¶ms=${encodeURIComponent(this.backParams)}`
// });
// 跳转回小程序页面
var
data
=
wx_decode
(
this
.
appid
,
this
.
session_key
,
e
.
mp
.
detail
.
encryptedData
,
e
.
mp
.
detail
.
iv
);
this
.
userInfo
=
JSON
.
parse
(
e
.
target
.
rawData
);
this
.
$store
.
commit
(
'setUserInfo'
,
this
.
userInfo
)
this
.
addRecord
(
false
);
this
.
pushPageType
();
}
else
{
var
data
=
wx_decode
(
this
.
appid
,
this
.
session_key
,
e
.
mp
.
detail
.
encryptedData
,
e
.
mp
.
detail
.
iv
);
this
.
unionId
=
data
.
unionId
||
""
;
this
.
userInfo
=
JSON
.
parse
(
e
.
target
.
rawData
);
console
.
log
(
this
.
userInfo
,
"this.userInfo"
);
this
.
$store
.
commit
(
'setUserInfo'
,
this
.
userInfo
)
if
(
this
.
unionId
)
{
login
.
checkUnionid
({
unionId
:
this
.
unionId
,
openId
:
this
.
openid
})
...
...
@@ -324,12 +276,13 @@ export default {
wx
.
navigateBack
({
delta
:
1
});
}
else
if
(
this
.
scene
==
'sso'
)
{
wx
.
redirectTo
({
url
:
`../wxArticle/main?link=
${
this
.
backPath
}
`
,
});
}
else
{
let
parseLink
=
decodeURIComponent
(
this
.
backPath
);
let
isTabbarIndex
=
checkTabbarPage
(
parseLink
)
console
.
log
(
'32111'
,
isTabbarIndex
,
parseLink
,
this
.
backParams
)
// wx.navigateBack()
// return
if
(
isTabbarIndex
>-
1
){
wx
.
reLaunch
({
url
:
parseLink
==
'/'
?
'/pages/home/main'
:
`/pages/tabBar
${
isTabbarIndex
}
/main`
,
...
...
@@ -341,7 +294,6 @@ export default {
}
¶ms=
${
encodeURIComponent
(
this
.
backParams
)}
`
});
}
}
},
getPhoneNumber
(
e
)
{
...
...
@@ -378,6 +330,7 @@ export default {
province
:
this
.
userInfo
.
province
,
city
:
this
.
userInfo
.
city
,
otherPhone
:
0
,
articleId
:
wx
.
getStorageSync
(
this
.
$store
.
state
.
mixid
+
"articleId"
)
||
''
,
customerSourceType
:
wx
.
getStorageSync
(
this
.
$store
.
state
.
mixid
+
"articleId"
)?
8
:
''
,
customerSourceId
:
wx
.
getStorageSync
(
this
.
$store
.
state
.
mixid
+
"articleId"
)
||
''
};
...
...
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