Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mallapp
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
viitto
mallapp
Commits
a2bf4ca5
Commit
a2bf4ca5
authored
Aug 21, 2020
by
Mac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
首页的静默登录
parent
19e3acd9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
97 additions
and
21 deletions
+97
-21
index.vue
pages/index/index.vue
+97
-21
No files found.
pages/index/index.vue
View file @
a2bf4ca5
...
@@ -211,31 +211,48 @@ export default {
...
@@ -211,31 +211,48 @@ export default {
withShareTicket
:
true
,
withShareTicket
:
true
,
menus
:
[
"shareAppMessage"
,
"shareTimeline"
],
menus
:
[
"shareAppMessage"
,
"shareTimeline"
],
});
});
if
(
uni
.
getStorageSync
(
"mall_UserInfo"
))
{
let
uid
=
uni
.
getStorageSync
(
"mall_UserInfo"
).
UserId
;
that
.
u
=
uni
.
getStorageSync
(
"mall_UserInfo"
)
wx
.
getUserInfo
({
wx
.
getUserInfo
({
success
:
function
(
res
)
{
success
:
function
(
res
)
{
if
(
uni
.
getStorageSync
(
"mall_UserInfo"
))
{
let
uid
=
uni
.
getStorageSync
(
"mall_UserInfo"
).
UserId
;
let
msg
=
{
let
msg
=
{
Id
:
uid
,
Id
:
uid
,
AliasName
:
res
.
userInfo
.
nickName
,
AliasName
:
res
.
userInfo
.
nickName
,
Photo
:
res
.
userInfo
.
avatarUrl
,
Photo
:
res
.
userInfo
.
avatarUrl
,
};
};
that
.
updateuserinfo
(
msg
);
that
.
updateuserinfo
(
msg
);
},
}
else
{
});
//静默登录操作
uni
.
login
({
provider
:
'weixin'
,
success
:
info
=>
{
let
obj
=
{
Name
:
res
.
userInfo
.
nickName
,
Photo
:
res
.
userInfo
.
avatarUrl
,
code
:
info
.
code
}
}
this
.
u
=
uni
.
getStorageSync
(
"mall_UserInfo"
);
that
.
getCode
(
obj
)
if
(
!
this
.
u
)
{
},
this
.
u
=
{
fail
:
()
=>
{
uni
.
showToast
({
title
:
'微信登录授权失败'
,
icon
:
'none'
});
if
(
!
that
.
u
)
{
that
.
u
=
{
nickName
:
"未登录"
,
nickName
:
"未登录"
,
avatarUrl
:
""
avatarUrl
:
""
};
};
this
.
showAuth
=
true
;
that
.
showAuth
=
true
;
}
}
});
}
},
});
}
else
{
}
// #endif
// #endif
this
.
init
();
this
.
init
();
let
set
=
uni
.
getStorageSync
(
"basedata"
)
let
set
=
uni
.
getStorageSync
(
"basedata"
)
...
@@ -317,6 +334,65 @@ export default {
...
@@ -317,6 +334,65 @@ export default {
},
},
methods
:
{
methods
:
{
//调用获取code
getCode
(
obj
)
{
var
that
=
this
;
//这里请求接口
that
.
request2
(
{
url
:
'/api/mall/GetWeChatOpenId'
,
data
:
{
Code
:
obj
.
code
}
},
res
=>
{
if
(
res
.
resultCode
==
1
)
{
obj
.
OpenId
=
res
.
data
;
that
.
getLogin
(
obj
);
}
}
);
},
getLogin
(
obj
)
{
var
that
=
this
;
let
pid
=
uni
.
getStorageSync
(
"pid"
)?
uni
.
getStorageSync
(
"pid"
).
pid
:
0
;
let
SmallShopId
=
uni
.
getStorageSync
(
"SmallShopId"
)?
uni
.
getStorageSync
(
"SmallShopId"
).
SmallShopId
:
0
;
that
.
request2
(
{
url
:
'/api/AppletLogin/Login'
,
data
:
{
Source
:
1
,
OpenId
:
obj
.
OpenId
,
Name
:
obj
.
Name
,
Photo
:
obj
.
Photo
,
Moblie
:
''
,
SuperiorId
:
pid
,
SmallShopId
:
SmallShopId
,
}
},
res
=>
{
if
(
res
.
resultCode
==
1
)
{
uni
.
setStorageSync
(
'mall_UserInfo'
,
res
.
data
);
if
(
res
.
couponResultCode
==
1
){
that
.
showCoupons
=
true
;
that
.
couponMessage
=
res
.
couponMessage
;
}
that
.
u
=
res
.
data
uni
.
removeStorageSync
(
'pid'
);
uni
.
removeStorageSync
(
'SmallShopId'
);
}
else
{
if
(
!
that
.
u
)
{
that
.
u
=
{
nickName
:
"未登录"
,
avatarUrl
:
""
};
that
.
showAuth
=
true
;
}
}
}
);
},
updateuserinfo
(
msg
)
{
updateuserinfo
(
msg
)
{
this
.
request2
(
this
.
request2
(
{
{
...
...
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