Authored by 邱骏

错误处理

... ... @@ -269,7 +269,14 @@ const userController = {
* @param res
*/
wechatUserCallback(req, res, next) {
let wechatUserInfo = JSON.parse(req.query.wechatUserInfo);
let wechatUserInfo;
try {
wechatUserInfo = JSON.parse(req.query.wechatUserInfo);
} catch (err) {
wechatUserInfo = {};
}
console.log('wechatUserCallBack:', wechatUserInfo);
let user_name = '',
... ... @@ -277,7 +284,7 @@ const userController = {
union_id = '';
if (wechatUserInfo) {
if (wechatUserInfo && wechatUserInfo.nickname) {
user_name = wechatUserInfo.nickname;
head_img = wechatUserInfo.headimgurl;
union_id = wechatUserInfo.unionid || wechatUserInfo.openid;
... ...