script type="text/javascript">
$(function(){
$('.agree_regi').click(function(){
var phone = $.trim($("#phone").val());
if(phone == ""){
NewAlert(2,"請輸入手機(jī)號",null);
return false;
}else{
var reg = /^0?1[3|4|5|8|7][0-9]\d{8}$/;
if (!reg.test(phone)) {
NewAlert(2,"請輸入有效的手機(jī)號碼",null);
return false;
}
}
var data ={
phone:phone,
};
$.ajax({
type:"POST",
url:"{:U('Register/PhoneFind')}",
data:data,
success:function(msg){
if(msg=='0'){
NewAlert(2,"手機(jī)號有誤",null);
}
if(msg=='1'){
NewAlert(2,"該手機(jī)號已經(jīng)注冊,請直接登錄",null);
}
if(msg=='2'){
location.href="/Register/Regowner?phone="+phone;
}
if(msg=='3'){
location.href="/Register/Regnest?phone="+phone;
}
}
});
});
});
/script>
public function PhoneFind(){
if(!empty(I('param.phone'))){ //I方法獲取post提交的值
$phone = I('param.phone');
$user = M("cuser");
$res=$user->where(array('phone' =>$phone))->find(); //去數(shù)據(jù)庫查詢一條,并以數(shù)組返回
if (!empty($res['password'])) {
$status=1;//密碼存在,用戶直接登錄
}elseif(!empty($res)){
$status=2;//存在,沒有密碼,設(shè)置密碼,是業(yè)主
}else{
$status=3;//不存在,是游客,注冊
}
}else{
$status=0;//手機(jī)號有誤
}
$this->ajaxReturn($status); //返回狀態(tài)值給前臺
}