一、在ecs_user表新增 (真实姓名) full_name、(身份证号) card_num、( 身份正面 ) idimg_one、(身份反面) idimg_two四个字段
ALTER TABLE `ecs_users` ADD `full_name` VARCHAR(10 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,ADD `card_num` VARCHAR(255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,ADD `idimg_one` VARCHAR(255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,ADD `idimg_two` VARCHAR(255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL二、打开 根目录/themes/default(模板名)/user.dwt
搜索:
客户服务
在搜索内容的上面添加下面的代码
实名验证
三、打开/include/apps/default/model/UserModel.class.php 文件
在get_profile()方法中查找以下代码:$sql = "SELECT user_name, birthday, sex, question, answer, rank_points, pay_points,user_money, user_rank," .用以下代码替换$sql = "SELECT user_name, birthday, sex, question, answer, rank_points, pay_points,user_money, user_rank, full_name, card_num, idimg_one, idimg_two," .查找以下代码:$info['user_rank'] = $infos['user_rank'];
在这段代码下面添加以下代码:$info['full_name'] = $infos['full_name'];$info['card_num'] = $infos['card_num'];$info['idimg_one'] = $infos['idimg_one'];$info['idimg_two'] = $infos['idimg_two'];
四、在ecs_order_info表新增 (真实姓名) full_name、(身份证号) card_num、( 身份正面 ) idimg_one、(身份反面) idimg_two四个字段
ALTER TABLE `ecs_order_info` ADD `full_name` VARCHAR(10 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,ADD `card_num` VARCHAR(255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,ADD `idimg_one` VARCHAR(255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,ADD `idimg_two` VARCHAR(255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL五、找到themes/default/flow_checkout.dwt模板文件
查找以下代码:
查找以下代码:用以下代码替换:
在页面拉到最后面,在最下面添加functionyzxinx()
{var pdygd = $('#pdygd').val();if(pdygd == 0)
{
alert("请输入身份信息,并提交您的信息");location.href="{:url('flow/identity_info')}";return false;
}
}六、打开/include/apps/default/controller/FlowController.class.php 文件
查找以下代码://检查用户是否已经登录 如果用户已经登录了则检查是否有默认的收货地址 如果没有登录则跳转到登录和注册页面
在这段代码上面添加以下代码:/**身份信息
*判断用户身份是否有数据,有传值1,没有传值0*/
$oks=1;$nos=0;$where['user_id'] = $_SESSION['user_id'];$result = $this->model->table('users')->field('full_name, card_num, idimg_one, idimg_two')->where($where)->find();if(empty($result['idimg_two']) && empty($result['idimg_one'])){$this->assign('pdygd',$nos);
}else{$this->assign('pdygd',$oks);
}/*身份信息*/查找以下代码:/*对是否允许修改购物车赋值*/在这段代码上面添加以下代码:/*获取用户身份信息*/
$user_list = $this->model->table('users')->where('user_id = '.$_SESSION['user_id'])->find();$this->assign('profile',$user_list);
七、
打开/include/apps/default/controller/FlowController.class.phh
(若有MY_FlowController.class.php就在MY_Flow....) 文件
查找以下代码://订单信息
在这段代码上面添加以下代码://获取身份信息
$where['user_id'] = $_SESSION['user_id'];$res = $this->model->table('users')->field('full_name, card_num, idimg_one, idimg_two')->where($where)->find();
查找以下代码:$order = array(
在这段代码下面添加以下代码:'full_name' => $res['full_name'],
'card_num' => $res['card_num'],
'idimg_one' => $res['idimg_one'],
'idimg_two' => $res['idimg_two'],把下面的两个方法放到flow控制机的最下面/**实名认证**/
public functionidentity_info()
{if(IS_POST)
{/*身份证验证*/
$full_name = I('post.full_name');$card_num = I('post.card_num');//只更新姓名或者身份证号
if($_FILES['idimg_one']['size'] == 0 && $_FILES['idimg_two']['size'] == 0){$data = array('full_name' => $full_name,
'card_num' => $card_num);$this->model->table('users')->data($data)->where('user_id = '.$_SESSION['user_id'])->update();
ecs_header("Location: " . url('flow/checkout') . "\n");exit;
}//如果上传了其中一张图片
if($_FILES['idimg_one']['size'] == 0 || $_FILES['idimg_two']['size'] == 0){
show_message('请同时上传身份证的正反面', '', '');exit;
}//用户如果上传了2张图片
if($_FILES['idimg_one']['size'] != 0 && $_FILES['idimg_two']['size'] != 0){/*图片处理*/
$image = new EcsImage($_CFG['bgcolor']);if (!$image->check_img_type($_FILES['idimg_one']['type']) || !$image->check_img_type($_FILES['idimg_two']['type']))
{
show_message("图片格式不正确!");
}//检查是否存在上传的身份证图片,如果有则删除
$user_id = $_SESSION['user_id'];$sql = 'select idimg_one,idimg_two from ' . $this->model->pre . "users where user_id ='$user_id'";$card_img = $this->model->getRow($sql);if($card_img['idimg_one'] != '' || $card_img['idimg_two'] != '')
{//echo $card_img['idimg_one'];
@unlink('../'.$card_img['idimg_one']);
@unlink('../'.$card_img['idimg_two']);
}//生成随机文件名
$img_name2 = date("Ymd-His") .'.'. end(explode('.', $_FILES['idimg_two']['name']));$target2 = __ROOT__ . '/' .DATA_DIR . '/idimg_two/';$original_img2 = $image->upload_image($_FILES['idimg_two'], 'idimg_two', $img_name2); //原始图片
$idimg_two = $image->make_thumb($original_img2, '', '', $target2);if ($idimg_two === false)
{
show_message("图片保存出错!");
}$img_name1 = date("Ymd-His") .'.'. end(explode('.', $_FILES['idimg_one']['name']));$target1 = __ROOT__ . '/' .DATA_DIR . '/idimg_one/';$original_img1 = $image->upload_image($_FILES['idimg_one'], 'idimg_one', $img_name1); //原始图片
$idimg_one = $image->make_thumb($original_img1, '', '', $target1);if ($idimg_one === false)
{
show_message("图片保存出错!");
}/*需要增加判断,根据数据库中信息是否存在执行insert还是update*/
$res_s = $this->model->table('users')->where('user_id = '.$_SESSION['user_id'])->find();if(empty($res_s)){/*用户信息不存在,则执行插入操作*/
$data = array('full_name' => $full_name,
'card_num' => $card_num,
'idimg_one' => $target1.$img_name1,
'idimg_two' => $target2.$img_name2);$this->model->table('users')->data($data)->where('user_id = '.$_SESSION['user_id'])->insert();
ecs_header("Location: " . url('flow/checkout') . "\n");exit;
}else{/*用户信息存在,则执行更新操作*/
$data = array('full_name' => $full_name,
'card_num' => $card_num,
'idimg_one' => $target1.$img_name1,
'idimg_two' => $target2.$img_name2);$this->model->table('users')->data($data)->where('user_id = '.$_SESSION['user_id'])->update();
ecs_header("Location: " . url('flow/checkout') . "\n");exit;
}
}/*身份证验证*/
//用户资料
}$user_id=$_SESSION['user_id'];$user_info = model('Users')->get_profile($user_id);$this->assign('profile', $user_info);$this->display('flow_identity_info.dwt');
}/**实名认证**/
public functionidentity_in()
{if(IS_POST)
{/*身份证验证*/
$full_name = I('post.full_name');$card_num = I('post.card_num');//只更新姓名或者身份证号
if($_FILES['idimg_one']['size'] == 0 && $_FILES['idimg_two']['size'] == 0){$data = array('full_name' => $full_name,
'card_num' => $card_num);$this->model->table('users')->data($data)->where('user_id = '.$_SESSION['user_id'])->update();
show_message('更新用户信息成功', '', '');exit;
}//如果上传了其中一张图片
if($_FILES['idimg_one']['size'] == 0 || $_FILES['idimg_two']['size'] == 0){
show_message('请同时上传身份证的正反面', '', '');exit;
}//用户如果上传了2张图片
if($_FILES['idimg_one']['size'] != 0 && $_FILES['idimg_two']['size'] != 0){/*图片处理*/
$image = new EcsImage($_CFG['bgcolor']);if (!$image->check_img_type($_FILES['idimg_one']['type']) || !$image->check_img_type($_FILES['idimg_two']['type']))
{
show_message("图片格式不正确!");
}//检查是否存在上传的身份证图片,如果有则删除
$user_id = $_SESSION['user_id'];$sql = 'select idimg_one,idimg_two from ' . $this->model->pre . "users where user_id ='$user_id'";$card_img = $this->model->getRow($sql);if($card_img['idimg_one'] != '' || $card_img['idimg_two'] != '')
{//echo $card_img['idimg_one'];
@unlink('../'.$card_img['idimg_one']);
@unlink('../'.$card_img['idimg_two']);
}//生成随机文件名
$img_name2 = date("Ymd-His") .'.'. end(explode('.', $_FILES['idimg_two']['name']));$target2 = __ROOT__ . '/' .DATA_DIR . '/idimg_two/';$original_img2 = $image->upload_image($_FILES['idimg_two'], 'idimg_two', $img_name2); //原始图片
$idimg_two = $image->make_thumb($original_img2, '', '', $target2);if ($idimg_two === false)
{
show_message("图片保存出错!");
}$img_name1 = date("Ymd-His") .'.'. end(explode('.', $_FILES['idimg_one']['name']));$target1 = __ROOT__ . '/' .DATA_DIR . '/idimg_one/';$original_img1 = $image->upload_image($_FILES['idimg_one'], 'idimg_one', $img_name1); //原始图片
$idimg_one = $image->make_thumb($original_img1, '', '', $target1);if ($idimg_one === false)
{
show_message("图片保存出错!");
}/*需要增加判断,根据数据库中信息是否存在执行insert还是update*/
$res_s = $this->model->table('users')->where('user_id = '.$_SESSION['user_id'])->find();if(empty($res_s)){/*用户信息不存在,则执行插入操作*/
$data = array('full_name' => $full_name,
'card_num' => $card_num,
'idimg_one' => $target1.$img_name1,
'idimg_two' => $target2.$img_name2);$this->model->table('users')->data($data)->where('user_id = '.$_SESSION['user_id'])->insert();
show_message('更新用户信息成功', '', '');exit;
}else{/*用户信息存在,则执行更新操作*/
$data = array('full_name' => $full_name,
'card_num' => $card_num,
'idimg_one' => $target1.$img_name1,
'idimg_two' => $target2.$img_name2);$this->model->table('users')->data($data)->where('user_id = '.$_SESSION['user_id'])->update();
show_message('更新用户信息成功', '', '');exit;
}
}/*身份证验证*/
//用户资料
}$user_id=$_SESSION['user_id'];$user_info = model('Users')->get_profile($user_id);$this->assign('profile', $user_info);$this->display('flow_identity_in.dwt');
}
七 找到 根目录/admin/templates/order_info.htm
搜索:
{$order.card_num|escape}在上面的代码下面添加