<%@ page language="java" pageEncoding="UTF-8"
         contentType="text/html; charset=UTF-8"%>
<%@ page isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
    String basePath = request.getContextPath();
    String resourcePath = basePath + "/resource";
%>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>发布活动</title>
    <jsp:include page="../common/head.jsp"></jsp:include>
</head>
<body>

<jsp:include page="../common/body_header.jsp"></jsp:include>

<div class="mid-fabu10">
    <div class="mid-fabu101">
        <div class="form-fabu10">
            <div class="fabufont">活动发布</div>
            <div class="line-fabu"></div>
            <div class="clearfix"></div>
            <div class="fabu00">
                <form  id="addForm" >
                    <div class="fabu-01">
                        <span class="fabufont1"><span class="xinghao">*</span>活动名称</span>
                        <span class="ff1">
                            <input type="text" id="activityName" name="activityName" class="fabuinput" placeholder="请输入活动名称">
                         <div class="tishi4"></div>
                        </span>

                    </div>
                    <div class="fabu-01">
                        <span class="fabufont1">活动简介</span>
                        <span class="ff1">
                            <textarea name="activityIntro" id="activityIntro" cols="30" rows="2" class="fabuinput1" placeholder="请输入活动简介" ></textarea>
                        </span>

                    </div>

                    <div class="fabu-021">
                        <span class="fabufont2"><span class="xinghao">*</span>活动类型</span>
                        <span class="radio01">
                                               <%--<input type="radio" name="activityType" value="行业交流" class="radio">行业交流&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--%>
                                                <%--<input type="radio" name="activityType" value="创业分享" class="radio">创业分享&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--%>
                                                <%--<input type="radio" name="activityType" value="路演活动" class="radio">路演活动&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--%>
                                                <%--<input type="radio" name="activityType" value="合伙人招募" class="radio">合伙人招募&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--%>
                                                <%--<input type="radio" name="activityType" value="互联网大会" class="radio">互联网大会&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--%>
                                                <%--<input type="radio" name="activityType" value="商业培训" class="radio">商业培训&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--%>
                                                <%--<input type="radio" name="activityType" value="文化体验" class="radio">文化体验&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--%>
                                                <%--<input type="radio" name="activityType" value="智能家居" class="radio">智能家居&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>--%>
                                                <%--<input type="radio" name="activityType" value="教育" class="radio">教育&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--%>
                                                <%--<input type="radio" name="activityType" value="视频分享" class="radio">视频分享&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--%>
                                                <%--<input type="radio" name="activityType" value="政民互动" class="radio">政民互动&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><br>--%>

                         <c:forEach items="${activityType}" var="item">
                             <input id="activityType" type="radio" name="activityType" value="${item.key}" class="radio">${item.key}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                         </c:forEach>
                             <div class="tishi4" id="ra"></div>
                        </span>
                    </div>
                    <div class="fabu-01">
                        <span class="fabufont1"><span class="xinghao">*</span>发起人</span>
                        <span class="ff1">
                            <input type="text" id="organiger" name="organiger" class="fabuinput" placeholder="请输入发起人">
                         <div class="tishi4"></div>
                        </span>

                    </div>
                    <div class="fabu-01">
                        <span class="fabufont1"><span class="xinghao">*</span>报名地址</span>
                        <span class="ff1">
                            <input type="text" id="enrollAddr" name="enrollAddr" class="fabuinput" placeholder="请输入报名地址">
                         <div class="tishi4"></div>
                        </span>

                    </div>
                    <div class="fabu-01">
                        <span class="fabufont1"><span class="xinghao">*</span>报名时间</span>
                        <span class="ff1">
                            <input type="text"  id="enrollTime" name="enrollTime" class="fabuinput" placeholder="请输入报名时间">
                         <div class="tishi4"></div>
                        </span>

                    </div>
                    <div class="fabu-01">
                        <span class="fabufont1"><span class="xinghao">*</span>举办地址</span>
                        <span class="ff1">
                            <input type="text" id="activityAddr" name="activityAddr" class="fabuinput" placeholder="请输入举办地址">
                         <div class="tishi4"></div>
                        </span>

                    </div>
                    <div class="fabu-01">
                        <span class="fabufont1"><span class="xinghao">*</span>举办时间</span>
                        <span class="ff1">
                            <input type="text"  id="activityTime" name="activityTime" class="fabuinput" placeholder="请输入举办时间">
                         <div class="tishi4"></div>
                        </span>

                    </div>
                    <div class="fabu-01">
                        <span class="fabufont1">活动详情</span>
                        <span class="ff1">
                            <textarea name="activityDetail" id="activityDetail"  cols="30" rows="2" class="fabuinput1" placeholder="请输入活动详情" ></textarea>
                        </span>

                    </div>




                    <div class="fabu-01">
                        <span class="fabufont1"><span class="xinghao">*</span>缩略图</span>
                        <span class="ff1">
                            <input style="border: none" id="fileImg"  type="file" name="fileImg" class="fabuinput" placeholder="">
                            <div class="tishi4" id="im"></div>
                        </span>

                    </div>
                    <%--<div class="fabu-01">--%>
                        <%--<span class="fabufont1">缩略图</span>--%>
                        <%--<div id="preview">--%>
                        <%--</div>--%>
                        <%--<input type="hidden"  id="imgFile"  name="imgFile"/>--%>
                        <%--<span class="ff1">--%>
                            <%--<input class="fabuinput"  type="file" style="margin-left:45px;border: none" onchange="preview(this)" id="fileImgEdit"  name="fileImgEdit" accept="image/gif,image/jpeg,image/jpg,image/png,image/svg"/>--%>
                         <%--</span>--%>
                    <%--</div>--%>
                    <input type="hidden" name="flag" id="flag"/>

                    <div class="clearfix"></div>
                    <button type="button" onclick="fabu()" class="fabu-but">发布</button>
                    <button type="button" onclick="zancun()" class="fabu-but1">暂存</button>
                </form>
            </div>

        </div>
    </div>
