用户注册账号

admin1年前Laravel493

public function register()
{
   $mobile = request()->input('mobile');
   $code = request()->input('code');
   $pwd = request()->input('pwd'); // 密码
   $rpwd = request()->input('rpwd'); // 密码

   if (empty($mobile)) {
       return $this->error('请输入手机号');
   }
   if (empty($code)) {
       return $this->error('请输入验证码');
   }
   if (empty($pwd)) {
       return $this->error('请输入密码');
   }
   if (empty($rpwd)) {
       return $this->error('请输入确认密码');
   }

   if ($pwd != $rpwd) {
       return $this->error('两次密码不一样');
   }

   if (!$this->phone($mobile)) {
       return $this->error('手机号格式不正确');
   }

   $nums = Db::table('member')->where(array('mobile' => $mobile, 'status' => 1))->count();
   if ($nums) {
       return $this->error('手机号已存在');
   }

   $this->verfiy($mobile, $code);

   $data['mobile'] = $mobile;
   $data['pwd'] = md5($this->md5 . $pwd);
   $data['time'] = time();
   $data['status'] = 1;
   Db::beginTransaction();
   $info = Db::table('member')->insertGetId($data);
   if ($info) {
       Db::commit();
       $token = JWT::encode($info, self::$tokenKey);
       return $this->success('注册成功', $token);
   } else {
       Db::rollBack();
       return $this->error('注册失败');
   }
}

相关文章

下载文件

public function img_url() { $id = request()->param('id', 1122); $info = Db::name('...

解密微信绑定的手机号

public function mobile() { $code = request()->input('code'); if (!$code) { return $this-&...

查找下级所有数据

public function bottom($mid = 3){    $members = DB::select('select id,parent_id,`level...

关注公众号并登录

/* * 服务端生成带唯一标识二维码并将唯一标识返回给前端 */ public function wx_code() { $scene_str = $this->get_...

生成唯一的订单号

public function get_order_sn() {     return date('Ymd') ...

修改密码

public function setpass(){    $mobile = request()->input('mobile');   &nbs...