//从浏览器页面跳转到app,安卓处理
function readUrlAndroid(isFutang, fn) {
	var _href_temp = location.href.replace('?share=1','');
	var _href = _href_temp.replace('&share=1','');
	var _pathname = location.pathname;
	var _rt = '';
	var _headerMarks = 'tonglianjituan';
	if(isFutang == '1'){
		_headerMarks = 'futangchina';
	}
	if(_pathname.indexOf('details_tl.html') >= 0) {
		//楼盘详情
		var _houseid = getUrlParam('id');
		var _housename = getUrlParam('housename');
		_rt = _headerMarks + '://admin.tonglianjituan.com/house/details?id=' + _houseid + '&name=' + _housename;
	}else if(_pathname.indexOf('news2_app.html') >= 0){
		var _newstype = getUrlParam('newstype');
		var _id = getUrlParam('id');
		var _name = getUrlParam('name');
		if(_newstype == '1'){
			//商学院里的新闻
			_rt = _headerMarks + '://admin.tonglianjituan.com/business/details?url=' + _href + '&name=' + _name;
			
		}else{
			//头条详情里的新闻
			_rt = _headerMarks + '://admin.tonglianjituan.com/news/details?id=' + _id + '&name=' + _name;
		}
	}else if(_pathname.indexOf('money_banner.html') >= 0){
		//banner 在线结佣
		_rt = _headerMarks + '://admin.tonglianjituan.com/url/details?url='+ _href +'&name=在线结佣';
	}else if(_pathname.indexOf('poster_intro.html') >= 0){
		//海报设计,海报制作
		_rt = _headerMarks + '://admin.tonglianjituan.com/url/details?url='+ _href +'&name=海报设计';
	}else if(_pathname.indexOf('invite_intro.html') >= 0){
		//邀好友
		_rt = _headerMarks + '://admin.tonglianjituan.com/url/details?url='+ _href +'&name=邀好友';
	}else if(_pathname.indexOf('come_intro.html') >= 0){
		//进场红包
		_rt = _headerMarks + '://admin.tonglianjituan.com/url/details?url='+ _href +'?down_hide=1&name=进场红包';
	}
	
	return fn(_rt);
}

//从浏览器页面跳转到app,苹果处理
function readUrlIos(isFutang, fn){
	var _href_temp = location.href.replace('?share=1','');
	var _href = _href_temp.replace('&share=1','');
	
	var _pathname = location.pathname;
	var _search_temp = location.search.replace('?share=1','');
	var _search = _search_temp.replace('&share=1','');
	
	var _rt = '';
	var _headerMarks = 'tonglianjituan';
	if(isFutang == '1'){
		_headerMarks = 'futangchina';
	}
	
	if(_pathname.indexOf('money_banner.html') >= 0){
		//banner 在线结佣
		_rt = _headerMarks + '://admin.tonglianjituan.com' + _pathname + '?url='+ _href +'&name=在线结佣';
	}else if(_pathname.indexOf('poster_intro.html') >= 0){
		//海报设计,海报制作
		_rt = _headerMarks + '://admin.tonglianjituan.com' + _pathname + '?url='+ _href +'&name=海报设计';
	}else if(_pathname.indexOf('invite_intro.html') >= 0){
		//邀好友
		_rt = _headerMarks + '://admin.tonglianjituan.com' + _pathname + '?url='+ _href +'&name=邀好友';
	}else if(_pathname.indexOf('come_intro.html') >= 0){
		//进场红包
		_rt = _headerMarks + '://admin.tonglianjituan.com' + _pathname + '?url='+ _href +'&name=进场红包';
	}else{
		_rt = _headerMarks + '://admin.tonglianjituan.com' + _pathname + _search;
	}
	
	return fn(_rt);
}

function jumpEvent(){
	var _ft = getUrlParam('ft');
//	if(_ft == '1'){
//		$('.fix_area_top>img:nth-of-type(2)').attr('src','images/pbl_logo_ft.png');
//		$('.fix_area_top>p>span:nth-of-type(2)').html('请下载福堂中国APP');
//		$('#jump_link>img').attr('src','images/pbl_dakai_ft.png');
//	}
	
	//自动跳转app设置
	if(device.isIos()) {
		readUrlIos(_ft, function(_url){
			window.location = _url;
		});
	} else if(device.isAndroid()) {
		readUrlAndroid(_ft, function(_url){
			window.location = _url;
		});
	} else {
		console.log("other device");
	}

	//点立即打开之后的事件
	$('#jump_link').click(function(e) {
		if(device.isIos()) {
			readUrlIos(_ft, function(_url){
				window.location = _url;
			});
		} else if(device.isAndroid()) {
			readUrlAndroid(_ft, function(_url){
				window.location = _url;
			});
		} else {
			console.log("other device");
		}
		
		var t = Date.now();
		setTimeout(function() {
			if(Date.now() - t < 1200) {
//				if(_ft == '1'){
//					location.href = 'xiazai.html?ft=1';
//				}else{
					location.href = 'xiazai.html';
//				}
			}
		}, 1000);
	});
}
