<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
?>
<div class="centreInner ">
    <div class="mainInner radius5 "> 
        <!---->
        <div class="personalBox_top">
            <?= $person ?>
        </div>
        <!---->
        <div class="titleTabBox">
            <?= $tabs ?>
        </div>
        <!---->
        <div class="branchCommon_p_box">
            <?php if ($cBidPeriods['status'] == 1) { ?>
                <div class="marketing_status_box">
                    <div class="m_item clearfix" id="bidHouseContent">
                        <div class="status_bor status_inner radius5">
                            <div class="clearfix">
                                <div class="pic_box_m">
                                    <div class="item_title">推广房源</div>
                                    <div class="radius3 pic_show" style="height: 183px;">
                                        <?php
                                        if ($houseInfo['pic1'] == '') {
                                            $pic = STATIC_SOURCE_URL . '/zsb/images/v1.0/nopic1.gif';
                                        } else {
                                            //$pic = str_replace('thumb/', '', $houseInfo['pic1']);
                                            $pic = get_big_pic_new($houseInfo['pic1']);
                                        }
                                        ?>
                                        <div class="pic"><a href="<?= get_rentinfo_url($houseInfo['id']) ?>" target="_blank"><img alt="" src="<?= $pic ?>" width="192" height="110"></a></div>
                                        <div class="info" style="padding: 8px 5px 0 5px;">
                                            <p class="tex"><a href="<?= get_rentinfo_url($houseInfo['id']) ?>" target="_blank"><?php echo csubstr($houseInfo['address'], 0, 20); ?></a></p>
                                            <p><?= $houseInfo['room'] ?>室<?= $houseInfo['hall'] ?>厅 <?= $houseInfo['buildarea'] ?>㎡ <?= $houseInfo['price'] ?><?= $house['priceunit'][$houseInfo['priceunit']]  ?></p>
                                        </div>
                                    </div>
                                </div>
                                <div class="status_box_m">

                                    <div class="item_title">
                                        <?php if ($type == 1) { ?>
                                            <div class="f_l">小区词：</div>
                                            <div class="color_title f_l"><?= $houseInfo['blockshowname'] ?></div>
                                        <?php } else { ?>
                                            <div class="f_l">热搜词：</div>
                                            <div class="color_title f_l">

                                                <div class="imitateSelect">
                                                    <label class="labelImitate" >请选竞投词</label>
                                                    <input class="imitate imitateIe" type="text"  readonly="" value="<?= $houseInfo['keyword'] ?>">
                                                    <input type="hidden" name="bidId" class="jsImitateHidden" value="<?= $houseInfo['bid'] ?>">
                                                    <div class="listImitate">
                                                        <dl class="inner" id="loadNewBid">
                                                            <?php
                                                            foreach ($houseInfo['hotsearch'] as $key => $v) {
                                                                echo '<dd><a href="####" class="link" oid="' .
                                                                $v['bid'] . '">' . $v['keyword'] . '</a></dd>';
                                                            }
                                                            ?>
                                                        </dl>
                                                    </div>
                                                </div>

                                            </div>
                                        <?php } ?>
                                        <?php if (array_key_exists('attention_id', $houseInfo) && $houseInfo['attention_id']) { ?>
                                            <div class="f_l house_gz"><a class="link link02" href="#" bid="<?= $houseInfo['bid'] ?>">已关注</a></div>
                                        <?php } else if ($houseInfo['my_record'] || $type == 1) { ?>
                                            <div class="f_l house_gz attention"><a class="link link02" href="#" bid="<?= $houseInfo['bid'] ?>">关注</a></div>
                                        <?php } ?>
                                    </div>
                                    <div class="status_m_inner status_m_inner0<?= $houseInfo['timeRing'] ?>">
                                        <div class="t_sata"><?= $houseInfo['bid_status_str'] ?></div>
                                        <div class="t_tex">剩余</div>
                                        <div class="t_time"><span class="counttime"><?= date("F d,Y H:i:s", strtotime($houseInfo['end_time'])); ?></span></div>
                                    </div>
                                    <div class="time" style="margin:3px 0px 0px 20px;">本期推广时间<br><?php echo date('Y.m.d', strtotime($houseInfo['tg_start_time'])) . '-' . date('Y.m.d', strtotime($houseInfo['tg_end_time'])); ?></div>
                                </div>

                                <div class="logbuch_box_m">
                                    <div class="item_title">目前有 <strong class="color_title" id="bidnumber"><?= $houseInfo['number'] ?></strong>人已出价
                                        <a class="link link03" href="#" id="refreshBid">刷新战况</a></div>
                                    <div class="tex">目前房豆投入情况</div>
                                    <?= $growthBrokerBidRent->rankList($houseInfo['record'], $cBidPeriods['status'], '', $houseInfo['my_record']) ?>
                                </div>

                            </div>
                        </div>
                        <div class="status_bor status_fun radius5">
                            <!--	<div class="title">我要投入</div>-->
                            <div class="title_tip_box" style="margin-bottom:-15px;"><?= $houseInfo['tip1'] ?></div>
                            <div class="forms functionBox functionBox_m" style="padding-top:15px;">
                                <dl class="list" >
                                    <dd class="list_item clearfix" >
                                        <div class="fields">
                                            <div class="fgInput nameInput ">
                                                <div class="title"><?= $houseInfo['score_input_default']['span'] ?></div>
                                                <div class="fgInput fgInput_p jsNameInput jsFgInput">
                                                    <label class="labelPrev labelPrevN jslabelPrev" for="jsNameInputNF6" style="display: block;"><?= $houseInfo['score_input_default']['value'] ?></label>
                                                    <input type="text" autocomplete="off" value="" id="jsNameInputNF6" class="input_text w70" <?php if ($houseInfo['tip']) {
                                    echo 'readonly';
                                } ?> default="<?= $houseInfo['min_score']['score'] ?>">
                                                </div>
                                                <p class="textFg">房豆</p>
                                            </div>
                                        </div>

                                    </dd>
                                </dl>
                            </div>
                            <p class="tip_ts"><?= $houseInfo['tip'] ?></p>
                            <p class="tip_ts total"><?= $houseInfo['score_input_default']['totalTip'] ?></p>
                            <div class="sata" style="padding-top:5px;padding-bottom:5px;">可用房豆：<span><?= $houseInfo['my_credit'] ?></span>房豆</div>
                            <div class="btnFBbox"> <a class="btnB btnSubmit <?php if ($houseInfo['tip']) {
                                    echo 'btnSubmitNone';
                                } ?> radius5" bid="<?= $houseInfo['bid'] ?>" href="javascript:void(0)" type="<?= $houseInfo['bidType'] ?>" houseid ="<?= $houseInfo['id'] ?>">竞投</a>
                            </div>
                            <div class="tip" style="margin-top:8px;">
                                <p>竞投期间投中状态房豆冻结</p>
                                <p>如未投中将会返还</p>
                            </div>
                        </div>
                    </div>
                </div>
