function pcLogin(){
	$('.loginbtn').html('登录中...').css({'background-color':'rgba(47, 117, 236, .6)'})
    var params = {};
    params.theData = {phone:$('#loginbox .unlogin .user input').val(),password:$('#loginbox .unlogin .password input').val(),type:$(".typeChose .active").attr('data-type')};
    params.theUrl = allAPI.user.login;
    doPostAjax(params,isLogin)
}

function isLogin(data){
	setTimeout(function(){login_flag = true;},2000)
    if(data.code===200){
        localStorage.userType = data.data.userType
		localStorage.nick = data.data.nick
		data.data.userType==1&&(window.location.href= '/advert/index')
		data.data.userType==2&&(window.location.href= '/media/index')
        // isLoginStatus()
    }else if(data.code===4004){
        $('#loginbox .password .--err').html(data.info).show(10).fadeIn().delay(2000).fadeOut()
    }else if(data.code===4003){
        $('#loginbox .user .--err').html(data.info).show(10).fadeIn().delay(2000).fadeOut()
    }
}

function pcRegister(cb){
	$('.registerbtn.registerbtn1').html('注册中...').css({'background-color':'rgba(47, 117, 236, .6)'})
    var params = {};
    params.theData = {phone:$('.user input').val(),password:$('.password input').val(),type:$('#loginbox .regster-title').attr('data-type'),code:$('.code input').val()};
    params.theUrl = allAPI.user.register;
    doPostAjax(params,isRegister)
}
function isRegister(data){
	setTimeout(function(){r_flag = true;},2000)
    if(data.code == 200){
        localStorage.userType = data.data.userType
        localStorage.nick = data.data.nick
        data.data.userType==1&&(window.location.href= '/advert/index')
		data.data.userType==2&&(window.location.href= '/media/index')
    }else{
		$('.registerbtn.registerbtn1').html('注册').css({'background-color':'rgba(47, 117, 236, 1)'})
        $('#loginbox .user .--err').html(data.info).show(10).fadeIn().delay(2000).fadeOut()
    }
}
// 显隐密码
function isEye(boo){
    if(boo){
        $('.ykleye').show().siblings('.yklbiyan').hide().siblings("input").attr('type','password')
    }else{
        $('.yklbiyan').show().siblings('.ykleye').hide().siblings('input').attr('type','text')
    }
}

var myLocalstorage = {
	//set时expiredDays为过期天数，大于0的整数
	//get时 isExpired 是否返回未过期
	set: function(key, value, expiredDays) {
		if(expiredDays > 0) {
			var obj = {};
			obj[key] = value;
			obj['time'] = new Date(new Date().setHours(23 + 24 * (expiredDays - 1), 59, 59, 0)).getTime();
			localStorage.setItem(key, JSON.stringify(obj));
		} else {
			localStorage.setItem(key, (typeof value == 'object' ? JSON.stringify(value) : value));
		}
	},
	get: function(key, isExpired) {
		var returnData;
		if(!localStorage.getItem(key)) {
			return '';
		};
		try {
			returnData = JSON.parse(localStorage.getItem(key));
		} catch(e) {
			returnData = localStorage.getItem(key) ? localStorage.getItem(key) : '';
		}
		if(isExpired) {
			if(!returnData.time || returnData.time >= new Date().getTime()) {
				//	 			returnData['expire'] = true;
			} else {
				//	  			returnData['expire'] = false;
				returnData[key] = '';
			}
		};
		return returnData;
	},
	//获取某个url的参数
	getUrl: function(name, url) {
		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
		var r = url ? url.match(reg) : window.location.search.substr(1).match(reg);
		if(r != null)
			return unescape(r[2]);
		return null;
	},
	re: function(key) {
		key ? localStorage.removeItem(key) : localStorage.clear();
	}
};

