$Sign={}
$Sign.make=function(store)
{
	let data=store.getItem('$sign')
	try 
	{
		return JSON.parse(data)
	} 
	catch (error) 
	{
		return data?data:{};
	}
}


$Sign.get=function()
{
	if(sessionStorage.getItem('$signId'))
	{
		return {id:sessionStorage.getItem('$signId'),data:$Sign.make(sessionStorage)}
	}
	else
	{
		return {id:localStorage.getItem('$signId'),data:$Sign.make(localStorage)}
	}
}

//退出登录
$Sign.out=function()
{
	sessionStorage.removeItem('$signId');
	localStorage.removeItem('$signId');
	sessionStorage.removeItem('$sign');
	localStorage.removeItem('$sign');
}

//登陆成功后向浏览器，存登陆信息,session代表会话
$Sign.sign=function(id,data,session)
{
	if(!session && data===true)
	{
		data=true;
		session=true;
	}
	if(typeof data == 'object')
	{
		try 
		{
			data=JSON.stringify(data)
		} 
		catch (error) 
		{
			$M.info('【登陆保存】数据解析错误');
		}
	}
	if(session)
	{
		sessionStorage.setItem('$signId',id)
		sessionStorage.setItem('$sign',data)
	}
	else
	{
		localStorage.setItem('$signId',id)
		localStorage.setItem('$sign',data)
	}
	return true;
}