function checkbindmobile() { $mobile = $_GET['mobile']; if ($mobile == null or !is_numeric($mobile)) { $data['success'] = false; $data['info'] = "请提供手机号码!"; $this->ajaxReturn($data); } $User = new UserApi(); $ret = $User->checkMobile($mobile); if ($ret == 1) { $data['success'] = true; $data['exist'] = false; } else { $data['success'] = true; $data['exist'] = true; } $this->ajaxReturn($data); }
public function validate() { if (!C('USER_ALLOW_REGISTER')) { $this->ajaxErr(-1, '注册已关闭'); } $type = I('type', 'default'); $value = I('val', ''); $ok = rand(0, 3) > 1 ? true : false; $User = new UserApi(); $msgMap = array("-1" => "用户名长度不合法", "-2" => "用户名禁止注册", "-3" => "用户名被占用", "-4" => "密码长度不合法", "-5" => "邮箱格式不正确", "-6" => "邮箱长度不合法", "-7" => "邮箱禁止注册", "-8" => "邮箱被占用", "-9" => "手机格式不正确", "-10" => "手机禁止注册", "-11" => "手机号被占用"); switch ($type) { case 'default': $this->ajaxErr(-1, '参数错误'); break; case 'username': $ret = $User->checkUsername($value); if ($ret == 1) { $this->ajaxSucc(); } else { $this->ajaxErr($ret, $msgMap[$ret]); } break; case 'mobile': $ret = $User->checkMobile($value); if ($ret == 1) { $this->ajaxSucc(); } else { $this->ajaxErr($ret, $msgMap[$ret]); } break; case 'email': $ret = $User->checkEmail($value); if ($ret == 1) { $this->ajaxSucc(); } else { $this->ajaxErr($ret, $msgMap[$ret]); } break; } }
public function order() { if (IS_POST) { $Order = D('Order'); $order_id = 'NS' . date('YmdHis') . mt_rand(1000, 9999); $uid = is_login(); if ($uid) { $result = $Order->input($order_id, $uid, 1); } else { $mobile = I('mobile', '', 'trim'); /* 调用注册接口注册用户 */ $User = new UserApi(); $res = $User->checkMobile($mobile); if ($res == 1) { $password = mt_rand(100000, 999999); $uid = $User->register('', $password, '', $mobile); if (0 < $uid) { //注册成功 send_sms($mobile, '您的密码:' . $password); $result = $Order->input($order_id, $uid, 1); } } else { $user_info = $User->getinfo($mobile, 3); $result = $Order->input($order_id, $user_info[0], 1); } } if ($result) { $this->redirect('checkOrder', array('order_id' => $order_id)); } else { $this->error('订单提交失败'); } } else { $line_id = I('line_id', 0, 'intval'); $tc_id = I('type_id', 0, 'intval'); $date = I('date', 0, 'strtotime'); if (empty($line_id) || empty($tc_id) || empty($date)) { $this->error('无效参数'); } // 线路信息 $line_info = M('Line')->find($line_id); // 套餐信息 $map = array('line_id' => $line_id, 'end_time' => array('egt', strtotime('+' . $line_info['earlier_date'] . 'day'))); $line_tc = M('LineTc')->where($map)->select(); if (empty($line_tc)) { $this->error('没有报价方案'); } $tc_info = array(); foreach ($line_tc as $key => $value) { if ($value['tc_id'] == $tc_id) { $tc_info = $value; break; } } $ext_time = strtotime('+' . $line_info['earlier_date'] . 'day'); $tc_str = explode(',', $tc_info['date_price_data']); foreach ($tc_str as $value) { list($k, $val) = explode('|', $value); $k = strtotime($k); if ($k <= $ext_time) { continue; } if ($k == $date) { $tc_info['price_info'] = explode('-', $val); $tc_info['price_info'][] = date('Y-m-d', $k); break; } } if (empty($tc_info['price_info'])) { $this->error('没有价格'); } $this->assign('line_info', $line_info); $this->assign('line_tc', $line_tc); $this->assign('tc_info', $tc_info); $this->display(); } }
public function checkMobile($mobile) { $User = new UserApi(); $res = $User->checkMobile($mobile); if ($res == 1) { $this->success('true'); } else { $this->error('false'); } }
public function checkMobile() { if (IS_POST) { $name = I('post.name'); $param = I('post.param'); if ($name == 'mobile') { $User = new UserApi(); $ret = $User->checkMobile($param); if ($ret == 1) { $this->error('该手机号码不存在'); return; } } } }