48 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			PHP
		
	
	
			
		
		
	
	
			48 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			PHP
		
	
	
| <?php
 | |
| 
 | |
| namespace app\validate;
 | |
| 
 | |
| use think\Validate;
 | |
| 
 | |
| class User extends Validate
 | |
| {
 | |
|     protected $rule = [
 | |
|         'username|用户名或手机号' => 'require',
 | |
|         'password|密码'      => 'require|min:4|max:16',
 | |
| 
 | |
|         'code|小程序code'    => 'require',
 | |
|         'nickname|昵称'     => 'max:100',
 | |
|         'headimgurl|头像'   => 'max:300',
 | |
|         'country|国家'      => 'max:100',
 | |
|         'province|省份'     => 'max:100',
 | |
|         'city|城市'         => 'max:100',
 | |
|         'county|区、县'      => 'max:250',
 | |
|         'mobile|手机号'      => 'mobile|max:20',
 | |
|         'invite_code|邀请码' => 'max:100',
 | |
|         'channel|来源渠道'    => 'max:200',
 | |
|         'birthday|出生年月'   => 'date',
 | |
|         'source_code|来源码' => 'max:250',
 | |
| 
 | |
|         'name|姓名'         => 'require',
 | |
|         'user_id|用户ID'    => 'require|number|gt:0',
 | |
|         'phone|联系方式'      => 'require',
 | |
|         'address|详细地址'    => 'require',
 | |
|         'province_str|省份' => 'require',
 | |
|         'city_str|城市'     => 'require',
 | |
|         'county_str|区、县'  => 'require',
 | |
|     ];
 | |
| 
 | |
|     protected $scene = [
 | |
|         'base'       => ['username', 'password'],//普通模式
 | |
|         'wechat'     => ['username'],//微信公众号登录
 | |
|         'qq'         => ['username'],//qq登录
 | |
|         'address'    => [
 | |
|             'user_id', 'name', 'phone', 'province', 'city', 'county', 'address',
 | |
|             'province_str', 'city_str', 'county_str'
 | |
|         ],//地址管理
 | |
|         // 微信小程序登录
 | |
|         'wx_applets' => ['code', 'nickname', 'headimgurl', 'country', 'province', 'city', 'mobile', 'invite_code', 'channel', 'source_code'],
 | |
|         // 修改用户信息
 | |
|         'edit'       => ['real_name', 'nickname', 'headimgurl', 'mobile', 'gender', 'province', 'city', 'county', 'birthday'],
 | |
|     ];
 | |
| } |