'weixin', 'identifier' => $open_id])->find(); if (empty($auth)) { session('user.open_id', $open_id); session('user.nickname', $param['nickname']); session('user.headimgurl', $param['headimgurl']); my_redirect('/login/mobile'); } else { $auth->logintime = time(); $auth->loginip = request()->ip(); $auth->save(); } session('user.id', $auth['userid']); my_redirect('/'); } public function type() { $user_id = get_user_id(); if (empty($user_id)) { my_redirect('/login/index'); } return view('login/type'); } public function setType() { $type = input('type') == 2 ? 2 : 1; session('user.type', $type); if ($type == 1) { my_redirect('/'); } else { my_redirect('/emp/index'); } } public function sinPage() { $field = input('field/s'); $sinpage = SinpageModel::where(1)->find(); $data = []; if ($field == "woman_aboutus") { $data = [ 'pagetil' => '关于我们', 'pagecon' => $sinpage->woman_aboutus, ]; } elseif ($field == "woman_privacy") { $data = [ 'pagetil' => '隐私政策', 'pagecon' => $sinpage->woman_privacy, ]; } elseif ($field == "woman_service") { $data = [ 'pagetil' => '用户协议', 'pagecon' => $sinpage->woman_service, ]; } elseif ($field == "woman_contact") { $data = [ 'pagetil' => '联系客服', 'pagecon' => $sinpage->woman_contact, ]; } else { $data = [ 'pagetil' => '关于我们', 'pagecon' => $sinpage->woman_aboutus, ]; } $pagecon = explode("\n", $data['pagecon']); $str = ''; foreach ($pagecon as $con) { $str .= "
{$con}
"; } $data['pagecon'] = $str; return view('/login/page', $data); } public function perfect() { $user_id = get_user_id(); $info = UserModel::where('id', $user_id)->find(); $catelist = ComjobsCateModel::order(['priority' => 'desc', 'id' => 'desc'])->select(); $userwill = UserWillModel::field('title as text,id')->select(); $emptime = RensheCodeModel::getList('emp_time'); $community = RensheCodeModel::getList('community')->toArray(); $community[] = ['name' => '不限']; return view('my/info', [ 'info' => $info, 'catelist' => $catelist, 'userwill' => $userwill, 'emptime' => $emptime, 'community' => json_encode($community), 'workexperience' => getWorkExperience(), 'education' => getEducation(), 'type' => 1, 'url' => url('/login/infoPost'), ]); } public function infoPost() { $user_id = get_user_id(); $info = UserModel::where('id', $user_id)->find(); $form = input('param.'); foreach ($form as $k => $v) { $info->$k = $v; } $info->is_perfect = 1; $info->save(); page_result(0, '操作成功'); } /** * 手机登录 */ public function mobile() { return view('login/mobile'); } public function mobilePost() { $mobile = input('mobile/s', ''); $verify = input('verify/s', ''); $session_verify = session('verify'); if ($verify != $session_verify) { page_result(1, '验证码错误!'); } $auth = UserAuthsModel::where(['identitytype' => 'mobile', 'identifier' => $mobile])->find(); if (empty($auth)) { $open_id = session('user.open_id'); $nickname = session('user.nickname'); $headimgurl = session('user.headimgurl'); $user_data = [ 'groupsid' => 7, 'brokerid' => 0, 'nickname' => $nickname, 'avatar' => $headimgurl ?? '', 'realname' => "", 'mobile' => $mobile, 'integral' => 0, 'inttotal' => 0, 'status' => 2, 'isvip' => 1, 'authstatus' => 1, 'authremark' => "", 'idcardzpic' => "", 'idcardfpic' => "", 'idcard' => "", 'gender' => 1, 'birthday' => "", 'address' => "", 'education' => "", 'createtime' => time(), 'jobintention' => "", 'workexperience' => "", 'eduexperience' => "", 'followstatus' => 1, 'wxampcode' => "", 'bankcard' => ['openbank' => "", 'account' => "", 'number' => ""], 'emp_time' => [], 'com_cate' => [], 'work_place' => [], 'user_tags' => [], ]; $user = User::create($user_data); $auth = UserAuthsModel::create([ 'userid' => $user['id'], 'identitytype' => 'weixin', 'identifier' => $open_id, 'logintime' => time(), 'loginip' => request()->ip(), ]); UserAuthsModel::create([ 'userid' => $user['id'], 'identitytype' => 'mobile', 'identifier' => $mobile, 'logintime' => time(), 'loginip' => request()->ip(), ]); } else { $auth->logintime = time(); $auth->loginip = request()->ip(); $auth->save(); } session('user.id', $auth['userid']); page_result(); } public function sendSms() { Session::delete('verify'); $rand = rand(100000, 999999); $mobile = trim(input('post.mobile')); $preg_phone = '/^1[34578]\d{9}$/ims'; $rtn = []; if (!$mobile) { page_result(1, '手机号为空'); } else { if (preg_match($preg_phone, $mobile)) { $sms = new SmsService(); $res = $sms->send($mobile, 'verification', [$rand]); if ($res['code'] == 0) { $rtn['code'] = 0; Session::set('verify', $rand); } else { page_result(1, '网络故障,请重试'); } } else { page_result(1, '手机号格式不正确'); } } page_result(); } /** * 雇主注册 */ public function empRegister() { $user_id = get_user_id(); $worker = WorkerModel::field(['id', 'realname', 'mobile', 'address', 'title', 'details', 'picone', 'remark', 'status'])->where('userid', $user_id)->find(); if (empty($worker)) { $worker = json_encode(['id' => 0, 'wtype' => '', 'realname' => '', 'mobile' => '', 'address' => '', 'title' => '', 'details' => '', 'picone' => '', 'remark' => '']); } else { if ($worker->status == 1) { return $this->_jump('等待管理员审核', url('/login/setType') . '?type=1'); } elseif ($worker->status == 3 || $worker->status == 4) { return $this->_jump('账号异常,请联系管理员', url('/login/setType') . '?type=1'); } elseif ($worker->status == 5) { my_redirect(url('/emp/index')); } } return view('login/emp_register', ['worker' => $worker]); } public function empRegisterPost() { $data = input('post.'); $data['status'] = 1; if ($data['id']) { WorkerModel::update($data); } else { $user_id = get_user_id(); $data['userid'] = $user_id; $data['ftitle'] = $data['title']; $data['province'] = '福建省'; $item['city'] = '福州市'; $item['district'] = '马尾区'; $data['createitme'] = time(); if ($data['wtype'] == 1) { $data['title'] = $data['ftitle'] = $data['realname']; } WorkerModel::create($data); } page_result(); } /** * 错误提示 */ private function _jump($msg = '', $url = null, $wait = 3) { if (is_null($url)) { $url = 'javascript:history.back(-1);'; } else { $url = "location.href = '" . url($url) . "'"; } $result = [ 'msg' => $msg, 'url' => $url, 'wait' => $wait, ]; return view('/public/jump', $result); } }