﻿$(function () {
	$('.sy_anli li:odd,.sy_zsgd_ul li:odd,.nhys_ul li:odd').addClass('addright');
	$('.menubtn').click(function () {
		$('.navbox').show();
	})
	$('.navclus').click(function () {
		$('.navbox').hide();
	})
	/*tcyuyue*/
	$('.tc_fomr_btn').click(function () {
		$('.tc_yuyue').show();
	})
	$('.clus').click(function () {
		$('.tc_yuyue').hide();
	})
	/*案例筛选*/
	$('.sx_btn_ul li').click(function () {
		var n = $(this).index();
		if (Number($(this).attr('sxoff'))) {
			$(this).attr('sxoff', 0).siblings().attr('sxoff', 1);
			$(this).addClass('addsxli').siblings().removeClass('addsxli');
			$('.sxlist_li').eq(n).addClass('addlisth').siblings().removeClass('addlisth');
		} else {
			$(this).attr('sxoff', 1)
			$(this).removeClass('addsxli');
			$('.sxlist_li').eq(n).removeClass('addlisth');
		}

	})

	/*楼盘*/
	$('.listlp_ul li:odd,.listsjs_ul li:odd,.listkb_ul li:odd,.gyzxpy_ul li:odd').css({
		'float': 'right'
	});
	/*楼盘详情*/
	$('.atlpnav div').click(function () {
		var lpn = $(this).index();
		$(this).addClass('addlpico').siblings().removeClass('addlpico');
		$('.atlplist .at_list').eq(lpn).show().siblings().hide();
	})

	/*案例详情*/
	$('.at_anlilist_ul li:odd,.hb_cl_ul li:odd').css({
		'float': 'right'
	});

	/*在施工地详情*/
	var gdlen = 0;
	var tcon = $('.jdtext').html();
	var licon = $('.zsgdjd_ul li');
	for (var i = 0; i < licon.length; i++) {
		if (licon.eq(i).find('p').html() == tcon) {
			for (var j = 0; j < i + 1; j++) {
				$('.zsgdjd_ul li').eq(j).find('.xyuan').css({
					'background': '#c4261d'
				});
				$('.zsgdjd_ul li').eq(i).addClass('addyuan');
			}
		}
	}

	/*关于我们*/

	$('.xjtico').click(function () {
		scrollTo('#zjnh', 300);
	})

	/*gongyi*/
	$('.gy_xxul li:odd,.gy_yq_ul li:odd').css({
		'float': 'right'
	});

	/*视频详情*/
	$('.nhspbox .videoico').click(function () {
		$(this).hide();
		$(".nhsp").get(0).play();
		return false;
	})
	$(".nhsp").click(function () {
		$(".nhspbox .videoico").show();
		$(".nhsp").get(0).pause();
		return false;
	})
	/*视频*/

	/*分页*/
	pagesfy("#videogetMore", 1, '/video', 1);
	pagesfy("#anligetMore", 1, "/anli", 2);
	pagesfy("#vrgetMore", 1, "/vr", 3);
	pagesfy("#sjsgetMore", 2, "/sjs", 4);
	pagesfy("#lpgetMore", 3, "/lp", 5);
	pagesfy("#zsgdgetMore", 4, "/gongdi", 6);
	pagesfy("#yzkbgetMore", 0, "/yzkb", 7);
	pagesfy("#jpgetMore", 0, "/jinpai", 8);
	var textcon = '';

	function videofor(obj) {
		for (var i = 0; i < obj.length; i++) {
			textcon += '<li class="width100_">';
			textcon += '<a href="/info_video/' + obj[i].id + '.html">';
			textcon += '<img class="width100_" src="' + obj[i].litpic + '" alt="' + obj[i].title + '" />';
			textcon += '<img class="videoico wpsa wpsauto" src="/mobile/images/play.png"/>';
			textcon += '<div class="wpsa anlitext baise">';
			textcon += '<div class="width90_ wauto">';
			textcon += '<p class="textlh1 font24">' + obj[i].title + '</p>';
			textcon += '<p class="font20 mdt02">' + obj[i].xiaoqu + '  |  ' + obj[i].mianji + 'm²  |  ' + obj[i].fengge + '</p>';
			textcon += '</div></div></a></li>';
		}
	}

	function anlifor(obj) {
		for (var i = 0; i < obj.length; i++) {
			textcon += '<li class="width100_">';
			textcon += '<a href="/info_al/' + obj[i].id + '.html">';
			textcon += '<img class="width100_" src="' + obj[i].litpic + '" alt="' + obj[i].title + '" />';
			textcon += '<div class="wpsa anlitext baise">';
			textcon += '<div class="width90_ wauto">';
			textcon += '<p class="textlh1 font24">' + obj[i].title + '</p>';
			textcon += '<p class="font20 mdt02">' + obj[i].xiaoqu + '  |  ' + obj[i].mianji + 'm²  |  ' + obj[i].fengge + '</p>';
			textcon += '</div></div></a></li>';
		}
	}

	function vrfor(obj) {
		for (var i = 0; i < obj.length; i++) {
			textcon += '<li class="width100_">';
			textcon += '<a href="/info_vr/' + obj[i].id + '.html"><div class="wpsr">';
			textcon += '<img class="width100_" src="' + obj[i].litpic + '" alt="' + obj[i].title + '" />';
			textcon += '<img class="vrico wpsa wpsauto" src="/mobile/images/vrico.png"/>';
			textcon += '</div><div class="anlitext bg0 baise">';
			textcon += '<div class="width90_ wauto">';
			textcon += '<p class="textlh1 huise222 font24">' + obj[i].title + '</p>';
			textcon += '<p class="font20 huise999 mdt02">' + obj[i].xiaoqu + '  |  ' + obj[i].mianji + 'm²  |  ' + obj[i].fengge + '</p>';
			textcon += '</div></div></a></li>';
		}
	}


	function sjsfor(obj) {
		for (var i = 0; i < obj.length; i++) {

			if (i % 2) {
				textcon += '<li class="width100_ wright">';
			} else {
				textcon += '<li class="width100_">';
			}
			textcon += '<a href="/info_sjs/' + obj[i].id + '.html">';
			textcon += '<img class="width100_" src="' + obj[i].headimg + '" alt="' + obj[i].name + '" />';
			textcon += '<div class="wpsa sjstext baise">';
			textcon += '<div class="width90_ wauto textc">';
			textcon += '<p class="textlh1 font24">' + obj[i].name + '<span class="font18 mdl04">[' + obj[i].jibie + ']</span></p>';
			textcon += '<p class="font20 textlh1 mdt02">从业时间：' + obj[i].nianxian + '年   预约次数：' + obj[i].click + '次</p>';
			textcon += '</div></div></a></li>';
		}
	}


	function lpfor(obj) {
		for (var i = 0; i < obj.length; i++) {
			if (i % 2) {
				textcon += '<li class="">';
			} else {
				textcon += '<li class="wright">';
			}
			textcon += '<a href="/info_lp/' + obj[i].id + '.html">';
			textcon += '<div class="lpimg woverflow">';
			textcon += '<img class="width100_" src="' + obj[i].img + '" alt="' + obj[i].title + '" /></div>';
			textcon += '<div class="lptext width90_ wauto">';
			textcon += '<p class="textc font24 huise222 mdt02">' + obj[i].title + '</p>';
			textcon += '<p class="textlh1 textc font24 mdt01">签约<span class="hongse">' + obj[i].qyhs + '</span>户&nbsp;&nbsp;已完工<span class="hongse">' + obj[i].jghs + '</span>户</p>';
			textcon += '</div></a></li>';
		}
	}


	function zsgdfor(obj) {
		for (var i = 0; i < obj.length; i++) {
			textcon += '<li><a href="/info_lp/' + obj[i].id + '.html">';
			textcon += '<div class="wleft width40_"><img class="width100_" src="' + obj[i].litpic + '" alt="' + obj[i].lpname + '' + obj[i].mianji + 'm²' + obj[i].fengge + '" /></div>';
			textcon += '<div class="wright width55_">';
			textcon += '<p class="font32 huise222 textlh1">' + obj[i].lpname + '' + obj[i].mianji + 'm²' + obj[i].fengge + '</p>';
			textcon += '<p class="font24 huise999 textlh1 mdtb03">' + obj[i].lpname + '  |  ' + obj[i].mianji + 'm²  |  ' + obj[i].fengge + '</p>';
			textcon += '<div class="woverflow">';
			textcon += '<img class="dingwei wleft" src="/mobile/images/dingwei.png"/>';
			textcon += '<p class="wleft mdl02 width85_ font24 huise999 textlh1">' + obj[i].lpdz + '</p></div><div class="woverflow mdt03">';
			textcon += '<p class="wleft width70_ font24 huise999 textlh1">风格：' + obj[i].fengge + '</p>';
			textcon += '<p class="wright jindu font20 hongse pdlr04 mdr05_">' + obj[i].lpjd + '</p>';
			textcon += '</div></div></a></li>';
		}
	}

	function yzkbfor(obj) {
		for (var i = 0; i < obj.length; i++) {
			if (i % 2) {
				textcon += '<li class="">';
			} else {
				textcon += '<li class="wright">';
			}
			textcon += '<a href="/info_yzkb/' + obj[i].id + '.html">';
			textcon += '<div class="kbimg woverflow">';
			textcon += '<img class="width100_" src="' + obj[i].img + '" alt="' + obj[i].title + '" />';
			textcon += '</div><div class="lptext width90_ wauto">';
			textcon += '<p class="textc font24 huise222 textlh1 mdt02">' + obj[i].title + '</p>';
			textcon += '</div></a></li>';
		}
	}


	function jinpaifor(obj) {
		for (var i = 0; i < obj.length; i++) {
			textcon += '<li><a href="/kefu.html" target="_blank">';
			textcon += '<div class="wleft jinpaiimg woverflow"><img class="width100_" src="' + obj[i].img + '" alt="' + obj[i].title + '" /></div>';
			textcon += '<div class="wpsr wright width72_">';
			textcon += '<p class="font32 huise333 mdt05">' + obj[i].title + ' <span class="huise999 font20 mdl02">【' + obj[i].xmjb + '】</span></p>';
			textcon += '<p class="font24 huise666 mdt04">从业时间：<span class="hongse">' + obj[i].cytime + '年</span></p>';
			textcon += '<p class="font24 huise666 mdt04 textlh1">工作宣言：' + obj[i].gzxy + '</p>';
			textcon += '<p class="font24 huise666 mdt04 textlh1">样板作品：' + obj[i].ybzp + '</p></div></a></li>';
		}
	}


	function pagesfy(obj, typeid, url, shu) {
		$(obj).click(function () {
			var _this = $(this);
			textcon = '';
			pnum = Number(_this.attr("pnum")) + 1; //分页码
			if (pnum == 1) {
				return false;
			}
			var data = {
				gywm_page: pnum
			};
			if (typeid == 1) {
				for (var i = 0; i < 3; i++) {
					if ($('.itemLst .current').eq(i).html() !== '全部') {
						if (i == 0) {
							data.fengge = $('.itemLst .current').eq(0).html()
						} else if (i == 1) {
							var mianji = $('.itemLst .current').eq(1).html();
							if (mianji == '50㎡以下') {
								mianji = '0-50'
							}
							if (mianji == '1000㎡以上') {
								mianji = '1000-10000'
							}
							mianji = mianji.replace('㎡', '');
							mianji = mianji.replace('㎡', '');

							data.mianji = mianji;
						} else {
							data.huxing = $('.itemLst .current').eq(2).html()
						}
					}
				}
			} else if (typeid == 2) {
				for (var i = 0; i < 3; i++) {
					if ($('.itemLst .current').eq(i).html() !== '全部') {
						if (i == 0) {
							data.sx_quyu = $('.itemLst .current').eq(0).html();
						} else if (i == 1) {
							var nian = $('.itemLst .current').eq(1).html();
							nian = nian.substr(0, nian.length - 1);
							data.nianxian = nian;
						} else {
							data.fengge = $('.itemLst .current').eq(2).html();
						}
					}
				}
			} else if (typeid == 3) {

				if ($('.itemLst .current').html() !== '全部') {
					data.lpquyu = $('.itemLst .current').html();
				} else {
					data.lpquyu = '';
				}
			} else if (typeid == 4) {
				if ($('.itemLst .current').html() !== '全部') {
					data.lpjd = $('.itemLst .current').html();
				}
			}
			$.ajax({
				url: url,
				data: data,
				success: function (data) {
					if (data != '') {
						if (shu == 1) {
							videofor(data);
						} else if (shu == 2) {
							anlifor(data)
						} else if (shu == 3) {
							vrfor(data)
						} else if (shu == 4) {
							sjsfor(data)
						} else if (shu == 5) {
							lpfor(data)
						} else if (shu == 6) {
							zsgdfor(data)
						} else if (shu == 7) {
							yzkbfor(data)
						} else if (shu == 8) {
							jinpaifor(data)
						}
						$(".index-list").append(textcon); //数据显示到页面
						_this.attr("pnum", Number(pnum)); //分页+1
					} else {
						_this.text("没有更多的数据");
						_this.attr("pnum", 0)
					}
				}
			})
			return false;
		})
	}

	/*报名*/

	$('.tc_fomr_btn').click(function () {
		var titles = $(this).attr('titles');
		$('.laiyuan').val(titles);
	})

submitclick('#dytopsub2', '#oname2', '#otel2', '#dytopform2', 0);
submitclick('#dytopsub', '#oname', '#otel', '#dytopform', 0);
submitclick('#tanc_sub', '#tancomj', '#tancotel', '#tanc_form', 1);
submitclick('#pub_freeprice', '#send_mj', '#send_tel', '#freeprice', 1);
submitclick('#baojiasub', '#baojianame', '#baojiatel', '#baojiaform', 0);
submitclick('#baojiasub2', '#baojianame2', '#baojiatel2', '#baojiaform2', 0);
	submitclick('#tc_foot_sub', '#tc_b_name', '#tc_b_tel', '#tc_foot_form', 0);
	submitclick('#tc_m_sub', '#tc_m_name', '#tc_m_tel', '#tc_m_form', 0);
	submitclick('#tc_top_sub', '#oname', '#otel', '#tc_top_form', 0);
	submitclick('#pp_top_sub', '#oname', '#otel', '#pp_top_form', 0);
	submitclick('#ppsl_sjtd_sub', '#oname', '#ppsl_sjtd', '#ppsl_sjtd_form', 0);
	submitclick('#pp_m_sub', '#ppsl_zt_name', '#ppsl_zt_tel', '#pp_m_form', 0);
	submitclick('#pp_bb_sub', '#ppsl_bb_name', '#ppsl_bb_tel', '#pp_bb_form', 0);
	submitclick('#gywm_sub', '#oname', '#otel', '#gywm_form', 0);
	submitclick('#hb_sub', '#oname', '#otel', '#hb_form', 0);
	submitclick('#gy_b_sub', '#oname', '#otel', '#gy_b_fomr', 0);
	submitclick('#bz_gy_sub', '#bzname', '#bztel', '#bz_gy_form', 0);
	submitclick('#pp_b_sub', '#oname', '#otel', '#pp_b_form', 0);
	submitclick('#tc_yuyue_sub', '#tc_oname', '#tc_otel', '#tc_yuyue_form', 0);
	submitclick('#yy_b_sub', '#yybname', '#yybtel', '#yy_b_form', 0);
	submitclick('#yy_vr_sub', '#oname', '#otel2', '#yy_vr_form', 0);
	submitclick('#yy_top_sub', '#oname', '#otel', '#yy_top_form', 0);
	submitclick('#sy_lpxq_sub', '#oname', '#otel', '#sy_lpxq_form', 0);
	submitclick('#sy_zsgd_sub', '#oname', '#zsgdtel', '#sy_zsgd_form', 0);
	submitclick('#sy_sjs_sub', '#oname', '#sjstel', '#sy_sjs_form', 0);
	submitclick('#sy_anli_sub', '#oname', '#anlitel', '#sy_anli_form', 0);
	submitclick('#sy_top_sub', '#oname', '#otel', '#sy_top_form', 0);
	submitclick('#hd_sub', '#hd_name', '#hd_tel', '#hd_form', 0);
	submitclick('#hdb_sub', '#hdb_name', '#hdb_tel', '#hdb_form', 0);
	submitclick('#yhq_sub', '#yhq_name', '#yhq_tel', '#yhq_form', 0);
	function submitclick(obj, name, tel, objr, ofif) {
		
			
		
		$(obj).click(function () {
							   
			console.log('abc')
			
			var httpurl = window.location.href;
			if (httpurl.indexOf("?") != -1) {
				httpurl=httpurl.substring(0, httpurl.indexOf("?"));
				//return httpurl;
			}
			$('#httpurl').val(httpurl);
			$('.httpurl').val(httpurl);
			if ($(this).parent().siblings().find(name).val() == "") {
				$(this).parent().siblings().find(name).focus();
				if (ofif == 1) {
					swal({
						title: '',
						text: '面积不能为空！',
						type: 'warning',
						timer: 2000
					})
				} else {
					swal({
						title: '',
						text: '用户名不能为空！',
						type: 'warning',
						timer: 2000
					})
				}
				return false;
			} else if ($(this).parent().siblings().find(tel).val() == "") {
				$(this).parent().siblings().find(tel).focus();
				swal({
					title: '',
					text: '手机号码不能为空！',
					type: 'warning',
					timer: 2000
				})
				return false;
			} else if (!(/^1[3456789]{1}[0-9]{9}$/.test($(this).parent().siblings().find(tel).val()))) {
				$(this).parent().siblings().find(tel).focus();
				swal({
					title: '',
					text: '手机号码输入有误！',
					type: 'warning',
					timer: 2000
				})
				return false;
			} else {

				add_ajaxmessage1(objr);

			};
		});
	};

	function add_ajaxmessage1(objr) {
		$.ajax({
			type: "POST",
			url: "/mform",
			data: $(objr).serialize(),
			success: function (data) {
				$(objr)[0].reset();
				swal("Good!", "成功提交，稍后客服会联系你，请保持电话畅通！", "success");
				setTimeout(function () {
					$('.tc_yuyue').fadeOut(300);
					$('.bj_yuyue').fadeOut(300);
					$('.m_tccz').fadeOut(300);
					$('.yhq_bd').fadeOut(300);
					$('.yhq_con').fadeOut(300);
					$('.actPop').fadeOut(300);
				}, 300);
				
				window._agl && window._agl.push(['track', ['success', {t: 3}]])
			}
		});
		return false;
	};
	
	
	SM_POST()
	
	function SM_POST() {
		
		var str = "{\"header\": {\"username\": \"浙江南鸿装饰股份有限公司\", \"password\": \"nhzs123456+\"},\"body\":{\"source\":1, \"data\":[{\"date\":\"2018-03-12\",\"click_id\":\"12131344\", \"conv_type\":5, \"conv_name\":\"表单提交\", \"conv_value\":\"1\" }]}}";
					

		
		$.ajax({
			type: "POST",
			ContentType : "application/x-www-form-urlencoded",
			url: "https://e.sm.cn/api/uploadConversions",
			data:str,
			success: function (data) {
				
				
				
			}
		});
		return false;
	};





	/*页面滚动*/
	function scrollTo(ele, speed) {
		if (!speed) speed = 300;
		if (!ele) {
			$("html,body").animate({
				scrollTop: 0
			}, speed);
		} else {
			if (ele.length > 0) $("html,body").animate({
				scrollTop: $(ele).offset().top
			}, speed);
		}
		return false;
	}

})