<?php
/**
 * App登录控制器
 * @Copyright (C) 2016 汉潮 All rights reserved.
 * @License http://www.hanchao9999.com
 * @Author xiaoli <xiaoli@1094186793.com>
 */
namespace App\Controller;
use Common\Controller\HanchaoController;
class LoginController extends BaseController {
	public function _initialize(){
		parent::_initialize ();
    }
    /**
     * 登录验证
     */
    public function dologin(){
        $param=I('param.');
        $return=D('Member')->dologin($param);
        $this->ajaxReturn($return);
    }

    /**
     * 注册会员
     */
    public function doregister(){
        $param=I('param.');
        $return=D('App/Member')->register($param);
        if($return['status']==1){
            $site_param=array(
                'type'=>'',
				'name'=>$param['username'],//站点名称
				'login_name'=>$param['username'],
				'login_pwd'=>$param['password'],
				'user_id'=>$return['data']['id'],
				'package'=>$param['package'],
				'agent_id'=>$param['agent_id'],
                'is_try'=>1,
            );
            $site_return=D('Common/Sites')->add_site($site_param);
            if($site_return['status']==1) {
                $site_info['type'] = 0;
                $site_info['id'] = $site_return['info'];
                $return['site_data'] = $site_info;
                $return['msg'] = '门店创建中';
            }else{
                $return['status']=3;
                $return['msg'] = $site_return['msg'];
            }
        }
        $this->ajaxReturn($return);
    }

    /**
     * 找回密码
     */
    public function reset_password(){
        $param=I('param.');
        $return = D('App/Member')->reset_password($param);
        $this->ajaxReturn($return);
    }
    /**
     * 更新权限信息
     */
    public function savedata(){
        $param=I('param.');
        $return = D('App/Member')->savedata($param);
        $this->ajaxReturn($return);
    }
    
}
?>