<style>
.modal-footer {
	text-align: left;
    padding: 14px 15px 15px;
    margin-bottom: 0;
    margin-left: 42%;
    background-color: #fff; 
    border-top: 0px solid #ddd;
    border-radius: 0 0 6px 6px;
    box-shadow: inset 0 1px 0 #fff;
}

#form-field-3, #form-field-phone {
    display: inline !important;
    width: 50% !important;
}

.h5a-btn.btn-primary {
    color: #ffffff;
    background-color: #6bb5c1;
    border-color: #4aa1af;
    background-color: #f5f5f5;
    border-color: #f8f8f8;
    border-radius: 5px;
    margin-left: 10px;
}

.addphone, .addimg {
    margin-left: 10px;
    border: 0px;
}

.addphone, .addimg {
    margin-left: 10px;
    border: 0px;
    padding-left: 16px;
    padding-right: 16px;
    padding-top: 6px;
    padding-bottom: 6px;
    border-radius: 4px;
    background-color: #eee;
}

.edt{padding-left:30px;}
</style>

<nav class="breadcrumb"> 五折卡模块 <span class="c-gray en">&gt;</span> 区域/商圈配置 </nav>
	<div class="" role="main" id="bnb">
	
		<div style="width:100%;border-bottom: 1px solid #e5e5e5;"><p class="edt"  style="font-size: 28px; color: #7d7d7d;vertical-align: middle; padding-top: 15px; padding-bottom: 15px;">区域/商圈配置</p>
		</div>
		<div class="qusq_out_box">	
        <form action="<?php echo site_url('admin/area/add');?>" method="post">			
			<div class="bs-example">
                <?php
                    $cdnum = count($info);
                    foreach ($info as $k => $v) {
                ?>
                        <div class="qusq_in_box">
                            <span sid="<?php echo $k+1;?>" style="width: 96px!important;">菜单项<?php echo $k+1;?></span>
                            <input type="text" maxlength="6" vid="<?php echo $v['id'];?>" name="district[<?php echo $v['id'];?>]" value="<?php echo $v['area_name'];?>">
                            <div class="qusq_in_btn qusq_in_off"> <img src="<?php echo asset_url('images/lajitong.png')?>">
                            </div>
                        </div>
                <?php
                    }
                ?>
                    <div class="qusq_in_box">
                        <span sid="<?php echo $cdnum+1;?>" style="width: 96px!important;">菜单项<?php echo $cdnum+1;?></span>
                        <input type="text" maxlength="6" vid="<?php echo isset($v['id'])?($v['id']+1):1;?>" name="district[<?php echo isset($v['id'])?($v['id']+1):1;?>]" value="">
                        <div class="qusq_in_btn qusq_in_add"> <img src="<?php echo asset_url('images/lALORKum1Cgo_40_40.png');?>">
                        </div>
                    </div>
				<div class="lr_ts" style="float:none;margin: 10px 0px;">
                     <img src="<?php echo asset_url('images/tips.png')?>" alt="" style="width: 14px;">
                     <span style="font-size:12px;">提示：请填写区域/商圈的自定义项，点击加号增加一个选项，最多填写6个汉字含英文。</span>
				</div>
                <button class="edit_btn" id="save">保存修改</button>
	        </div>
        </form>
        </div>
	</div>
	<script type="text/javascript">
		$(function(){
            //表单提交判断值
            $('#save').on('click',function(event) {
                event.preventDefault();
                /* Act on the event */
                $('.qusq_in_box').each(function(index, el) {
                    var send_val = $(this).children('input').val();
                    var rege=/^([\u4E00-\u9FA5]|\-|\_|\w){0,6}$/;
                    if(!rege.test(send_val))
                    {
                        alert('格式有误');
                        return false;
                    }
                    $('form').submit();
                });
            });
			// 添加 lALORKum1Cgo_40_40.png  lajitong.png
			$(document).on('click', '.qusq_in_add', function(event) {
                var columns_vid = $(".qusq_in_box").last().children('input').attr('vid');
                var columns_id = $(".qusq_in_box").last().children('span').attr('sid');
                var add_columns_id = parseInt(columns_id) +1;
                var add_columns_vid = parseInt(columns_vid) +1;
				var bqs='<div class="qusq_in_box"><span class="qusq_ad_span" sid="'+add_columns_id+'">菜单项'+add_columns_id+'</span><input type="text" maxlength="6" vid="'+add_columns_vid+'" name="district['+add_columns_vid+']"><div class="qusq_in_btn qusq_ad_btn qusq_in_add"><img src="assets/images/lALORKum1Cgo_40_40.png"></div></div>';
				$(this).parent().after(bqs);
				$(this).find('img').attr('src','<?php echo asset_url("images/lajitong.png");?>');
				$(this).removeClass('qusq_in_add');
				$(this).addClass('qusq_in_off');
			})

			$(document).on('click', '.qusq_in_off', function(event) {
                var obj  = $(this);
                var cid = $(this).prev('input').attr('vid');
                $.post('<?php echo site_url("admin/area/del");?>', {id: cid}, function(data) {
                    /*optional stuff to do after success */
                    obj.parent().remove();
                },'json');
				
			})

		})	
	</script>

