<?php
namespace app\Admin\controller;
use \think\Controller;

/**
 *
 * @author admin
 *			单点登录操作
 *			用户登录vip后台系统时，传brandid,admin_id,shop_code给vipshop，vipshop建立单方法 接收brandid(事业部id),admin_id(用户id),shop_code(岗位code)
 */

class Oauth extends Controller{
    function index() {       
        $brandid     = think_decrypt(input('brandid')); //事业部id
        $main_position_code = think_decrypt(input('main_position_code')); //岗位的code
        $admin_id  = think_decrypt(input('admin_id'));  //用户的id
        $ip        = think_decrypt(input('ip'));        //最后登录的ip
        $expiry    = think_decrypt(input('expiry'));    //最后登录的时间
        $user_name = think_decrypt(input('user_name'));    //用户名称
        $main_work_type = think_decrypt(input('main_work_type')); //主工作类型
        $work_type = think_decrypt(input('work_type')); //副工作类型
        $is_belong = think_decrypt(input('is_belong')); //员工等级
        if(!empty($main_work_type)){    //将主工作类型转换成数组
            $main_work_type = explode(' ',$main_work_type);
        }else{
            $main_work_type = [];
        }
        if(!empty($work_type)){         //将副工作类型转换成数组
            if(strpos($work_type,',') === false){
                $work_type = explode(' ',$work_type);
            }else{
                $work_type = explode(',',$work_type);
            }
        }
        //合并主/副工作类型
        if(!empty($work_type)){
            $work = array_merge($main_work_type,$work_type);
        }else{
            $work = $main_work_type;
        }
                
        if(in_array(22,$work)){
        	session('act_list','all');             //权限列表
        }elseif(!empty($main_position_code)){
            $admin_info = M('admin_role')->where('code',$main_position_code)->find();
            session('act_list',$admin_info['act_list']);
        }
        if(!empty($brandid)){
            session('brandid',$brandid);
        }
        if(!empty($admin_id)){
            session('admin_id',$admin_id);
        }
        if(!empty($ip)){
            session('last_login_ip',$ip);
        }
        if(!empty($expiry)){
            session('last_login_time',$expiry);
        }
        if(!empty($user_name)){
        	session('user_name',$user_name);
        }
        if(!empty($is_belong)){
            session('is_belong',$is_belong);
        }
        if(!empty($brandname)){
            session('brandname',$brandname);
        }
        if(!empty($shop_code)){
            session('shop_code',$shop_code);
        }

    }
}