/**
 * csc(作者)
 * 2018-03-29(开始日期)
 * 2018-03-31(最终更改日期)
 * xxx(最后更改者)
 * */
/******************************** 测试服  *************************************/
var apicom = 'http://172.16.5.66:17001';
/******************************** 正式服  *************************************/
var	name;// 用户名
var	id = 1;// 用户I
var	uuid;//uuid
var	is_team;//是否是团队
// 用户权限验证
function Auth(){
	if (localStorage.getItem('user_info')) {
		// 暂时关闭首页跳转 联调放开
		// window.location.href="home.html";
		var user_info = localStorage.getItem('user_info');
		user_info = JSON.parse(user_info);
		id = user_info.loginId;
		name = user_info.loginName;
		uuid = user_info.uuid;
		is_team = user_info.loginType;
		$('#login').text(name);
		return true;
	} else {
		return false;
	}
}

// 弹出层 消息提示
function tips(msg) {
	layer.open({
		content: msg,
		skin: 'msg',
		time: 1 //2秒后自动关闭
			,
		style: 'position:fixed;top:30%;left:50%;width:25rem;height:3rem;margin-left:-12.5rem;padding:10px 0; border:none;line-height:4rem'
	});
}

function big_tips(msg) {
	layer.open({
		content: msg,
		skin: 'msg',
		time: 1 //2秒后自动关闭
			,
		style: 'position:fixed;top:30%;left:50%;width:25rem;height:6rem;margin-left:-12.5rem;padding:10px 0; border:none;line-height:4rem'
	});
}
/* 公用全局函数 */
var globalFun = {
	/* 获取参数 */
	GetQueryString: function(name) {
		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
		var r = window.location.search.substr(1).match(reg);
		if (r != null) return unescape(r[2]);
		return null;
	},
	uniencode: function(text) {
		text = escape(text.toString()).replace(/\+/g, "%2B");
		var matches = text.match(/(%([0-9A-F]{2}))/gi);
		if (matches) {
			for (var matchid = 0; matchid < matches.length; matchid++) {
				var code = matches[matchid].substring(1, 3);
				if (parseInt(code, 16) >= 128) {
					text = text.replace(matches[matchid], '%u00' + code);
				}
			}
		}
		text = text.replace('%25', '%u0025');

		return text;
	},
}

var HtmlEncode = function(str) {
	var hex = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f');
	var preescape = str;
	var escaped = "";
	for (var i = 0; i < preescape.length; i++) {
		var p = preescape.charAt(i);
		escaped = escaped + escapeCharx(p);
	}

	return escaped;

	function escapeCharx(original) {
		var found = true;
		var thechar = original.charCodeAt(0);
		switch (thechar) {
			case 10:
				return "<br/>";
				break; //newline
			case 32:
				return "&nbsp;";
				break; //space
			case 34:
				return "&quot;";
				break; //"
			case 38:
				return "&amp;";
				break; //&
			case 39:
				return "&#x27;";
				break; //'
			case 47:
				return "&#x2F;";
				break; // /
			case 60:
				return "&lt;";
				break; //<
			case 62:
				return "&gt;";
				break; //>
			case 198:
				return "&AElig;";
				break;
			case 193:
				return "&Aacute;";
				break;
			case 194:
				return "&Acirc;";
				break;
			case 192:
				return "&Agrave;";
				break;
			case 197:
				return "&Aring;";
				break;
			case 195:
				return "&Atilde;";
				break;
			case 196:
				return "&Auml;";
				break;
			case 199:
				return "&Ccedil;";
				break;
			case 208:
				return "&ETH;";
				break;
			case 201:
				return "&Eacute;";
				break;
			case 202:
				return "&Ecirc;";
				break;
			case 200:
				return "&Egrave;";
				break;
			case 203:
				return "&Euml;";
				break;
			case 205:
				return "&Iacute;";
				break;
			case 206:
				return "&Icirc;";
				break;
			case 204:
				return "&Igrave;";
				break;
			case 207:
				return "&Iuml;";
				break;
			case 209:
				return "&Ntilde;";
				break;
			case 211:
				return "&Oacute;";
				break;
			case 212:
				return "&Ocirc;";
				break;
			case 210:
				return "&Ograve;";
				break;
			case 216:
				return "&Oslash;";
				break;
			case 213:
				return "&Otilde;";
				break;
			case 214:
				return "&Ouml;";
				break;
			case 222:
				return "&THORN;";
				break;
			case 218:
				return "&Uacute;";
				break;
			case 219:
				return "&Ucirc;";
				break;
			case 217:
				return "&Ugrave;";
				break;
			case 220:
				return "&Uuml;";
				break;
			case 221:
				return "&Yacute;";
				break;
			case 225:
				return "&aacute;";
				break;
			case 226:
				return "&acirc;";
				break;
			case 230:
				return "&aelig;";
				break;
			case 224:
				return "&agrave;";
				break;
			case 229:
				return "&aring;";
				break;
			case 227:
				return "&atilde;";
				break;
			case 228:
				return "&auml;";
				break;
			case 231:
				return "&ccedil;";
				break;
			case 233:
				return "&eacute;";
				break;
			case 234:
				return "&ecirc;";
				break;
			case 232:
				return "&egrave;";
				break;
			case 240:
				return "&eth;";
				break;
			case 235:
				return "&euml;";
				break;
			case 237:
				return "&iacute;";
				break;
			case 238:
				return "&icirc;";
				break;
			case 236:
				return "&igrave;";
				break;
			case 239:
				return "&iuml;";
				break;
			case 241:
				return "&ntilde;";
				break;
			case 243:
				return "&oacute;";
				break;
			case 244:
				return "&ocirc;";
				break;
			case 242:
				return "&ograve;";
				break;
			case 248:
				return "&oslash;";
				break;
			case 245:
				return "&otilde;";
				break;
			case 246:
				return "&ouml;";
				break;
			case 223:
				return "&szlig;";
				break;
			case 254:
				return "&thorn;";
				break;
			case 250:
				return "&uacute;";
				break;
			case 251:
				return "&ucirc;";
				break;
			case 249:
				return "&ugrave;";
				break;
			case 252:
				return "&uuml;";
				break;
			case 253:
				return "&yacute;";
				break;
			case 255:
				return "&yuml;";
				break;
			case 162:
				return "&cent;";
				break;
			case '\r':
				break;
			default:
				found = false;
				break;
		}
		if (!found) {
			if (thechar > 127) {
				var c = thechar;
				var a4 = c % 16;
				c = Math.floor(c / 16);
				var a3 = c % 16;
				c = Math.floor(c / 16);
				var a2 = c % 16;
				c = Math.floor(c / 16);
				var a1 = c % 16;
				return "&#x" + hex[a1] + hex[a2] + hex[a3] + hex[a4] + ";";
			} else {
				return original;
			}
		}
	}
}
//点击登录跳转登录页面3
$('#login').on('click',function(){
	window.location.href='login.html'
})
//点击成为志愿者跳转注册页面
$('#registe_volunteer').on('click',function(){
	window.location.href='registe.html?v_type=1'
})
//点击成为志愿团队跳转注册页面
$('#registe_team').on('click',function(){
	window.location.href='registe.html?v_type=2'
})
//点击切换列表
$('#vl_active').on('click',function(){
	window.location.href = 'index.html?type=1'
});
$('#vl_team').on('click',function(){
	window.location.href = 'index.html?type=2'
});
$('#vl_integral').on('click',function(){
	window.location.href = 'volunteer_integral.html'
});