</div>
<div class="clearfix"></div>
<jsp:include page="../common/body_footer.jsp"></jsp:include>

</body>
<script>
    $.datetimepicker.setLocale('zh');
    $("#activityTime").datetimepicker({
        format: 'Y-m-d'
    });
    $.datetimepicker.setLocale('zh');
    $("#enrollTime").datetimepicker({
        format: 'Y-m-d'
    });

    function fabu() {
        $('.tishi4').text('');//清空验证
        if($('input[name="activityType"]:checked').val()==null){
            $("#ra").html("!活动类型不能为空")
        }
        if($("#fileImg")[0].files[0]==null) {
            $("#im").html("!缩略图不能为空")
        }
        $("#flag").val(1);
        var formData = new FormData();
        formData.append("fileImg", $("#fileImg")[0].files[0]);
        formData.append("activityName", $("#activityName").val());
        formData.append("activityIntro", $("#activityIntro").val());
        formData.append("activityType", $("#activityType").val());
        formData.append("organiger", $("#organiger").val());
        formData.append("enrollAddr", $("#enrollAddr").val());
        formData.append("enrollTime", $("#enrollTime").val());
        formData.append("activityAddr", $("#activityAddr").val());
        formData.append("activityTime", $("#activityTime").val());
        formData.append("activityDetail", $("#activityDetail").val());
        formData.append("flag", $("#flag").val());

        $.ajax({
            url : "<%=basePath%>/open/innovationActivity/toAdd.action",
            type : 'POST',
            async : true,
            data : formData,
            // 告诉jQuery不要去处理发送的数据
            processData : false,
            // 告诉jQuery不要去设置Content-Type请求头
            contentType : false,
            success : function(ret) {
                if(ret.stateCode==200) {
                    swal("发布成功");
                    location.href="<%=basePath%>/open/innovationActivity/index.htm";
                }else{
                    for(var item in ret.data){
                        $("[name='"+item+"']").next().text("! "+ret.data[item]);
                        $("[name='"+item+"']").next().show();
                    }
                }
            }
        });
        
    }
    function zancun() {
        $("#flag").val(2);
        var formData = new FormData();
        formData.append("fileImg", $("#fileImg")[0].files[0]);
        formData.append("activityName", $("#activityName").val());
        formData.append("activityIntro", $("#activityIntro").val());
        formData.append("activityType", $("#activityType").val());
        formData.append("organiger", $("#organiger").val());
        formData.append("enrollAddr", $("#enrollAddr").val());
        formData.append("enrollTime", $("#enrollTime").val());
        formData.append("activityAddr", $("#activityAddr").val());
        formData.append("activityTime", $("#activityTime").val());
        formData.append("activityDetail", $("#activityDetail").val());
        formData.append("flag", $("#flag").val());
        $.ajax({
            url : "<%=basePath%>/open/innovationActivity/toAdd.action",
            type : 'POST',
            async : true,
            data : formData,
            // 告诉jQuery不要去处理发送的数据
            processData : false,
            // 告诉jQuery不要去设置Content-Type请求头
            contentType : false,
            success : function(ret) {
                if(ret.stateCode==200) {
                    // alert("发布成功");
                    location.href="";
                }
            }
        });



    }

</script>
</html>