release.html 3.0 KB
{extend name="layout/default"}
{block name="content"}
    <div class="tender_rCon">
        <h1 class="tender_rTxt">发布招标</h1>
        <div class="tender_rBox">
            <form id="form">
                <div class="release_Li clearfix">
                    <label for=""><span>*</span>&nbsp;&nbsp;&nbsp;</label>
                    <select name="style" id="" class="release_op">
                        <option value="">请选择类型</option>
                        {foreach $style as $s}
                        <option  value="{$s.id}">{$s.title}</option>
                        {/foreach}
                    </select>
                </div>
                <div class="release_Li clearfix">
                    <label for=""><span>*</span>&nbsp;&nbsp;&nbsp;</label>
                    <input type="text" class="release_input" name="title"  placeholder="请输入标题">
                </div>
                <div class="release_Li clearfix">
                    <label for=""><span>*</span>&nbsp;&nbsp;&nbsp;</label>
                    <textarea placeholder="请输入内容" name="content" id="" cols="30" rows="10" class="release_textarea"></textarea>
                </div>
                <div class="release_Li clearfix">
                    <label for=""><span>*</span>&nbsp;&nbsp;&nbsp;</label>
                    <input type="hidden" class="release_input" name="image" id="image">
                    <div class="release_file">
                        <div class="release_Imgs"><img src="/statis/image/icon50.png" alt=""></div>
                        <input type="file" name="file" onchange="sc(this);">
                    </div>
                </div>
            </form>
            <div class="release_btn">提交</div>
        </div>
    </div>
<script>
    $('.release_op').change(function () {
        $(this).css('color','black')
    });
    function sc(e){
            var data = new FormData($('#form')[0]);
            $.ajax({
                url: "/admin/ajax/upload",
                type: 'POST',
                data: data,
                dataType: 'JSON',
                cache: false,
                processData: false,
                contentType: false
            }).done(function(ret){
                if(ret['code']==1){
                    $("#image").val(ret.data.url);
                    $('.release_Imgs').find('img').attr('src',ret.data.url)
                    w('上传成功');
                }else{
                   w('上传失败');
                }
            });
    }
    $(".release_btn").on("click",function () {
        var data=$("#form").serialize();
        if($(".release_op  option:selected").text() == '请选择类型'){
            w('请选择类型');
        }else if($('.release_input').val() == ''){
            w('请输入标题');
        }else if($('.release_textarea').val() ==''){
            w('请输入内容');
        }else{
            ajax("/index/invitation/release",data,"post",function (res) {
                w(res.msg);
            },"");
        }
    })
</script>
{/block}