Browse Source

用户注册

master
ZLW-PC\Administrator 7 years ago
parent
commit
d92339a03b
  1. 15
      app/Http/Controllers/Api/UserController.php
  2. 26
      app/Http/Controllers/Weixin/UserController.php
  3. 4
      app/Http/Model/User.php
  4. 2
      resources/views/weixin/user/login.blade.php
  5. 29
      resources/views/weixin/user/register.blade.php
  6. 115
      resources/views/weixin/user/userinfo.blade.php

15
app/Http/Controllers/Api/UserController.php

@ -92,12 +92,25 @@ class UserController extends CommonController
$data['mobile'] = $request->input('mobile','');
$data['user_name'] = $request->input('user_name','');
$data['password'] = $request->input('password','');
$parent_mobile = $request->input('parent_mobile','');
if (($data['mobile']=='' && $data['user_name']=='') || $data['password']=='')
{
return ReturnData::create(ReturnData::PARAMS_ERROR);
}
if ($parent_mobile!='')
{
if($user = User::getOneUser(array('mobile'=>$parent_mobile)))
{
$data['parent_id'] = $user->id;
}
else
{
return ReturnData::create(ReturnData::PARAMS_ERROR,null,'推荐人手机号错误');
}
}
if (isset($data['mobile']) && !Helper::isValidMobile($data['mobile']))
{
return ReturnData::create(ReturnData::MOBILE_FORMAT_FAIL);
@ -111,7 +124,7 @@ class UserController extends CommonController
if (User::getOneUser(array('user_name'=>$data['user_name'])))
{
return ReturnData::create(ReturnData::SUCCESS,null,'用户名已存在');
return ReturnData::create(ReturnData::PARAMS_ERROR,null,'用户名已存在');
}
//添加用户

26
app/Http/Controllers/Weixin/UserController.php

@ -270,32 +270,6 @@ class UserController extends CommonController
header('Location: '.route('weixin_user'));exit;
}
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
if($_POST['user_name'] == '')
{
$this->error_jump('账号不能为空');
}
if($_POST['password'] == '')
{
$this->error_jump('密码不能为空');
}
$postdata = array(
'user_name' => $_POST['user_name'],
'password' => md5($_POST['password'])
);
$url = env('APP_API_URL')."/wx_login";
$res = curl_request($url,$postdata,'POST');
if($res['code'] != ReturnCode::SUCCESS_CODE){$this->error_jump('登录失败');}
$_SESSION['weixin_user_info'] = $res['data'];
header('Location: '.route('weixin_user'));exit;
}
return view('weixin.user.register');
}

4
app/Http/Model/User.php

