error('参数错误'); $app = Factory::miniProgram(config('app.mini_program')); $data = $app->auth->session($code); if(empty($data['openid'])) $this->error($data['errmsg']); $member = Db::name('store_member')->field('id,phone')->where('openid',$data['openid'])->find(); if(empty($member)){ $member_data = [ 'openid' => $data['openid'], 'headimg' => $headimg, 'create_at'=>date("Y-m-d H:i:s") ]; Db::table('store_member')->insert($member_data); $uid = Db::getLastInsID(); }else{ $uid = $member['id']; } if(empty($uid)) $this->error('数据有误'); $token =$this->createJwt($uid); $this->success('登录成功',['token'=>$token]); } }