display(); } public function register(){ $this->display(); } public function set_message($status=0,$info='',$url=''){ $data = array( "status" => $status, "return_code" => $info, "url" => $url ); echo str_replace("[]","{}",json_encode($data)); } /** * 获取分享链接 * @param $token * author: xmy 280564871@qq.com */ public function get_share_url($account){ $url = U("Share/register",['invite_account'=>$account],true,true); return $url; } /** * 发送验证码 * @param $phone 手机号 * @param int $type 1:验证账号 2:不验证 * author: xmy 280564871@qq.com */ public function send_msg($phone, $type = 1) { if (empty($phone)) { $this->set_message(1029, "手机号不能为空"); } $user = new UserLogic(); if ($type == 2 || $user->checkUserExist($phone)) { $result = $user::sendMsg($phone); if ($result) { $this->set_message(200, "发送成功");exit; } else { $this->set_message(1018, "发送失败");exit; } } else { $this->set_message(1017, "用户已存在");exit; } } /** * 邀请好友注册 * @param $phone * @param $password * @param $v_code * @param string $invite_account * author: xmy 280564871@qq.com */ public function share_register($phone,$password,$v_code,$invite_account="") { #验证短信验证码 $code_result = UserLogic::smsVerify($phone,$v_code); if($code_result == UserLogic::RETURN_SUCCESS) { $user['account'] = $phone; $user['password'] = $password; $user['nickname'] = $phone; $user = SafeFilter($user); $result = 1; if (C('UC_SET') == 1) { //UC注册 $result = D('User', 'Logic')->userRegisterByUc($user); } if ($result > 0) { $result = D('User', 'Logic')->userRegisterByApp($user); } if($result < 0){ switch($result) { case -1:{ $msg='用户名不合法'; };break; case -2:{ $msg='包含不允许注册的词语'; };break; case -3:{ $msg='用户名已经存在'; };break; case -4:{ $msg='Email 格式有误'; };break; case -5:{ $msg='Email 不允许注册'; };break; case -6:{ $msg='Email 该 Email 已经被注册'; } default:{ $msg='未定义'; } } $this->set_message(0,'注册失败');exit; } if(!empty($invite_account)) { $invite_account_arr = SafeFilter([$invite_account]); $invite_account = $invite_account_arr[0]; //添加邀请人记录 D("ShareRecord")->addShareRecord($invite_account, $phone); //添加邀请好友注册积分 D("PointRecord")->addPointByType("invite_friend", get_user_id($invite_account)); } $this->set_message(1,'注册成功');exit; }else{ $this->set_message(0,'验证码错误');exit; } } /** * 获取邀请记录 * @param $token * author: xmy 280564871@qq.com */ public function get_my_invite_record($token){ $this->auth($token); $invite_id = get_user_id(USER_ACCOUNT); $data = D("ShareRecord")->getMyInviteRecord($invite_id); if (empty($data)){ $this->set_message(1061,"暂无记录"); }else{ $this->set_message(200,"成功",$data); } } /** * 获取用户邀请统计 * @param $token * author: xmy 280564871@qq.com */ public function get_user_invite_info($user_id=0){ $model = new \Mobile\Model\ShareRecordModel(); $data = $model->getUserInviteInfo($user_id); return $data; } }