最近微信接口升级导致人人商城小程序授权登录失败,用户无法登录(已经上线的小程序不受影响,但是如果修改再审核的话,也需要更新接口)。
经过几天的研究终于搞定了。
需要把原来的getUserinfo接口升级到新的getUserProfile接口
小程序前端需要修改:pages/auth目录下的 index.js文件
前台需要原来的getUserinfo接口改成新的getUserProfile接口
后台需要修改:ewei_shopv2\plugin\app\core\mobile目录下的wxapp.php文件
把原来的接口重新写了,新的接口如下:
$data = $_GPC['userInfo'];
$data['openId'] = $_GPC['openId'];
$this->refine($data['openId']);
$member = m('member')->getMember('sns_wa_'.$data['openId']);
if (empty($member)){
$member = array(
'uniacid' => $_W['uniacid'],
'uid' => 0,
'openid' => 'sns_wa_'.$data['openId'],
'nickname' => !empty($data['nickName']) ? $data['nickName'] : '',
'avatar' => !empty($data['avatarUrl']) ? $data['avatarUrl'] : '',
'gender' => !empty($data['gender']) ? $data['gender'] : '-1',
'openid_wa' =>$data['openId'],
'comefrom' =>'sns_wa',
'createtime' => time(),
'status' => 0
);
pdo_insert('ewei_shop_member', $member);
$id = pdo_insertid();
$data['id'] = $id;
$data['uniacid'] = $_W['uniacid'];
if(method_exists(m('member'),'memberRadisCountDelete')) {
m('member')->memberRadisCountDelete();
}
}else{
$updateData = array(
'nickname' => !empty($data['nickName']) ? $data['nickName'] : '',
'avatar' => !empty($data['avatarUrl']) ? $data['avatarUrl'] : '',
'gender' => !empty($data['gender']) ? $data['gender'] : '-1',
);
pdo_update('ewei_shop_member',$updateData,array('id'=>$member['id'],'uniacid'=>$member['uniacid']));
$data['id'] = $member['id'];
$data['uniacid'] = $member['uniacid'];
$data['isblack'] = $member['isblack'];
}
if (p('commission')) {
p('commission')->checkAgent($member['openid']);
}
return app_json($data,$data['openId']);
return app_error(AppError::$WxAppError , '登录错误, 错误代码: '.$errCode);
时间太紧,写的有点乱,不明白的地方可以私信我