<?php
// +----------------------------------------------------------------------
// | 贝云cms内容管理系统
// +----------------------------------------------------------------------
// | Copyright (c) 2014 http://www.yershop.com All rights reserved.
// +----------------------------------------------------------------------
namespace app\api\controller;
use think\Controller;
use think\Db;

/**
 * 用户控制器
 * 包括用户中心，用户登录及注册
 */
class User extends Home {

	/* 注册页面 */
	public function register($username, $password){
		
           $version=intval(input('version'))?intval(input('version')):1;
		   $model=new \app\api\model\User;		
		   if($version=='1'){
				    $res= $model->register_v1(); 
				   if($res){
					   
				   header('Content-Type:application/json; charset=utf-8');
				   print_r( json_encode($res,JSON_UNESCAPED_UNICODE));
				   }else{
					    $res['msg']=$model->getError()?$model->getError():"获取失败！";
						$res['code']=0;
						   header('Content-Type:application/json; charset=utf-8');
				   print_r( json_encode($res,JSON_UNESCAPED_UNICODE));
				   }
	       }
	}
  public function registerbymobile($username, $password){
		
           $version=intval(input('version'))?intval(input('version')):1;
		   $model=new \app\api\model\User;		
		   if($version=='1'){
				    $res= $model->registerbymobile_v1(); 
				   if($res){
					   
				   header('Content-Type:application/json; charset=utf-8');
				   print_r( json_encode($res,JSON_UNESCAPED_UNICODE));
				   }else{
					    $res['msg']=$model->getError()?$model->getError():"获取失败！";
						$res['code']=0;
						   header('Content-Type:application/json; charset=utf-8');
				   print_r( json_encode($res,JSON_UNESCAPED_UNICODE));
				   }
	       }
	}
	public function bymobile($username, $password){
		
           $version=intval(input('version'))?intval(input('version')):1;
		   $model=new \app\api\model\User;		
		   if($version=='1'){
				    $res= $model-> bymobil_v1(); 
				   if($res){
					   
				   header('Content-Type:application/json; charset=utf-8');
				   print_r( json_encode($res,JSON_UNESCAPED_UNICODE));
				   }else{
					    $res['msg']=$model->getError()?$model->getError():"获取失败！";
						$res['code']=0;
						   header('Content-Type:application/json; charset=utf-8');
				   print_r( json_encode($res,JSON_UNESCAPED_UNICODE));
				   }
	       }
	}
	/* 登录页面 */
	public function login($username = "", $password = ""){
		
	
           $version=intval(input('version'))?intval(input('version')):1;
		   $model=new \app\api\model\User;		
		   if($version=='1'){
				     $res= $model->login_v1(); 
				   if($res){
					      header('Content-Type:application/json; charset=utf-8');
				   print_r( json_encode($res,JSON_UNESCAPED_UNICODE));
				   }else{
					     $res['msg']=$model->getError()?$model->getError():"获取失败！";
						  $res['code']=0;
						     header('Content-Type:application/json; charset=utf-8');
				   print_r( json_encode($res,JSON_UNESCAPED_UNICODE));
				   }
	       }
		
	}
  /* 登录页面 */
	public function other($username = "", $password = ""){
		
	
           $version=intval(input('version'))?intval(input('version')):1;
		   $model=new \app\api\model\User;		
		   if($version=='1'){
				     $res= $model->other_v1(); 
				   if($res){
					      header('Content-Type:application/json; charset=utf-8');
				   print_r( json_encode($res,JSON_UNESCAPED_UNICODE));
				   }else{
					     $res['msg']=$model->getError()?$model->getError():"获取失败！";
						  $res['code']=0;
						     header('Content-Type:application/json; charset=utf-8');
				   print_r( json_encode($res,JSON_UNESCAPED_UNICODE));
				   }
	       }
		
	}
	/* 登录页面 */
	public function update($username = "", $uid= ""){
		
	
           $version=intval(input('version'))?intval(input('version')):1;
		   $model=new \app\api\model\User;		
		   if($version=='1'){
				     $res= $model->update_v1(); 
				   if($res){
					      header('Content-Type:application/json; charset=utf-8');
				   print_r( json_encode($res,JSON_UNESCAPED_UNICODE));
				   }else{
					     $res['msg']=$model->getError()?$model->getError():"获取失败！";
						  $res['code']=0;
						     header('Content-Type:application/json; charset=utf-8');
				   print_r( json_encode($res,JSON_UNESCAPED_UNICODE));
				   }
	       }
    }	
	/* 登录页面 */
	public function password($username = "", $uid= ""){
		
	
           $version=intval(input('version'))?intval(input('version')):1;
		   $model=new \app\api\model\User;		
		   if($version=='1'){
				     $res= $model->password_v1(); 
				   if($res){
					      header('Content-Type:application/json; charset=utf-8');
				   print_r( json_encode($res,JSON_UNESCAPED_UNICODE));
				   }else{
					     $res['msg']=$model->getError()?$model->getError():"获取失败！";
						  $res['code']=0;
						     header('Content-Type:application/json; charset=utf-8');
				   print_r( json_encode($res,JSON_UNESCAPED_UNICODE));
				   }
	       }
		
	}
   /* 登录页面 */
	public function mobile($username = "", $uid= ""){
		
	
           $version=intval(input('version'))?intval(input('version')):1;
		   $model=new \app\api\model\User;		
		   if($version=='1'){
				     $res= $model->mobile_v1(); 
				   if($res){
					      header('Content-Type:application/json; charset=utf-8');
				   print_r( json_encode($res,JSON_UNESCAPED_UNICODE));
				   }else{
					     $res['msg']=$model->getError()?$model->getError():"获取失败！";
						  $res['code']=0;
						     header('Content-Type:application/json; charset=utf-8');
				   print_r( json_encode($res,JSON_UNESCAPED_UNICODE));
				   }
	       }
		
	}
 
}
