Kaynağa Gözat

增加身份证注册,在默认主题,sunning主题,后台管理全部新增,验证组件增加身份证18位、15位校验正则表达式

project 7 yıl önce
ebeveyn
işleme
4e91a64eed

+ 25 - 0
src/controllers/member.php

@@ -54,6 +54,10 @@ class Member extends IController implements adminAuthorization
 		$repassword = IFilter::act(IReq::get('repassword'));
 		$group_id   = IFilter::act(IReq::get('group_id'),'int');
 		$truename   = IFilter::act(IReq::get('true_name'));
+
+		//add by Scott Chen on 2017-11-03
+        $id_type   = IFilter::act(IReq::get('id_type'));
+        $id_code   = IFilter::act(IReq::get('id_code'));
 		$sex        = IFilter::act(IReq::get('sex'),'int');
 		$telephone  = IFilter::act(IReq::get('telephone'));
 		$mobile     = IFilter::act(IReq::get('mobile'));
@@ -102,6 +106,23 @@ class Member extends IController implements adminAuthorization
 			$this->setError('手机号码重复');
 		}
 
+
+
+        //add by Scott Chen on 2017-11-03
+        //id_type
+        if ($id_type != "1") {
+            return "证件类型目前只支持身份证";
+        }
+        if (IValidate::id_ex_18($id_code) == false) {
+            return "非法身份证号码";
+        }else{
+            $memberRow = $memberDB->getObj(" id_type='" . $id_type . "' and id_code='" . $id_code ."' and user_id != ".$user_id);
+            if($memberRow)
+            {
+                $this->setError('证件类型,证件号码重复');
+            }
+        }
+
 		//操作失败表单回填
 		if($errorMsg = $this->getError())
 		{
@@ -113,6 +134,10 @@ class Member extends IController implements adminAuthorization
 		$member = array(
 			'email'        => $email,
 			'true_name'    => $truename,
+
+            //add by Scott Chen on 2017-11-03
+			'id_type'    => $id_type,
+			'id_code'    => $id_code,
 			'telephone'    => $telephone,
 			'mobile'       => $mobile,
 			'area'         => $_POST['area'],

+ 26 - 0
src/lib/core/util/validate_class.php

@@ -165,4 +165,30 @@ class IValidate
     {
     	return (bool)preg_match("|^[\w\.\,\-<>=\!\x{4e00}-\x{9fa5}\s*]+$|u",$str);
     }
+
+
+    /**
+     * add by Scott Chen on 2017-11-03
+     * @brief 身份证18位格式验证
+     * @param string $str 需要验证的字符串
+     * @return bool 验证通过返回 true 不通过返回 false
+     */
+    public static function id_ex_18($str='')
+    {
+        return (bool)preg_match('/^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/i',$str);
+    }
+
+    /**
+     * add by Scott Chen on 2017-11-03
+     * @brief 身份证15位格式验证
+     * @param string $str 需要验证的字符串
+     * @return bool 验证通过返回 true 不通过返回 false
+     */
+    public static function id_ex_15($str='')
+    {
+        return (bool)preg_match('/^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}[0-9Xx]$/i',$str);
+    }
+
+
+
 }

+ 5 - 0
src/lib/web/js/source/autovalidate/validate.js

@@ -86,6 +86,11 @@
 			case 'int':	pattern = /^\d+$/i;break;
 			case 'float': pattern = /^\d+\.?\d*$/i;break;
 			case 'percent': pattern = /^[1-9][0-9]*$/;break;
+
+			//add by Scott Chen on 2017-11-03
+			case 'id_ex_18': pattern=/^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/i;break;
+			case 'id_ex_15': pattern=/^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}[0-9Xx]$/i;break;
+
 		}
         var value = this.value;
         var alt = textfield.getAttribute("alt");

+ 31 - 2
src/plugins/_userInfo/_userInfo.php

@@ -149,7 +149,15 @@ class _userInfo extends pluginBase
     	$password   = IFilter::act(IReq::get('password','post'));
     	$repassword = IFilter::act(IReq::get('repassword','post'));
     	$captcha    = IFilter::act(IReq::get('captcha','post'));