@ -123,7 +123,6 @@ class User extends BaseModel
{
$user = self::where($where)->first();
if(!$user){return false;}
$user['reciever_address'] = UserAddress::getOne($user->address_id);
return $user;
}
@ -146,7 +145,8 @@ class User extends BaseModel
if(isset($user_name)){$data['user_name'] = $user_name;}
if(isset($mobile)){$data['mobile'] = $mobile;}
if(isset($password)){$data['password'] = $password;}
if(isset($password)){$data['password'] = $password;} //md5加密
if(isset($parent_id)){$data['parent_id'] = $parent_id;}
if (isset($data) && $id = self::add($data))
{

2
resources/views/weixin/user/login.blade.php

@ -46,7 +46,7 @@
<a style="margin:10px;background-color:#1aad19;text-align:center;color:white;border:1px solid #179e16;" class="bottoma" href="javascript:submit();">登录</a>
</div>
<div class="box reg">
<a style="float:left;" href="<?php echo route('weixin_register'); ?>">快速注册</a> <a style="float:right;" href="">忘记密码</a>
<a style="float:left;" href="<?php echo route('weixin_register'); ?>">快速注册</a> <a style="float:right;" href="">忘记密码</a>
</div>
<script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/md5.min.js"></script>
<script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/layer/mobile/layer.js"></script>

29
resources/views/weixin/user/register.blade.php

@ -42,17 +42,20 @@
<input type="text" name="mobile" class="" id="mobile" placeholder="请输入手机号码">
</div>
<div class="adr-form-group">
<input type="password" name="password" class="" id="password" placeholder="输入密码">
<input type="password" name="password" class="" id="password" placeholder="设置6-20位登录密码">
</div>
<div class="adr-form-group">
<input type="password" name="re_password" class="" id="re_password" placeholder="确认密码">
</div>
<div class="adr-form-group">
<input type="text" name="parent_mobile" class="" id="parent_mobile" placeholder="请输入推荐人手机号,选填">
</div>
</div>
</form>
<a style="margin:10px;background-color:#1aad19;text-align:center;color:white;border:1px solid #179e16;" class="bottoma" href="javascript:submit();">提交</a>
</div>
<div class="box reg">
<a style="float:left;" href="<?php echo route('weixin_login'); ?>">已有账号</a>
<a style="float:left;" href="<?php echo route('weixin_login'); ?>">已有账号</a> <span style="float:right;"><a href="<?php echo route('weixin_login'); ?>">注册协议</a></span>
</div>
<script type="text/javascript" src="<?php echo env('APP_URL'); ?>/js/md5.min.js"></script>
@ -64,10 +67,10 @@ function submit()
var mobile = $("#mobile").val();
var password = $("#password").val();
var re_password = $("#re_password").val();
var parent_mobile = $("#parent_mobile").val();
if(user_name == '')
{
//提示
layer.open({
content: '用户名不能为空'
,skin: 'msg'
@ -79,7 +82,6 @@ function submit()
if(mobile == '')
{
//提示
layer.open({
content: '手机号不能为空'
,skin: 'msg'
@ -91,7 +93,6 @@ function submit()
if(!validatemobile(mobile))
{
//提示
layer.open({
content: '手机号格式不正确'
,skin: 'msg'
@ -103,7 +104,6 @@ function submit()
if(password == '')
{
//提示
layer.open({
content: '密码不能为空'
,skin: 'msg'
@ -115,7 +115,6 @@ function submit()
if(password != re_password)
{
//提示
layer.open({
content: '两次密码不一致'
,skin: 'msg'
@ -125,25 +124,29 @@ function submit()
return false;
}
$("#login").submit();
/* $.post('<?php echo env('APP_API_URL').'/wx_login'; ?>',{user_name:user_name,password:md5(password)},function(res)
//$("#login").submit();
$.post('<?php echo env('APP_API_URL').'/wx_register'; ?>',{user_name:user_name,mobile:mobile,parent_mobile:parent_mobile,password:md5(password)},function(res)
{
if(res.code==0)
{
//提示
layer.open({
content: '登录成功'
content: '注册成功'
,skin: 'msg'
,time: 2 //2秒后自动关闭
});
location.href = '<?php if(isset($_SERVER["HTTP_REFERER"])){echo $_SERVER["HTTP_REFERER"];}else{echo route('weixin_user');} ?>';
setInterval(function(){location.href = '<?php echo route('weixin_login'); ?>';},5000);
}
else
{
layer.open({
content: res.msg
,skin: 'msg'
,time: 2 //2秒后自动关闭
});
}
},'json'); */
},'json');
}
</script>
@include('weixin.common.footer')

115
resources/views/weixin/user/userinfo.blade.php

@ -75,27 +75,130 @@ $(function(){
});
});
</script>
<li>
<a href="javascript:update_username();"><li>
<div class="ui-list-info">
<h4 class="ui-nowrap">用户名</h4>
<div class="ui-txt-info"><?php echo $user_info['user_name']; ?> &nbsp;</div>
</div>
<i class="fa fa-angle-right" aria-hidden="true"></i>
</li>
<li>
</li></a>
<style>
.adr_add{margin:0 10px;}
.adr-form-group input[type=text],.adr-form-group input[type=password]{display:block;width:100%;font-size:16px;padding:12px;color:#777;vertical-align:middle;background-color:#fff;background-image:none;border:1px solid #ddd;border-radius:0;box-sizing:border-box;}
</style>
<script>
function update_username()
{
//询问框
layer.open({
title: [
'用户名修改',
'background-color: #FF4351; color:#fff;'
]
,content: '<div class="adr-form-group"><input type="text" name="user_name" class="" id="user_name" placeholder="请输入用户名"></div>'
,btn: ['确定', '取消']
,yes: function(index){
var user_name = $("#user_name").val();
if(user_name == '')
{
layer.open({
content: '修改失败'
,skin: 'msg'
,time: 2 //2秒后自动关闭
});
}
else
{
location.reload();
}
layer.close(index);
}
});
}
</script>
<a href="javascript:update_nickname();"><li>
<div class="ui-list-info">
<h4 class="ui-nowrap">昵称</h4>
<div class="ui-txt-info"><?php echo $user_info['nickname']; ?> &nbsp;</div>
</div>
<i class="fa fa-angle-right" aria-hidden="true"></i>
</li>
<li>
</li></a>
<script>
function update_nickname()
{
//询问框
layer.open({
title: [
'昵称修改',
'background-color: #FF4351; color:#fff;'
]
,content: '<div class="adr-form-group"><input type="text" name="nickname" class="" id="nickname" placeholder="请输入用户名"></div>'
,btn: ['确定', '取消']
,yes: function(index){
var nickname = $("#nickname").val();
if(nickname == '')
{
layer.open({
content: '修改失败'
,skin: 'msg'
,time: 2 //2秒后自动关闭
});
}
else
{
location.reload();
}
layer.close(index);
}
});
}
</script>
<a href="javascript:update_sex();"><li>
<div class="ui-list-info">
<h4 class="ui-nowrap">性别</h4>
<div class="ui-txt-info"><?php if($user_info['sex']==0){echo '未知';}elseif($user_info['sex']==1){echo '男';}elseif($user_info['sex']==2){echo '女';} ?> &nbsp;</div>
</div>
<i class="fa fa-angle-right" aria-hidden="true"></i>
</li>
</li></a>
<script>
function update_sex()
{
//询问框
layer.open({
title: [
'性别修改',
'background-color: #FF4351; color:#fff;'
]
,content: '<div class="adr-form-group"><input type="text" name="sex" class="" id="sex" placeholder="请输入用户名"></div>'
,btn: ['确定', '取消']
,yes: function(index){
var sex = $("#sex").val();
if(sex == '')
{
layer.open({
content: '修改失败'
,skin: 'msg'
,time: 2 //2秒后自动关闭
});
}
else
{
location.reload();
}
layer.close(index);
}
});
}
</script>
</ul>
<ul class="fui-list mt10">

Loading…
Cancel
Save