86], [['type', 'cx_mch_id', 'user_id'], 'integer'], [['mobile', 'type', 'cx_mch_id', 'user_id'], 'required'], ]; } public function attributeLabels() { return [ 'mobile' => '手机号', 'mobile_prefix' => '手机号国家代码', 'type' => '短信验证码类型' ]; } public function sender() { if(!$this->validate()){ return $this->getModelError(); } //手机号格式验证码 if(!Validation::is_mobile($this->mobile, $this->mobile_prefix)){ return [ 'code' => 1, 'msg' => '手机号格式错误' ]; } try{ $sms_sender = new SmsMsgHelper($this->cx_mch_id); $tpl_type = SmsTpl::getTplKey($this->type); $data = $sms_sender->sender($this->mobile, $tpl_type, $this->mobile_prefix, $this->user_id); return $data; } catch (\Exception $ex){ return $this->apiReturnError($ex->getMessage()); } } }