getRequest()->get('mobile'); if (Utils::checkPhoneNumber($mobile) == false) { return $this->outJson(0, [], '手机号码格式不正确'); } $code = MailHelper::sendCodeSms($mobile); if ($code == null) { return $this->outJson(0, [], '短信发送失败,请稍后重试'); } return $this->outJson(1, ['code' => $code], 'OK'); } /** * 获取短信验证码 * @return \yii\web\Response */ public function actionGetCode() { $mobile = trim(Yii::$app->getRequest()->get('mobile')); if ($mobile == '') { return $this->outJson(0, [], '手机号码不能为空'); } $result = MailHelper::getCodeSms($mobile); return $this->outJson(1, $result, 'OK'); } }