-    	$_captcha   = ISafe::get('captcha');
+
+        //add by Scott Chen on 2017-11-03
+        //id_type
+        $true_name   = IFilter::act(IReq::get('true_name','post'));
+        $id_type    = IFilter::act(IReq::get('id_type','post'));
+        $id_code   = IFilter::act(IReq::get('id_code','post'));
+
+
+        $_captcha   = ISafe::get('captcha');
 
     	//获取注册配置参数
 		$siteConfig = new Config('site_config');
@@ -236,7 +244,25 @@ class _userInfo extends pluginBase
 			}
     	}
 
-		//插入user表
+        //add by Scott Chen on 2017-11-03
+        //id_type
+        if ($id_type != "1") {
+            return "证件类型目前只支持身份证";
+        }
+        if (IValidate::id_ex_18($id_code) == false) {
+            return "非法身份证号码";
+        }else{
+            $memberDB = new IQuery('member');
+            $memberDB->setWhere(" id_type='" . $id_type . "' and id_code='" . $id_code . "'");
+            $memberRow = $memberDB->find();
+            if($memberRow)
+            {
+                return "证件类型为身份证, 证件号码为: ". $id_code . ", 已经被注册";
+            }
+        }
+
+
+        //插入user表
 		$userArray = array(
 			'username' => $username,
 			'password' => md5($password),
@@ -256,6 +282,9 @@ class _userInfo extends pluginBase
 			'status'  => $reg_option == 1 ? 3 : 1,
 			'mobile'  => $mobile,
 			'email'   => $email,
+            'true_name' => $true_name,
+            'id_type' => $id_type,
+            'id_code' => $id_code
 		);
 		$memberObj = new IModel('member');
 		$memberObj->setData($memberArray);

+ 28 - 0
src/views/default/simple/reg.html

@@ -14,6 +14,34 @@
 					<tr><th>邮箱:</th><td><input class="gray" type="text" name='email' pattern="email" alt="填写正确的邮箱格式" /><label>填写正确的邮箱格式</label></td></tr>
 					{/if}
 					<tr><th>用户名:</th><td><input class="gray" name='username' type="text" pattern="^[\w\u0391-\uFFE5]{2,20}$" alt="填写2-20个字符,可以为字母、数字、下划线和中文" /><label>请填写用户名,格式为2-20个字符,可以为字母、数字、下划线和中文</label></td></tr>
+
+					<!-- add by Scott Chen on 2017-11-03  -->
+					<!-- id_type beg -->
+					<tr>
+						<th>真实姓名:</th>
+						<td>
+							<input class="gray" name='true_name' type="text" pattern="^[\u4e00-\u9fa5]{2,20}$" alt="填写2-20个中文汉字">
+							<label>填写2-20个中文汉字</label>
+						</td>
+					</tr>
+					<tr>
+						<th>证件类型:</th>
+						<td>
+							<select class="gray" name="id_type" style="width:250px;heigh:38px;line-height:38px;">
+								<option value="1" selected>身份证</option>
+							</select>
+							<label>仅支持身份证</label>
+						</td>
+					</tr>
+					<tr>
+						<th>证件号码:</th>
+						<td>
+							<input class="gray" name="id_code" type="text" pattern="id_ex_18" alt="填写合法身份证号码">
+							<label>填写合法身份证号码</label>
+						</td>
+					</tr>
+					<!-- id_type end -->
+
 					<tr><th>设置密码:</th><td><input class="gray" type="password" name='password' pattern="^\S{6,32}$" bind='repassword' alt='填写6-32个字符' /><label>填写登录密码,6-32个字符</label></td></tr>
 					<tr><th>确认密码:</th><td><input class="gray" type="password" name='repassword' pattern="^\S{6,32}$" bind='password' alt='重复上面所填写的密码' /><label>重复上面所填写的密码</label></td></tr>
 					<tr><th>验证码:</th><td><input class='gray_s' type='text' name='captcha' pattern='^\w{5,10}$' alt='填写图片所示的字符' /><img src='{url:/simple/getCaptcha}' id='captchaImg' onclick="changeCaptcha();" /><label>填写图片所示的字符</label></td></tr>

+ 26 - 1
src/views/default/ucenter/info.html

@@ -36,10 +36,35 @@
 			<table class="form_table" width="100%" cellpadding="0" cellspacing="0">
 				<col width="120px" />
 				<col />
