コード例 #1
0
 /**
  * @title 用户注册
  *
  * @param int $mobile 手机号
  * @param string password 密码
  * @param string verifyCode 验证码
  * @param string uname 用户名 '' 不填则默认为手机号
  * @param string realname 真实姓名 '' 不填则为空
  * @param string channel 渠道
  * @param string device_code 设备码
  * @param string introducer 推荐码
  * @method post
  */
 public function reg()
 {
     $mobile = I('post.mobile');
     $password = I('post.password');
     $uname = I('post.uname');
     $realname = I('post.realname');
     $channel = I('post.channel');
     $device_code = I('post.device_code');
     $introducer = I('post.introducer');
     $userModel = new \Common\Model\UserModel();
     $verifyCode = I('post.verifyCode') or ajax_error('请输入手机验证码!');
     $userModel->verifyCode($mobile, $verifyCode) or ajax_error($userModel->getError());
     $uid = $userModel->addUser($mobile, $uname, $realname, $password, $introducer, $channel, $device_code);
     $uid or ajax_error($userModel->getError());
     // 进行自动登录
     $this->_login_success($uid);
 }
コード例 #2
0
 public function add()
 {
     if (IS_POST) {
         $mobile = I('post.mobile');
         $password = I('post.password');
         $repassword = I('post.repassword');
         $uname = I('post.uname');
         /* 检测密码 */
         if ($password != $repassword) {
             $this->error('密码和重复密码不一致!');
         }
         $userModel = new \Common\Model\UserModel();
         $uid = $userModel->addUser($mobile, $uname, $uname, $password);
         $_POST['uid'] = $uid;
         $this->_relaField(false);
         $infoModel = M('userInfo');
         $infoModel->create();
         $infoModel->save() !== false or $this->error($infoModel->getError());
         $this->success('用户添加成功!', U('index'));
     } else {
         $this->_initForm();
         $this->meta_title = '新增用户';
         $this->display('edit');
     }
 }
コード例 #3
0
 public function check_success($id)
 {
     $company = $this->find($id);
     if (!$company) {
         $this->error = '此商铺信息不存在!';
         return false;
     }
     if ($company['status'] == 1) {
         $this->error = '禁止操作:此商铺信息已审核通过,请刷新后重试';
         return false;
     }
     // 判断信息是否完善
     if (!$company['name']) {
         $this->error = '请先输入商铺名!';
         return false;
     }
     // 需更新的数据
     $data = ['status' => 1];
     // 关联账号
     if ($company['uid'] == 0) {
         // 未关联,则读取手机号
         $mobile = $company['telephone'];
         if (!preg_match('/^1\\d{10}$/', $mobile)) {
             $this->error = '自动关联商家账号时,无法读取正确的手机号!';
             return false;
         }
         $uname = $realname = trim($company['contact']);
         if (!$uname) {
             $this->error = '自动关联商家账号时,无法读取商家用户名!';
             return false;
         }
         $uid = M('user')->where(['mobile' => $mobile])->getField('uid');
         if (!$uid) {
             // 自动创建用户
             $userModel = new \Common\Model\UserModel();
             $uid = $userModel->addUser($mobile, $uname, $realname, uniqid());
             if (!$uname) {
                 $this->error = $userModel->getError();
                 return false;
             }
         }
         $data['uid'] = $uid;
     }
     $this->where(['id' => $id])->save($data);
     return true;
 }