url(true)); $response = redirect('https://www.jucai.gov.cn/api/auth/wechat_auth?url=' . urlencode(url('/mobile/login/humanLogin'))); throw new \think\exception\HttpResponseException($response); } } /** * 表单 */ public function index() { $this->_formValidate(); return view(); } public function institutionForm() { $this->_formValidate(); return view('', [ 'cooperate_list' => json_encode(HumanInstitutionModel::COOPERATE), ]); } public function institutionFormPost() { $data = input('post.'); try { validate(HumanInstitutionApplyValidate::class)->check($data); } catch (ValidateException $e) { ajax_return(1, $e->getError()); } $data['open_id'] = session('mobile.human.open_id'); HumanInstitutionApplyModel::create($data); ajax_return(); } public function enterpriseForm() { $this->_formValidate(); return view('', [ 'cooperate_list' => json_encode(HumanInstitutionModel::COOPERATE), ]); } public function enterpriseFormPost() { $data = input('post.'); try { validate(HumanEnterpriseApplyValidate::class)->check($data); } catch (ValidateException $e) { ajax_return(1, $e->getError()); } $data['open_id'] = session('mobile.human.open_id'); HumanEnterpriseApplyModel::create($data); ajax_return(); } public function tips() { $open_id = session('mobile.human.open_id'); $msg = ''; $type = ''; $institution = HumanInstitutionApplyModel::where('open_id', $open_id)->find(); $enterprise = HumanEnterpriseApplyModel::where('open_id', $open_id)->find(); if (empty($institution) && empty($enterprise)) { return redirect(url('human/index')); } if (!empty($institution)) { $type = 'institution'; if ($institution['status'] != HumanInstitutionApplyModel::STATUS_PASS) { $msg = HumanInstitutionApplyModel::STATUS[$institution['status']]; if (!empty($institution['comment'])) { $msg .= ':' . $institution['comment']; } } else { return redirect(url('human/enterpriseList')); } } if (!empty($enterprise)) { $type = 'enterprise'; if ($enterprise['status'] != HumanEnterpriseApplyModel::STATUS_PASS) { $msg = HumanEnterpriseApplyModel::STATUS[$enterprise['status']]; if (!empty($enterprise['comment'])) { $msg .= ':' . $enterprise['comment']; } } else { return redirect(url('human/institutionList')); } } return view('', ['msg' => $msg, 'type' => $type]); } public function resetApply() { $open_id = session('mobile.human.open_id'); $institution = HumanInstitutionApplyModel::where('open_id', $open_id)->find(); if (!empty($institution)) { $institution->delete(); } $enterprise = HumanEnterpriseApplyModel::where('open_id', $open_id)->find(); if (!empty($enterprise)) { $enterprise->delete(); } return redirect(url('human/index')); } /** * 列表 */ public function institutionList() { $this->_listValidate(); $cooperate_list = [['text' => '业务范围', 'value' => '']]; foreach (HumanInstitutionModel::COOPERATE as $cooperate) { $cooperate_list[] = ['text' => $cooperate, 'value' => $cooperate]; } return view('', [ 'cooperate_list' => json_encode($cooperate_list), ]); } public function listInstitution() { $where = $this->dealLikeInput(['name', 'cooperate']); $where[] = ['status', '=', HumanInstitutionModel::STATUS_SHOW]; $list = HumanInstitutionModel::where($where) ->order(['priority' => 'desc']) ->limit(input('limit', 10)) ->page(input('page', 1)) ->select(); ajax_success($list); } public function institutionDetail() { $this->_listValidate(); $id = input('id'); empty($id) && jump('该机构不存在或已删除'); $info = HumanInstitutionModel::find($id); empty($info) && jump('该机构不存在或已删除'); return view('', ['info' => $info]); } public function enterpriseList() { $this->_listValidate(); return view(); } public function listEnterprise() { $where = $this->dealLikeInput(['name']); $where[] = ['status', '=', HumanEnterpriseModel::STATUS_SHOW]; $list = HumanEnterpriseModel::where($where) ->order(['priority' => 'desc']) ->limit(input('limit', 10)) ->page(input('page', 1)) ->select(); ajax_success($list); } public function enterpriseDetail() { $this->_listValidate(); $id = input('id'); empty($id) && jump('该企业不存在或已删除'); $info = HumanEnterpriseModel::find($id); empty($info) && jump('该企业不存在或已删除'); return view('', ['info' => $info]); } public function center() { $this->_listValidate(); return view(); } public function describe() { return view(); } public function guide() { // $this->_listValidate(); return view(); } public function jinjiang() { return view(); } public function renzi() { return view(); } public function arrive() { $open_id = session('mobile.human.open_id'); $institution = HumanInstitutionApplyModel::where('open_id', $open_id)->find(); $enterprise = HumanEnterpriseApplyModel::where('open_id', $open_id)->find(); $msg = ''; if (empty($institution) && empty($enterprise)) { $msg = '请先报名'; } if (!empty($institution)) { $institution->is_arrive = HumanInstitutionApplyModel::IS_ARRIVE_YES; $institution->save(); $msg = '签到成功'; } if (!empty($enterprise)) { $enterprise->is_arrive = HumanEnterpriseApplyModel::IS_ARRIVE_YES; $enterprise->save(); $msg = '签到成功'; } return view('', ['msg' => $msg]); } private function _formValidate() { $open_id = session('mobile.human.open_id'); $institution = HumanInstitutionApplyModel::where('open_id', $open_id)->find(); $enterprise = HumanEnterpriseApplyModel::where('open_id', $open_id)->find(); if (!empty($institution)) { if ($institution['status'] != HumanInstitutionApplyModel::STATUS_PASS) { throw new \think\exception\HttpResponseException(redirect(url('human/tips'))); } else { throw new \think\exception\HttpResponseException(redirect(url('human/enterpriseList'))); } } if (!empty($enterprise)) { if ($enterprise['status'] != HumanEnterpriseApplyModel::STATUS_PASS) { throw new \think\exception\HttpResponseException(redirect(url('human/tips'))); } else { throw new \think\exception\HttpResponseException(redirect(url('human/institutionList'))); } } } private function _listValidate() { $open_id = session('mobile.human.open_id'); $institution = HumanInstitutionApplyModel::where('open_id', $open_id)->find(); $enterprise = HumanEnterpriseApplyModel::where('open_id', $open_id)->find(); if (empty($institution) && empty($enterprise)) { throw new \think\exception\HttpResponseException(redirect(url('human/index'))); } if (!empty($institution)) { if ($institution['status'] != HumanInstitutionApplyModel::STATUS_PASS) { throw new \think\exception\HttpResponseException(redirect(url('human/tips'))); } } if (!empty($enterprise)) { if ($enterprise['status'] != HumanEnterpriseApplyModel::STATUS_PASS) { throw new \think\exception\HttpResponseException(redirect(url('human/tips'))); } } } }