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
d0ceeeb3
Commit
d0ceeeb3
authored
May 26, 2020
by
程默
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix login
parent
a1c5b190
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
24 deletions
+54
-24
src/pages/login/index.vue
+54
-24
No files found.
src/pages/login/index.vue
View file @
d0ceeeb3
...
@@ -37,6 +37,7 @@ export default {
...
@@ -37,6 +37,7 @@ export default {
},
},
data
()
{
data
()
{
return
{
return
{
code
:
""
,
session_key
:
""
,
session_key
:
""
,
shopName
:
""
,
shopName
:
""
,
logoUrl
:
""
,
logoUrl
:
""
,
...
@@ -66,13 +67,40 @@ export default {
...
@@ -66,13 +67,40 @@ export default {
};
};
},
},
created
()
{},
created
()
{},
onShow
()
{
wx
.
checkSession
({
success
:
()
=>
{
//session_key 未过期,并且在本生命周期一直有效
wx
.
login
({
success
:
res
=>
{
this
.
code
=
res
.
code
;
},
fail
:
err
=>
{
reject
(
err
);
}
})
//重新登录
},
fail
:
()
=>
{
// session_key 已经失效,需要重新执行登录流程
wx
.
login
({
success
:
res
=>
{
this
.
code
=
res
.
code
;
},
fail
:
err
=>
{
reject
(
err
);
}
})
//重新登录
}
})
},
onLoad
(
options
)
{
onLoad
(
options
)
{
Object
.
assign
(
this
.
$data
,
this
.
$options
.
data
());
//mpvue 的混合周期 使用小程序生命周期数据未初始化
Object
.
assign
(
this
.
$data
,
this
.
$options
.
data
());
//mpvue 的混合周期 使用小程序生命周期数据未初始化
if
(
options
.
back
)
{
if
(
options
.
back
)
{
this
.
backPath
=
options
.
back
;
this
.
backPath
=
options
.
back
;
}
}
if
(
options
.
params
)
{
if
(
options
.
params
)
{
this
.
backParams
=
serialize
(
options
.
params
);
this
.
defalutBackParams
=
serialize
(
options
.
params
);
this
.
backParams
=
this
.
defalutBackParams
;
let
params
=
JSON
.
parse
(
options
.
params
);
let
params
=
JSON
.
parse
(
options
.
params
);
this
.
fromType
=
params
.
fromType
;
this
.
fromType
=
params
.
fromType
;
}
}
...
@@ -102,34 +130,26 @@ export default {
...
@@ -102,34 +130,26 @@ export default {
},
},
init
()
{
init
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
wx
.
login
({
login
success
:
res
=>
{
.
miniLogin
({
code
:
this
.
code
,
if
(
res
.
code
)
{
spokesmanRelId
:
this
.
$store
.
state
.
spokesmanRelId
,
login
spokesmanGroupId
:
this
.
$store
.
state
.
spokesmanGroupId
,
.
miniLogin
({
code
:
res
.
code
,
spokesmanShopId
:
this
.
$store
.
state
.
spokesmanShopId
spokesmanRelId
:
this
.
$store
.
state
.
spokesmanRelId
,
})
spokesmanGroupId
:
this
.
$store
.
state
.
spokesmanGroupId
,
.
then
(
res
=>
{
spokesmanShopId
:
this
.
$store
.
state
.
spokesmanShopId
if
(
res
.
data
.
code
==
200
)
{
})
resolve
(
res
);
.
then
(
res
=>
{
}
else
{
if
(
res
.
data
.
code
==
200
)
{
reject
(
res
.
data
.
msg
);
resolve
(
res
);
}
else
{
reject
(
res
.
data
.
msg
);
}
})
.
catch
(
err
=>
{
reject
(
err
);
});
}
},
fail
:
err
=>
{
reject
(
err
);
}
}
})
.
catch
(
err
=>
{
reject
(
err
);
});
});
});
});
},
},
getUserInfo
:
function
(
e
)
{
getUserInfo
:
function
(
e
)
{
this
.
backParams
=
this
.
defalutBackParams
wx
.
showLoading
({
wx
.
showLoading
({
title
:
"加载中"
title
:
"加载中"
});
});
...
@@ -189,6 +209,15 @@ export default {
...
@@ -189,6 +209,15 @@ export default {
// }¶ms=${encodeURIComponent(this.backParams)}`
// }¶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
.
pushPageType
();
this
.
pushPageType
();
}
else
{
}
else
{
var
data
=
wx_decode
(
var
data
=
wx_decode
(
...
@@ -200,6 +229,7 @@ export default {
...
@@ -200,6 +229,7 @@ export default {
this
.
unionId
=
data
.
unionId
||
""
;
this
.
unionId
=
data
.
unionId
||
""
;
this
.
userInfo
=
JSON
.
parse
(
e
.
target
.
rawData
);
this
.
userInfo
=
JSON
.
parse
(
e
.
target
.
rawData
);
console
.
log
(
this
.
userInfo
,
"this.userInfo"
);
console
.
log
(
this
.
userInfo
,
"this.userInfo"
);
this
.
$store
.
commit
(
'setUserInfo'
,
this
.
userInfo
)
if
(
this
.
unionId
)
{
if
(
this
.
unionId
)
{
login
login
...
...
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