<!--标签零售样式-->
<style>
#asideBox .bq1 { background: url("http://esf.s.house365.com/zsb/images/v1.0/bq_sprites.png") no-repeat 0 -138px ;}
#asideBox .on .bq1{ background: url("http://esf.s.house365.com/zsb/images/v1.0/bq_sprites.png") no-repeat 0 0 ;}
.bq-record{border-collapse: collapse; border-spacing: 0;table-layout: fixed;margin:20px 10px;}
.bq-record td,.bq-record th{border: solid 1px #d9d9d9; padding: 3px;text-align: center;height: 30px;width: 5%;}
.bq-record th{color:#333;background-color: #ebebeb;}
.bq-record td{color: #333;}
</style>
<!--标签零售样式结束-->
<!---->
<div id="centre" class="layout">
    <div class="centreInner ">
        <div class="mainInner radius5 ">
            <div class="fgTitleBox fgTitleBox_school">
                <table class="table">
                    <tbody>
                        <tr>
                            <td class="w20">&nbsp;</td>
                            <td align="left">购买确认</td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <!---->
            <div class="belongBox radius5">
                <div class="pay_school_dt">购买产品：<span class="c">房源包装—二手房搜搜</span></div>
            </div>
            <!---->

            <div class="belongBox belongBox_visible radius5">
                <div class="select_house_name_box">
                    <div class="text clearfix">
                        <div class="text_b2"><span class="h4">我选择的推广房源</span>请选择<strong class="c">5条同区属板块</strong>二手房房源作为推广房源</div>
                    </div>

                    <div class="select_house_error" style="display:none">
			 所选房源不在同一区属板块哦，请重新选择。
                    </div>

                    <div class="select_house clearfix clear">
                        <div class="clearfix">
                            <div class="t t2">房源1：</div>
                            <div class="info">
                                <div class="js_select_house input_m">
                                    <input type="hidden" value="" name="rowid" class="js_hidden_input">
                                    <input type="hidden" value="" class="streetid">
                                    <div class="tex">请选择推广房源</div>
                                </div>
                                <!--	<div class="input_m input_s"><div class="tex" >天润城1 3室2厅 / 104.00㎡ / 100.00万 【44561703】</div></div> -->
                            </div>
                        </div>

                        <div class="clearfix">
                            <div class="t t2">房源2：</div>
                            <div class="info">
                                <div class="js_select_house input_m">
                                    <input type="hidden" value=""name="rowid" class="js_hidden_input">
                                    <input type="hidden" value="" class="streetid">
                                    <div class="tex">请选择推广房源</div>
                                </div>
                                <!--	<div class="input_m input_s"><div class="tex" >天润城1 3室2厅 / 104.00㎡ / 100.00万 【44561703】</div></div> -->
                            </div>
                        </div>


                        <div class="clearfix">
                            <div class="t t2">房源3：</div>
                            <div class="info">
                                <div class="js_select_house input_m">
                                    <input type="hidden" value="" name="rowid" class="js_hidden_input">
                                    <input type="hidden" value="" class="streetid">
                                    <div class="tex">请选择推广房源</div>
                                </div>
                                <!--	<div class="input_m input_s"><div class="tex" >天润城1 3室2厅 / 104.00㎡ / 100.00万 【44561703】</div></div> -->
                            </div>
                        </div>



                        <div class="clearfix">
                            <div class="t t2">房源4：</div>
                            <div class="info">
                                <div class="js_select_house input_m">
                                    <input type="hidden" value="" name="rowid" class="js_hidden_input">
                                    <input type="hidden" value="" class="streetid">
                                    <div class="tex">请选择推广房源</div>
                                </div>
                                <!--	<div class="input_m input_s"><div class="tex" >天润城1 3室2厅 / 104.00㎡ / 100.00万 【44561703】</div></div> -->
                            </div>
                        </div>



                        <div class="clearfix">
                            <div class="t t2">房源5：</div>
                            <div class="info">
                                <div class="js_select_house input_m">
                                    <input type="hidden" value="" name="rowid" class="js_hidden_input">
                                    <input type="hidden" value="" class="streetid">
                                    <div class="tex">请选择推广房源</div>
                                </div>
                                <!--	<div class="input_m input_s"><div class="tex" >天润城1 3室2厅 / 104.00㎡ / 100.00万 【44561703】</div></div> -->
                            </div>
                        </div>


                    </div>

                    <div class="text clearfix">
                        <div class="text_b2"><span class="h4">我选择的备选房源</span>可以备选<strong class="c">2条</strong>房源（如果房源不符合要求，使用备选房源）</div>
                    </div>

                    <div class="select_house clearfix">
                        <div class="clearfix">
                            <div class="t t2">备选1：</div>
                            <div class="info">
                                <div class="js_select_house input_m">
                                    <input type="hidden" value="" name="rowid" class="js_hidden_input">
                                    <input type="hidden" value="" class="streetid">
                                    <div class="tex">请选择推广房源</div>
                                </div>
                                <!--	<div class="input_m input_s"><div class="tex" >天润城1 3室2厅 / 104.00㎡ / 100.00万 【44561703】</div></div> -->
                            </div>
                        </div>

                        <div class="clearfix">
                            <div class="t t2">备选2：</div>
                            <div class="info">
                                <div class="js_select_house input_m">
                                    <input type="hidden" value="" name="rowid" class="js_hidden_input">
                                    <input type="hidden" value="" class="streetid">
                                    <div class="tex">请选择推广房源</div>
                                </div>
                                <!--	<div class="input_m input_s"><div class="tex" >天润城1 3室2厅 / 104.00㎡ / 100.00万 【44561703】</div></div> -->
                            </div>
                        </div>

                    </div>

                </div>
            </div>

            <!---->

            <div class="branchCommon branchCommon_pay branchCommon_pay_school radius5 "   >
                <div class="title"><span class="h4">请选择房源</span><span class="c">本人全部二手房房源</span></div>
                <div class="hd">
                    <table class="tableExpert">
                        <tr>
                            <td class="td f w185">小区名</td>
                            <td class="td w345">详情</td>
                            <td class="td w195">房源编号</td>
                            <td class="td">操作</td>
                        </tr>
                    </table>
                </div>
                <div class="mod mod_school" id="js_list_scoll">
                    <table class="tableExpert">
                        <?php
                        if(is_array($house_all) && !empty($house_all)) {
                            $n = 1;
                            foreach($house_all as $key=>$value) {
                                $street = $this->street_model->find_by_id($value['streetid']);
                                ?>
                        <tr <?php if($n%2==0) {
                             echo 'class="bg"';
                               }?>>
                            <td class="td f w185"><?php echo $value['blockshowname'];?></td>
                            <td class="td w345"><?php echo $value['room'].'室'.$value['hall'].'厅';?> / <?php echo ceil($value['buildarea']);?>㎡ / <?php echo ceil($value['price']);?>万 / <?php echo $value['district'];?> / <?php echo  $street['streetname'];?></td>
                            <td class="td w195"><a href="<?php echo get_sellinfo_url($value['id']);?>" target="_blank"><?php echo $value['id'];?></a></td>
                            <td class="td"><input type="checkbox" id="<?php echo $value['id'];?>" streetid="<?php echo $value['streetid'];?>" class="js_checkbox_house"></td>
                        </tr>
                     <?php
                                $n++;
                            }
                            }
                            ?>

                    </table>
                </div>
                    <?php
                     $price_sell=$price['current_price']==0?$price['cost_price']:$price['current_price'];
                    ?>
                <div class="bd">
                    <div class="bd_school_zw_qk">
                        <div class="left tex tex2">我要支付<span class="c"><?php echo $price_sell;?></span>房豆</div>
                    </div>
                    <div class="bd_school_zw_btn clear">

                        <?php if($info['credit']>=$price_sell) { ?>
                        <a href="javascript:void(0)" class="btnB btnSubmit radius5" id="sub">立即支付</a>
                            <?php }else { ?>
                        <a href="<?=$payment_url?>" class="btnB btnSubmit radius5" target="_blank">立即充值</a>
                       <?php }?>
                        <a href="javascript:void(0)" class="btnB btnCon radius5">取消</a> </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="http://esf.s.house365.com/min/?f=common/js/jquery.mCustomScrollbar.concat.min.js"></script>
<script>
    $(function(){

        $(".js_checkbox_house").change(function(){

            var _id = $(this).attr("id");
            var _streetid= $(this).attr("streetid");


            var obj = $(".js_select_house");
            var num = obj.length;

            var mark = 0;
            if(this.checked)
            {
                var tex1 =$(this).parents("tr").find("td:eq(0)").text();
                var tex2 =$(this).parents("tr").find("td:eq(1)").text();
                var tex3 =$(this).parents("tr").find("td:eq(2)").text();
                var tex4 =tex1+" "+tex2;

                for(var i=0;i<=num;i++ )
                {
                    var t=obj.eq(i).hasClass("input_s");
                    if(!t)
                    {
                        obj.eq(i).find(".tex").text(tex4);
                        obj.eq(i).find(".js_hidden_input").val(_id);
                        obj.eq(i).find(".streetid").val(_streetid);
                        obj.eq(i).addClass("input_s");
                        break;
                    }

                }

                //检查是否是同一个小区
                for(var i=0;i<=num;i++ )
                {
                    if(obj.eq(i).find(".streetid").val()){
                        if( _streetid!= obj.eq(i).find(".streetid").val()){
                            mark = 1;
                        }
                    }
                }
                if(mark==1){
                    $(".select_house_error").html("所选房源不在同一区属板块哦，请重新选择。");
                    $(".select_house_error").show();
                }else if(mark==0){
                    $(".select_house_error").hide();
                }

            }
            else
            {
                mark=0;
                var once=0;
                var streetid2=0;
                for(var i=0;i<=num;i++ )
                {
                    var uid = obj.eq(i).find(".js_hidden_input").val();
                    if(uid == _id)
                    {
                        obj.eq(i).find(".tex").text("请选择推广房源。");
                        obj.eq(i).find(".js_hidden_input").val("");
                        obj.eq(i).find(".streetid").val("");
                        obj.eq(i).removeClass("input_s");
                        $(".select_house_error").hide();
                        break;
                    }


                }
                //检查是否是同一个小区
                for(var i=0;i<=num;i++ )
                {
                    if(obj.eq(i).find(".streetid").val()){
                        //记录首次的值
                        if(once==0)
                        {
                            streetid2=obj.eq(i).find(".streetid").val();
                            once =1;
                        }

                        if( streetid2 != obj.eq(i).find(".streetid").val()){
                            mark = 1;
                        }
                    }
                }

                if(mark==1){
                    $(".select_house_error").html("所选房源不在同一区属板块哦，请重新选择。");
                    $(".select_house_error").show();
                }else if(mark==0){
                    $(".select_house_error").hide();
                }


            }

            var _len = $(".input_s").length;
            var o = $(".js_checkbox_house");
            if(_len>=7)
            {
                var c_len = o.length;
                for(var j=0;j<=c_len;j++ )
                {
                    if(!o.eq(j).attr("checked"))
                    {
                        o.eq(j).attr("disabled",true)
                    }
                }
            }
            else
            {
                o.attr("disabled",false)
            }
        })



        if(window.XMLHttpRequest)
        {
            (function($){
                $(window).load(function(){
                    if($("#js_list_scoll").length>0)
                    {
                        $("#js_list_scoll").mCustomScrollbar();
                    }
                });
            })(jQuery);
        }



    })



    $("#sub").click(function(){
        var mark=0;
        var once=0;
        var str='';
        var streetid2=0;
        var obj = $(".js_select_house");
        var num = obj.length;
        //检查是否是同一个小区
        for(var i=0;i<=num;i++ )
        {
            if(obj.eq(i).find(".streetid").val()){
                //记录首次的值
                if(once==0)
                {
                    streetid2=obj.eq(i).find(".streetid").val();
                    once =1;
                }

                if( streetid2 != obj.eq(i).find(".streetid").val()){
                    mark = 1;
                }
            }else if(i<5){
                openWin("warning3");
                return false;
            }
        }

        if(mark==1){
            $(".select_house_error").html("所选房源不在同一区属板块哦，请重新选择。");
            $(".select_house_error").show();
            return false;
        }else if(mark==0){
            $(".select_house_error").html("所选房源不在同一区属板块哦，请重新选择。");
            $(".select_house_error").hide();
        }

        //ajax 提交购买信息
        var obj=document.getElementsByName("rowid");
        for(i=0;i<obj.length;i++){
            if(obj[i].value){
                str = str+obj[i].value+',';
            }
        }
         if(str){
         $.ajax({
            type: 'post',
            url : '/vas_packing_house/addorder',
            data: 'str='+str,
            dataType:'json',
            success: function(msg){
			  if(msg['status']==1)
			    {
                               $("#waring_text").html("交易号："+msg['transaction_id']);
                             openWin("warning1");
                               window.setTimeout("window.location.href='/vas_packing_house/orderlist/'; ",6000);
                           }else{
			     openWin("warning2");
                            }
                }
            });
         }

    })
</script>
<div style="display:none;" class="dialog dialogW340 radius5" id="warning1">
		<div class="hd">
				<h3 class="h3">提示</h3>
				<p class="close close-win" title="关闭">关闭 </p>
		</div>
		<div class="mod">
				<div class="textMod textMod003"><img alt="" src="http://esf.s.house365.com/zsb/images/v1.0/okBg.png"> 恭喜您，购买成功！</div>
				<div class="textHd_new textHd_new02">
						<p> 购买产品：<span class="c2">房源包装&mdash;二手房搜搜</span></p>
						<p id="waring_text"></p>
						<p>温馨提示：工作人员会尽快给您排期反馈，</p>
						<p>您可以在<a class="c1" href="/vas_packing_house/orderlist/">我的购买记录</a>中查看实时进度。</p>
				</div>
		</div>
</div>
<div style="display:none;" class="dialog dialogW340 radius5"  id="warning2">
		<div class="hd">
				<h3 class="h3">提示</h3>
				<p class="close close-win" title="关闭">关闭 </p>
		</div>
		<div class="mod">
				<div class="textMod textMod003"><img alt="" src="http://esf.s.house365.com/zsb/images/v1.0/failureBg.png"> 很遗憾，购买失败！</div>
				<div class="textHd_new">
						<div class="textHd_new_link "><a href="###" class="close-win">再试一次吧！</a></div>
				</div>
		</div>
</div>
<div style="display:none;" class="dialog dialogW485 radius5" id="warning3">
		<div class="hd">
				<h3 class="h3">提示</h3>
				<p class="close close-win" title="关闭">关闭 </p>
		</div>
		<div class="mod">
				<div class="textMod textMod005">购买产品：<span class="ch">房源包装-二手房搜搜</span></div>
				<div class="sb_text_box" style="padding-left: 146px;">
						<p class="p">温馨提示：1.请选择<span class="c1">5条</span>二手房源作为推广房源。如房源出现<br>失效，过期等问题，采用备用房源。
								<br>2.推广房源必须是<span class="c1">同区属</span>房源。 </p>
						<p class="p">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;很遗憾您的房源不足五条
							        <a class="c2" href="/sell/add/" target="_blank">去发布房源 &gt;&gt;</a><br>
								</p>
				</div>
				<div class="img_pirce_box"> <img src="http://esf.s.house365.com/zsb/images/v1.0/pay_ico_zx13.png" class="img"> <span>我要支付<strong class="num"><?php echo $price['current_price']?$price['current_price']:$price['cost_price'];?></strong>房豆</span> </div>
				<div class="pop_pay_btn_box"> <a href="javascript:void(0)" class="btn btnCon btnCon_none radius5">确认支付</a> <a href="javascript:void(0)" class="btn btnCon radius5 close-win">取消</a> </div>
		</div>
</div>
</body>
</html>
