public function findPassword($setp = 1) { switch ($setp) { case '1': $this->display(findPassword . '_1'); break; case '2': if (IS_POST) { /* 检测验证码 */ $sms_code = I('sms_code'); $code = cookie('_findPassword_code'); if (empty($code) || $code != $sms_code) { $this->error('验证码输入错误!'); } $mobile = I('mobile', '', 'trim'); if (empty($mobile)) { $this->error('用户名不能为空!'); } $User = new UserApi(); if (!$User->checkMobile($mobile)) { $this->error('用户名不存在!'); } cookie('_findPassword_check', 1, 120); cookie('_findPassword_mobile', $mobile, 120); $this->assign('username', $mobile); $this->display(findPassword . '_2'); } break; case '3': if (IS_POST) { if (!cookie('_findPassword_check')) { $this->error('验证失败!'); } $mobile = cookie('_findPassword_mobile'); $password = I('password', '', 'trim'); $Api = new UserApi(); if ($Api->findPassword($mobile, $password)) { $this->display(findPassword . '_3'); } else { $this->error('修改失败'); } } break; } }