<?php
namespace app\validate;

use think\Validate;

class Login extends Validate
{
    protected $regSmsRule = [
        'phone'         => 'require|mobile',
        'sms_code'      => 'require|length:4,20',
    ];
    protected $regSmsMessage    = [
        'phone.require'             => '手机号必填！',
        'phone.mobile'              => '请输入正确格式的手机号！',
        'sms_code.require'          => '短信验证码必填！',
        'sms_code.length'           => '短信验证码错误！',
    ];

    protected $registerRule = [
        //'industry_code' => 'require',
        //'company_size'  => 'require',
        'team_name'     => 'require|length:2,200',
        'email'         => 'require|length:6,100',
        'password'      => 'require|length:6,20|alphaNum',
        'second_domain' => 'require|length:4,12|alphaNum',
    ];
    protected $registerMessage = [
        'industry_code.require'     => '所属行业必须！',
        'company_size.require'      => '公司规模必须！',
        'team_name.require'         => '公司或团队名称必填！',
        'team_name.length'          => '请输入正确的公司或团队名称！',
        'email.require'             => '邮箱必填！',
        'email.length'              => '邮箱地址格式不正确！',
        'password.require'          => '密码必填！',
        'password.length'           => '密码格式错误！密码由6-20位数字和大小写字母组成',
        'password.alphaNum'         => '密码格式错误！密码由6-20位数字和大小写字母组成',
        'second_domain.require'     => '二级域名必填！',
        'second_domain.length'      => '二级域名格式错误！二级域名由4-12位数字或字母组成',
        'second_domain.alphaNum'    => '二级域名格式错误！二级域名由4-12位数字或字母组成',
    ];

    protected $phoneRule    = [
        'phone'             => 'require|length:11|mobile'
    ];
    protected $phoneMessage     = [
        'phone.require'             => '手机号必填！',
        'phone.length'              => '请输入正确格式的手机号！',
        'phone.mobile'              => '手机号错误！',
    ];

    public function regSmsCheck($data)
    {
        $this->rule     = $this->regSmsRule;
        $this->message  = $this->regSmsMessage;

        return $this->check($data);
    }

    public function registerCheck($data)
    {
        $this->rule     = $this->registerRule;
        $this->message  = $this->registerMessage;

        return $this->check($data);
    }

    public function phoneCheck($data)
    {
        $this->rule     = $this->phoneRule;
        $this->message  = $this->phoneMessage;
        return $this->check($data);
    }
}