<?php } else if ($cBidPeriods['status'] == 2) { ?>
                <div class="marketing_status_box">
                    <div class="m_item clearfix" id="bidHouseContent">
                        <div class="status_bor status_inner radius5">
                            <div class="clearfix">
                                <div class="pic_box_m">
                                    <div class="item_title">推广房源</div>
                                    <div class="radius3 pic_show"  style="height: 183px;">
                                        <?php
                                        if ($houseInfo['pic1'] == '') {
                                            $pic = '../images/nopic1.gif';
                                        } else {
                                            //$pic = str_replace('thumb/', '', $houseInfo['pic1']);
                                            $pic = get_big_pic_new($houseInfo['pic1']);
                                        }
                                        ?>
                                        <div class="pic"><a href="<?= $houseInfo['id'] ?>" target="_blank"><img alt="" src="<?= $pic ?>" width="192" height="110"></a></div>
                                        <div class="info"  style="padding: 8px 5px 0 5px;">
                                            <p class="tex"><a href="<?= $houseInfo['id'] ?>" target="_blank"><?= csubstr($houseInfo['address'], 0, 20); ?></a></p>
                                            <p><?= $houseInfo['room'] ?>室<?= $houseInfo['hall'] ?>厅 <?= $houseInfo['buildarea'] ?>㎡ <?= $houseInfo['price'] ?><?= $house['priceunit'][$houseInfo['priceunit']]  ?></p>
                                        </div>
                                    </div>
                                </div>
                                <div class="status_box_m" style="width:200px;">

                                    <div class="item_title">
                                        <?php if ($type == 1) { ?>
                                            <div class="f_l">小区词：</div>
                                            <div class="color_title f_l"><?= $houseInfo['blockshowname'] ?></div>
    <?php } else { ?>
                                            <div class="f_l">热搜词：</div>
                                            <div class="color_title f_l">

                                                <div class="imitateSelect">
                                                    <label class="labelImitate" >请选竞投词</label>
                                                    <input class="imitate imitateIe" type="text"  readonly="" value="<?= $houseInfo['keyword'] ?>">
                                                    <input type="hidden" name="bidId" class="jsImitateHidden" value="<?= $houseInfo['bid'] ?>">
                                                    <div class="listImitate">
                                                        <dl class="inner" id="loadNewBid">
                                                            <?php
                                                            foreach ($houseInfo['hotsearch'] as $key => $v) {
                                                                echo '<dd><a href="####" class="link" oid="' .
                                                                $v['bid'] . '">' . $v['keyword'] . '</a></dd>';
                                                            }
                                                            ?>
                                                        </dl>
                                                    </div>
                                                </div>

                                            </div>
    <?php } ?>
                                    </div>
                                    <div class="status_m_inner status_m_inner0<?= $houseInfo['timeRing'] ?>">
                                        <div class="t_tex_over" style="color:#666666;"><?= $houseInfo['bid_status_str'] ?></div>
                                    </div>
                                    <div class="time" style="margin:3px 0px 0px 20px;">下期推广时间<br/><?php echo date('Y.m.d', strtotime($houseInfo['tg_start_time'])) . '-' . date('Y.m.d', strtotime($houseInfo['tg_end_time'])); ?>
                                    </div>
                                </div>

                                <div class="logbuch_box_m logbuch_box_m02 box_history" style="width:240px;">
                                    <div class="tex_over_m" style="margin-top:106px;">离下期开始还剩
                                        <div class="t_time"><span class="counttime"><?= date("F d,Y H:i:s", strtotime($houseInfo['start_time'])) ?></span></div>
                                    </div>
                                </div>


                            </div>
                        </div>
                        <div class="status_bor status_fun radius5 ">
                            <!--	<div class="title">我要投入</div>-->
                            <div class="title_tip_box"  style="margin-bottom:-15px;"><?= $houseInfo['tip'] ?></div>
                            <div class="title_tip_box">&nbsp;</div>
                            <div class="forms functionBox functionBox_m">
                                <dl class="list">
                                    <dd class="list_item clearfix">
                                        <div class="fields">
                                            <div class="fgInput nameInput ">
                                                <div class="title"><?= $houseInfo['score_input_default']['span'] ?></div>
                                                <div class="fgInput fgInput_p jsNameInput jsFgInput ">
                                                    <label class="labelPrev labelPrevN jslabelPrev" for="jsNameInputNF6" style="display: block;"><?= $houseInfo['score_input_default']['value'] ?></label>
                                                    <input type="text" autocomplete="off" disabled="" default="1<?= $houseInfo['min_score']['score'] ?>" value="" id="jsNameInputNF6" readonly class="input_text w70 readonly_input_text">
                                                </div>
                                                <p class="textFg">房豆</p>
                                            </div>
                                        </div>

                                    </dd>
                                </dl>
                            </div>
                            <p class="tip_ts"><?= $houseInfo['tip'] ?></p>
                            <p class="tip_ts total"><?= $houseInfo['score_input_default']['totalTip'] ?></p>
                            <div class="sata">可用房豆：<?= $houseInfo['my_credit'] ?>房豆</div>
                            <div class="btnFBbox"> <a class="btnB btnSubmit btnSubmitNone radius5" href="javascript:void(0)" type="<?= $houseInfo['bidType'] ?>" houseid ="<?= $houseInfo['id'] ?>">竞投</a>
                            </div>
                            <div class="tip" style="margin-top:8px;">
                                <p>竞投期间投中状态房豆冻结</p>
                                <p>如未投中将会返还</p>
                            </div>
                            <input type="hidden" id="selectBid" value="">
                            <input type="hidden" id="selectBidHouseId" value="<?= $houseInfo['id'] ?>">
                            <input type="hidden" id="selectBidTypeId" value="<?= $type ?>">
                        </div>
                    </div>
                </div>
<?php } else { ?>
                <div class="marketing_status_box">
                    <div class="m_item clearfix" id="bidHouseContent">
                        <div class="status_bor status_inner radius5">
                            <div class="clearfix">
                                <div class="pic_box_m">
                                    <div class="item_title">推广房源</div>
                                    <div class="radius3 pic_show"  style="height: 183px;">
                                        <?php
                                        if ($houseInfo['pic1'] == '') {
                                            $pic = '../images/nopic1.gif';
                                        } else {
                                            //$pic = str_replace('thumb/', '', $houseInfo['pic1']);
                                            $pic = get_big_pic_new($houseInfo['pic1']);
                                        }
                                        ?>
                                        <div class="pic"><a href="<?= $houseInfo['id'] ?>" target="_blank"><img alt="" src="<?= $pic ?>" width="192" height="110"></a></div>
                                        <div class="info"  style="padding: 8px 5px 0 5px;">
                                            <p class="tex"><a href="<?= $houseInfo['id'] ?>" target="_blank"><?= csubstr($houseInfo['address'], 0, 20) ?></a></p>
                                            <p><?= $houseInfo['room'] ?>室<?= $houseInfo['hall'] ?>厅 <?= $houseInfo['buildarea'] ?>㎡ <?= $houseInfo['price'] ?><?= $house['priceunit'][$houseInfo['priceunit']] ?></p>
                                        </div>
                                    </div>
                                </div>
                                <div class="status_box_m">

                                    <div class="item_title">
                                        <?php if ($type == 1) { ?>
                                            <div class="f_l">小区词：</div>
                                            <div class="color_title f_l"><?= $houseInfo['blockshowname'] ?></div>
    <?php } else { ?>
                                            <div class="f_l">热搜词：</div>
                                            <div class="color_title f_l">

                                                <div class="imitateSelect">
                                                    <label class="labelImitate" >请选竞投词</label>
                                                    <input class="imitate imitateIe" type="text"  readonly="" value="<?= $houseInfo['keyword'] ?>">
                                                    <input type="hidden" name="bidId" class="jsImitateHidden" value="<?= $houseInfo['bid'] ?>">
                                                    <div class="listImitate">
                                                        <dl class="inner" id="loadNewBid">
                                                            <?php
                                                            foreach ($houseInfo['hotsearch'] as $key => $v) {
                                                                echo '<dd><a href="####" class="link" oid="' .
                                                                $v['bid'] . '">' . $v['keyword'] . '</a></dd>';
                                                            }
                                                            ?>
                                                        </dl>
                                                    </div>
                                                </div>

                                            </div>
    <?php } ?>
                                    </div>
                                    <div class="status_m_inner status_m_inner0<?= $houseInfo['timeRing'] ?>">
                                        <div class="t_sata"><?= $houseInfo['bid_status_str'] ?></div>
                                        <div class="t_tex">剩余</div>
                                        <div class="t_time"><span class="counttime"><?= date("F d,Y H:i:s", strtotime($houseInfo['end_time'])) ?></span></div>
                                    </div>
                                    <div class="time" style="margin:3px 0px 0px 20px;">本期推广时间<br>
    <?php echo date('Y.m.d', strtotime($houseInfo['tg_start_time'])) . '-' . date('Y.m.d', strtotime($houseInfo['tg_end_time'])); ?></div>
                                </div>
                                <div class="logbuch_box_m">

                                    <div class="item_title">目前有 <strong class="color_title" id="bidnumber"><?= $houseInfo['number'] ?></strong>人已出价</div>
                                    <div class="tex">目前房豆投入情况</div>
    <?= $growthBrokerBidRent->rankList($houseInfo['record'], $cBidPeriods['status'], '', $houseInfo['my_record']) ?>
                                </div>
                            </div>
                        </div>
                        <div class="status_bor status_fun radius5">
                            <?php
                            $tuiHuan = '';
                            if ($houseInfo['winFlag'] > 0 && $houseInfo['winFlag'] <= 4) {
                                $stateAuction = "stateAuction1";
                                $fen = "投入" . $houseInfo['my_score'] . "房豆";
                            } else if ($houseInfo['winFlag'] == '-1') {
                                $stateAuction = "stateAuction3";
                                $fen = "";
                            } else {
                                $stateAuction = "stateAuction2";
                                $fen = "投入" . $houseInfo['my_score'] . "房豆";
                                $tuiHuan = '房豆已退还';
                            }
                            ?>
                            <div class="stateAuction <?= $stateAuction ?>">
                                <div class="inner"><?= $fen ?></div>
                            </div>
                            <div class="stateAuction2Text"><?= $tuiHuan ?></div>
                            <input type="hidden" id="selectBid" value="">
                            <input type="hidden" id="selectBidHouseId" value="<?= $houseInfo['id'] ?>">
                            <input type="hidden" id="selectBidTypeId" value="<?= $type ?>">
                        </div>
                    </div>
                </div>
<?php } ?>

            <!--竞投说明 -->
            <?php require APPPATH.'views/market_bid_rent/bid_rent_ruler.php' ?>
        </div>
    </div>