+
+				<tr>
+					<th></th>
+					<td style="font-size:16px; font-weight: bolder;color:red;">真实姓名、证件号码修改,请联系官方客服</td>
+				</tr>
+
+				<!-- add by Scott Chen on 2017-11-03  -->
+				<!-- id_type beg -->
 				<tr>
-					<th>姓名:</th><td><input class="normal" type="text" name="true_name" alt='请填写真实姓名' /></td>
+					<th>真实姓名:</th>
+					<td>
+						<input class='normal' type="text" name="true_name" value="{$this->memberRow['true_name']}" readonly style="background-color: #e4e4e4"/>
+					</td>
 				</tr>
 				<tr>
+					<th>证件类型:</th>
+					<td>
+						{if:$this->memberRow['id_type']=='1'}身份证{elseif:$this->memberRow['id_type']==null || empty($this->memberRow['id_type'])}-{else:}其它{/if}
+					</td>
+				</tr>
+				<tr>
+					<th>证件号码:</th>
+					<td>
+						<input class='normal' name='id_code' type="text" value="{$this->memberRow['id_code']}" readonly style="background-color: #e4e4e4">
+					</td>
+				</tr>
+				<!-- id_type end -->
+
+				<tr>
 					<th>性别:</th>
 					<td>
 						<label class='attr'><input type='radio' name='sex' value='1' />男</label>

+ 31 - 0
src/views/suning/simple/reg.html

@@ -9,6 +9,10 @@
 	</header>
 	<section class="reg_box">
 		<form action='{url:/simple/reg_act}' method='post'>
+			<dl>
+				<dt></dt>
+				<dd style="font-size:16px; font-weight: bolder;color:red;">请填写真实姓名,身份证号码,否则所购商品不能正常通过海关</dd>
+			</dl>
 			{if:$this->_siteConfig->reg_option == 1}
 			<dl>
 				<dt>邮箱:</dt>
@@ -25,6 +29,33 @@
 					<span>请填写用户名,格式为2-20个字符,可以为字母,数字下划线和中文</span>
 				</dd>
 			</dl>
+
+			<!-- add by Scott Chen on 2017-11-03  -->
+			<!-- id_type beg -->
+			<dl>
+				<dt>真实姓名:</dt>
+				<dd>
+					<input class="input_text" name='true_name' type="text" pattern="^[\u4e00-\u9fa5]{2,20}$" alt="填写2-20个中文汉字">
+					<span>填写2-20个中文汉字</span>
+				</dd>
+			</dl>
+			<dl>
+				<dt>证件类型:</dt>
+				<dd>
+					<select name="id_type" style="width:210px;">
+						<option value="1" selected>身份证</option>
+					</select>
+					<span>仅支持身份证</span>
+				</dd>
+			</dl>
+			<dl>
+				<dt>证件号码:</dt>
+				<dd>
+					<input class="input_text" name="id_code" type="text" pattern="id_ex_18" alt="填写合法身份证号码">
+					<span>填写合法身份证号码</span>
+				</dd>
+			</dl>
+			<!-- id_type end -->
 			<dl>
 				<dt>设置密码:</dt>
 				<dd>

+ 24 - 2
src/views/suning/ucenter/info.html

@@ -8,6 +8,10 @@
 <section class="user_form">
 	<form action='{url:/ucenter/info_edit_act}' method='post' name='user_info'>
 		<dl>
+			<dt></dt>
+			<dd style="font-size:16px; font-weight: bolder;color:red;">真实姓名、证件号码修改,请联系官方客服</dd>
+		</dl>
+		<dl>
 			<dt>头像:</dt>
 			<dd>{set:$user_ico = $this->user['head_ico']}
 				<div class="user_ico">
@@ -24,11 +28,29 @@
 			</dd>
 		</dl>
 		{/if}
+
+		<!-- add by Scott Chen on 2017-11-03  -->
+		<!-- id_type beg -->
 		<dl>
-			<dt>姓名:</dt>
-			<dd><input class="input_text" type="text" name="true_name" alt='请填写真实姓名' /></dd>
+			<dt>真实姓名:</dt>
+			<dd>
+				<input class="input_text"  type="text" name="true_name" value="{$this->memberRow['true_name']}" readonly/>
+			</dd>
 		</dl>
 		<dl>
