public function SendCode() { $tel = I('tel'); if (preg_match("/1[3458]{1}\\d{9}\$/", $tel)) { import('Vendor.Sms.sms'); $sms = new \sms(); $mobile_code = phone_random(0, 9); $content = "您的验证码是:" . $mobile_code . "。请不要把验证码泄露给其他人。"; $result = $sms->sendTo($tel, $content); $date = array('tel' => $tel, 'authcode' => $mobile_code, 'create_time' => date("Y-m-d H:i:s")); if (2 == $result['code']) { M('t_authcode')->add($date); $this->ajaxReturn("1"); } else { $this->ajaxReturn($result); } } else { $this->ajaxReturn('手机号码不正确'); } }