</div>
<script type='text/javascript'>
    $(function() {
        //加载某个热搜词的战况
        $('#loadNewBid .link').bind('click', function() {
            var bid = $(this).attr('oid');
            //$('#refreshBid').attr('bid', bid);
            $('.btnSubmit').attr('bid', bid);
            $('#selectBid').val(bid);
            //$('#history').attr('href', $('#history').attr('url') + '&' + bid );
            //getNewBidRecord(bid, {@$houseid@});
            openWin("loadingjs");
            refreshBid();
        }
        );
        //关注
        $(".house_gz a").click(function() {
            var abtn = $(this);
            var c = $(this).parent();
            if (c.hasClass('attention')) {
                $.get("/market_bid_rent/attention", {bid: abtn.attr('bid'), houseid: $('.btnSubmit').attr('houseid'), action: 'attention'}, function(data) {
                    //console.log(data);
                    if (data.result == 1) {
                        abtn.text("已关注");
                        openWin('atttention');
                        c.removeClass('attention');
                        var attentionNumber = $("#js_show_pop_zs").find(".num");
                        attentionNumber.text(parseInt(attentionNumber.text()) + 1);
                        var toU = '/market_bid_attention/helper/';
                        $("#attentionIframe").attr("src", toU + "?v=" + Math.random());
                    } else {
                        openWin('atttention_warning');
                    }
                }, 'json');
            }
            return false;
        })

        //刷新战况
        $('#refreshBid').bind('click', function() {
            //var bid = $(this).attr('bid');
            //if (bid) {getNewBidRecord(bid, $(this).attr('houseid'));}
            refreshBid();
        });
		/****modify**/
        //竞投提示
        $(".btnSubmit").click(function(){
            var btn = $(this);
            if (btn.hasClass("btnSubmitNone")) {
                return false;
            }
            var score = $("#jsNameInputNF6").val();                       
            //提示
            var minScore = $("#jsNameInputNF6").attr('default');
            var maxScore = $("#jsNameInputNF6").parents(".status_bor").find(".sata span").text();
            var tipP = $("#jsNameInputNF6").parents(".forms").next();
            var scored = /^\d+$/;
            if (!scored.test(score)) {
                tipP.html("请填写大于0的整数");
                return
            }
            if (isNaN(parseInt(score)) || parseInt(score) < parseInt(minScore)) {
                tipP.html("您投入的房豆不足");
                return
            }           
            if (parseInt(score) > parseInt(maxScore)) {
                tipP.html("您投入的房豆超过了可用房豆！");
                return
            }
            var bid_id = $(this).attr('bid');
            var houseid = $(this).attr('houseid');
            if (bid_id == '') {
                bidTip('warning', '请选择竞投词');                
                return false;
            }
            $("#dialogSaveDiv").html("您确定投入"+score+"房豆参与竞投吗？");
            openWin("dialogtc");
        });
        /****modify**/
        //竞投
        $("#payCredit").click(function() {
            /****modify**/
            $("#dialogtc").hide();
            openWin("loadingjs");
            var bid_id = $(".btnSubmit").attr('bid');
            var houseid = $(".btnSubmit").attr('houseid');
            var score = $("#jsNameInputNF6").val();     
             /****modify**/
            $.get("/market_bid_rent/bid", {score: score, bid: bid_id, houseid: houseid, action: 'bid'}, function(data) {
                $("#loadingjs").hide();
                if (data.result == 1) {
                    bidTip('success', "竞投提交成功！");
					var bidAOption = {url:'/market_bid_attention/helper/'}
                    $("#bid_attention_helper").bidAttentionHelper(bidAOption);
                    refreshBid();
                } else {
                    var errorCode = data.error.errorCode;
                    var error = {1: '付费经纪人才有此权限！', 2: '你的房豆不足！', 3: '房源不满足竞投标准', 4: '你的等级不够！', 5: '你投入的房豆不足！', 10: '对不起，请稍后再试！', 100: '本期竞投已结束，不能提交！', 200: '对不起，请稍后再试！'};
                    bidTip('warning', error[errorCode]);
                }
            }, 'json');
            return false;
        });
        $(".m_item input").keyup(function() {
            var addValue = $(this).val();
            if (addValue.length == 0) {
                addValue = 0;
            }
            //
            addValue = parseInt(addValue);
            if (!isNaN(addValue)) {
                var totalSpan = $(this).parents(".status_bor").find(".total span");
                if (totalSpan.length) {
                    var defaultValue = totalSpan.attr('value');
                    totalSpan.html(parseInt(defaultValue) + addValue);
                }
            }
        });
    });

    //重新刷页面
    function refreshBid() {
        var form = $('form[name="search_form"]');
        var tab = form.find('input[name="tab"]')
        var d = {};
        form.find('input').each(function() {
            d[$(this).attr('name')] = $(this).val();
        })
        var houseid = $('.btnSubmit').attr('houseid');
        var type = $('.btnSubmit').attr('type');
        if ($('.btnSubmit').attr('bid')) {
            bid = $('.btnSubmit').attr('bid');
            d['bid'] = bid;
        } else if ($('#selectBid').val()) {
            d['bid'] = $('#selectBid').val();
            houseid = $('#selectBidHouseId').val();
            type = $('#selectBidTypeId').val();
        } else {
            return;
        }
        d['type'] = type;
        d['houseid'] = houseid;
        $.get("/market_bid_rent/refresh/", d, function(data) {
            if (data.length) {
                if(data=='errorCode401') {
                    alert('请重新登录');
                    window.location.href = '/market_bid_rent/jump/login';
                } else {
                    $("#centre").html(data);
                    $('#gTipsCoverloadingjs').remove();
                    $("#loadingjs").hide();
                }
                
            }
        },'text')
    }

    //获取最新一期
    function getNewBidRecord(bid, houseid) {
        $.ajax({
            type: "GET",
            url: "market_bid_rent.php",
            data: {'action': 'refreshRank', 'bid': bid, 'id': houseid},
            success: function(data) {
                var arrData = $.parseJSON(data);
                if (!$.isEmptyObject(arrData)) {
                    $('#bidnumber').html(arrData.number);
                    $('.fraction_rank_box').remove();
                    $('.logbuch_box_m').append(arrData.recordHtml);
                }
            }
        });
    }


    $(".counttime").each(function() {
        var status = <?= $cBidPeriods['status'] ?>;
        var year;
        if (status == 2) {
            year = "<span class='cd-time'>%d</span>天";
        } else {
            year = '';
        }
        var x = $(this).text();
        if (x.length) {
            $(this).countdown({
                htmlTemplate: year + "<span class='cd-time'>%h</span>时<span class='cd-time'>%i</span>分<span class='cd-time'>%s</span>秒",
                date: x,
                yearsText: '年',
                monthsText: '月',
                daysText: '天',
                hoursText: '时',
                minutesText: '分',
                secondsText: '秒',
                servertime: '<?= microtime(true) * 1000 ?>'
            });
        }
    });
</script>


<!---------modify---------->
<!--确定操作弹框-->
<div id="dialogtc" class="dialog radius5">
	<div class="hd">
		<h3 class="h3">提示</h3>
		<span title="关闭" class="close close-win">&Chi;</span> </div>
	<div class="mod">
		<div class="text" id="dialogSaveDiv"></div>
		<div style="padding:20px 0 0 65px;">
                    <a id="payCredit" href='####' class="btn savePrjoect btnConColor radius5">确定</a>
                    <a href="####" class="btn btnCon radius5 close-win">取消</a>                
		</div>
	</div>
</div>
<!---------modify---------->