$this->auth->id])->field('id,username,nickname,google_key,google_bind')->find(); $googleKey = isset($admin['google_key'])? $admin['google_key'] : ''; if(empty($googleKey)){ $secret = $google->createSecret(); Admin::where(['id'=> $this->auth->id])->update(['google_key'=> $secret,'updatetime'=>time()]); } $config = Config::getConfigByGroup('basic'); $siteName = isset($config['name'])? $config['name']['value'] : '茶马古道'; $qrcode = $google->getQRCodeGoogleUrl($admin['username'],$googleKey,$siteName); $this->view->assign('admin', $admin); $this->view->assign('qrcode', $qrcode); return $this->view->fetch(); } /** * 绑定 * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function bind() { if(Admin::where(['id'=> $this->auth->id])->update(['google_bind'=>1,'updatetime'=>time()])){ $this->success('绑定成功'); }else{ $this->error('绑定失败'); } } }