/** * 登入方法 * @param null $input * @return array */ public function login($input = null) { $input = $input ? $input : rq(); if (!empty($input['user_type']) && $input['user_type'] == 'doctor' && !empty($input['cust_id'])) { $d = M('doctor'); $d = $d->where('cust_id', $input['cust_id'])->first(); if ($d) { log_him_in(['uid' => $d->id]); add_chara($input['user_type']); return ss(); } return $d ? ss($d) : ee(2); } if (!empty($input['user_type']) && !empty($input['username']) && !empty($input['password'])) { $input['password'] = hash_password($input['password']); $user = $this->user_exists($input['user_type'], array_only($input, ['username', 'password'])); if ($user) { log_him_in(['username' => $user->username, 'uid' => $user->id]); add_chara($input['user_type']); return ss(); } } else { return ee(2); } return ee(2); }
public function doctor($p = null) { if (!he_is('doctor') && !rq()) { return view('page.doctor_login'); } if (rq() && $p == 'login_check') { if (rq('user_type') == 'doctor') { $he = M('doctor')->where('cust_id', rq('cust_id'))->first(); if (!$he) { Session::flash('input_error', ['识别码有误']); return redirect('doctor/login'); } else { log_him_in(['uid' => $he->id]); add_chara(rq('user_type')); return redirect('doctor/home'); } } } $d = []; $appId = env('WECHAT_APPID'); $secret = env('WECHAT_SECRET'); $js = new Js($appId, $secret); $d['js'] = $js; switch ($p) { case 'history': $d['his_history'] = M('doctor')->get_his_history(); break; } return view('page.doctor_' . $p, $d); }
/** * 登入方法 * @param null $input * @return array */ public function login($input = null) { $input = $input ? $input : rq(); if (!empty($input['user_type']) && $input['user_type'] == 'doctor' && !empty($input['cust_id'])) { $d = M('doctor'); $d = $d->where('cust_id', $input['cust_id'])->first(); if ($d) { log_him_in(['uid' => $d->id]); add_chara($input['user_type']); return ss(); } return $d ? ss($d) : ee(2); } if (!empty($input['user_type']) && !empty($input['username']) && !empty($input['password'])) { $input['password'] = hash_password($input['password']); $user = $this->user_exists($input['user_type'], array_only($input, ['username', 'password'])); if ($user) { $lifetime = 6000; log_him_in(['username' => $user->username, 'uid' => $user->id], $lifetime); add_chara($input['user_type']); if ($input['user_type'] == 'employee') { sess('permission', $user->permissions); } else { sess('permission', []); } if ($input['user_type'] == 'agency') { sess('org', $user->name); sess('name_in_charge', $user->name_in_charge); } if ($input['user_type'] == 'department') { sess('org', $user->hospital_name . ':' . $user->name); } if ($input['user_type'] == 'employee') { sess('org', $user->name); } // 添加日志 ILog::login($input['user_type'], $user); return ss($user); } } else { return ee(2); } return ee(2); }