+			<dt>证件类型:</dt>
+			<dd>
+				{if:$this->memberRow['id_type']=='1'}身份证{elseif:$this->memberRow['id_type']==null || empty($this->memberRow['id_type'])}-{else:}其它{/if}
+			</dd>
+		</dl>
+		<dl>
+			<dt>证件号码:</dt>
+			<dd>
+				<input class="input_text" name='id_code' type="text" value="{$this->memberRow['id_code']}" readonly>
+			</dd>
+			</dl>
+		<!-- id_type end -->
+		<dl>
 			<dt>性别:</dt>
 			<dd>
 				<label class='attr'><input type='radio' name='sex' value='1' />男</label>

+ 26 - 2
src/views/sysdefault/member/member_edit.html

@@ -39,9 +39,33 @@
 						</td>
 					</tr>
 					<tr>
-						<th>姓名:</th>
-						<td><input class="normal" name="true_name" type="text" value="" /><label>真实姓名</label></td>
+						<th>真实姓名:</th>
+						<td><input class="normal" name="true_name" type="text" value=""  pattern="^[\u4e00-\u9fa5]{2,20}$" alt="填写2-20个中文汉字"/>
+							<label>* 真实姓名(必填)</label>
+						</td>
 					</tr>
+
+					<!-- add by Scott Chen on 2017-11-03  -->
+					<!-- id_type beg -->
+					<tr>
+						<th>证件类型:</th>
+						<td>
+							<select  class="normal" name="id_type">
+								<option value="1" selected>身份证</option>
+								<option value="2">其它</option>
+							</select>
+						</td>
+					</tr>
+					<tr>
+						<th>证件号码:</th>
+						<td>
+							<!--<input class="input_text" name='id_code' type="text" pattern="^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$" alt="填写合法身份证号码">-->
+							<input class="normal" name="id_code" type="text" pattern="id_ex_18" alt="填写合法身份证号码">
+							<label>* 证件号码(必填)</label>
+						</td>>
+					</tr>
+					<!-- id_type end -->
+
 					<tr>
 						<th>性别:</th>
 						<td>

+ 15 - 3
src/views/sysdefault/member/member_list.html

@@ -33,8 +33,12 @@
 				<col width="120px" />
 				<col width="80px" />
 				<col width="80px" />
+				<!-- <!-- add by Scott Chen on 2017-11-03  -->
+				<col width="70px" />
+				<col width="140px" />
+
 				<col width="50px" />
-				<col width="140px"/>
+				<!--<col width="140px"/>-->
 				<col width="80px" />
 				<col width="70px" />
 				<col width="50px" />
@@ -49,8 +53,12 @@
 					<th>用户名</th>
 					<th>会员等级</th>
 					<th>姓名</th>
+					<!-- <!-- add by Scott Chen on 2017-11-03  -->
+					<th>证件类型</th>
+					<th>证件号码</th>
+
 					<th>性别</th>
-					<th>Email</th>
+					<!--<th>Email</th>-->
 					<th>余额</th>
 					<th>积分</th>
 					<th>状态</th>
@@ -68,8 +76,12 @@
 					<td title="{echo:htmlspecialchars($item['username'])}">{$item['username']}</td>
 					<td title="{$group[$item['group_id']]}">{$group[$item['group_id']]}</td>
 					<td title="{echo:htmlspecialchars($item['true_name'])}">{$item['true_name']}</td>
+
+					<!-- <!-- add by Scott Chen on 2017-11-03  -->
+					<td>{if:$item['id_type']=='1'}身份证{elseif:$item['id_type']==null || empty($item['id_type'])}-{else:}其它{/if}</td>
+					<td title="{echo:htmlspecialchars($item['id_code'])}">{$item['id_code']}</td>
 					<td>{if:$item['sex']=='1'}男{else:}女{/if}</td>
-					<td title="{echo:htmlspecialchars($item['email'])}">{$item['email']}</td>
+					<!--<td title="{echo:htmlspecialchars($item['email'])}">{$item['email']}</td>-->
 					<td title="{$item['balance']}">{$item['balance']}</td>
 					<td title="{$item['point']}">{$item['point']}</td>
 					<td title="{echo:Common::userStatusText($item['status'])}">{echo:Common::userStatusText($item['status'])}</td>