publishArticle.html 8.29 KB
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>Yoho!Buy运营平台</title>
    <script src="/pfcms/js/include.js"></script>
    <script src="/pfcms/js/ajaxfileupload.js"></script>
    <style>
        .btn-long {
            width: 120px;
            height: 37px;
            line-height: 37px;
            font-size: 15px;
            color: white;
            border-radius: 5px;
            display: inline-block;
            cursor: pointer;
            text-align: center;
        }
        .btn-long:hover {
            opacity: 0.9;
        }

    </style>
</head>
<body class="easyui-layout" >
<div  region="north" style="height: 100px;">
    <script>
        document.write(addHead('运营管理', '种草内容发布'));
    </script>

</div>
<div region="center" id="labelGroupList" style="margin-left: 20px">
    <div id="tt" class="easyui-layout" fit="true" style="overflow-y: scroll">
        <form name="publishArticleForm" id="publishArticleForm" method="post"   >
            <div style="margin-top: 20px;margin-left: 30px">
                <table border="0" style="width:95%;margin-top:5px;line-height:30px;" id="tab">

                    <tr style="height: 60px">
                        <td >
                            <span style="color:red">*</span><label>选择用户</label>  <br>
                            <input id="articleUid" name="articleUid" class="easyui-textbox" style="width: 380px;"/>
                        </td>
                    </tr>

                    <tr style="height: 60px">
                        <td>
                            <span style="color:red">*</span><label>文字内容</label> <br>
                            <input id="content" name="content" class="easyui-textbox" style="width: 380px;"/>
                        </td>
                    </tr>

                    <tr style="height: 60px">
                        <td>
                            <span style="color:red">*</span><label>选择话题</label> <br>
                            <input id="topic" name="topicId" class="easyui-combobox" style="width: 380px;"/>
                        </td>
                    </tr>
                    <tr style="height: 20px">
                        <td >
                            <span style="color:red">*</span><label>选择图片</label>
                            <a id="addImage" class="btn-default" >选择图片+</a>
                            <input id="imgs" name="articleImages" hidden="hidden"/>
                        </td>
                    </tr>
                    <tr style="height: 60px">
                        <td id="imgTd">
                            <div id="imageUpload">
                            </div>
                        </td>
                    </tr>
                    <tr style="height: 60px">
                        <td>
                            <span style="color:red">*</span><label>关联商品</label> <br>
                            <a id="addSkn" class="btn-default" >新增商品+</a>
                            <input id="skns" name="articleSkns" hidden="hidden"/>
                        </td>
                        <td>
                            <img id="good1" src="" hidden>
                            <img id="good2" src="" hidden>
                        </td>
                    </tr>
                    <tr>
                        <td height="50" valign="bottom">
                            <input  class="btn-primary" type="button" onclick="submit()"  value="保存"/>
                        </td>
                    </tr>
                </table>
            </div>
        </form>

    </div>

</div>



</body>
<script>
    var count = 1;

    $(function () {
        $("#articleUid").textbox({
            required: true,
            missingMessage: "发布用户不能为空",
            prompt: "请输入发布用户"
        });
        $("#content").textbox({
            required: true,
            missingMessage: "发布内容不能为空",
            prompt: "请输入发布内容"
        });
        $("#topic").combobox({
            prompt: "请选择话题"
        });


        $("#imageUpload").imageUpload({
            width: 171,
            height: 120,
            realInputName: "url",
            url: contextPath + '/fileupload/uploadFile',
            queryParams: {
                bucket: "activity"
            },
            onBeforeSubmit: function () {
                $.messager.progress({
                    title: "正在执行",
                    msg: "正在执行,请稍后...",
                    interval: 500,
                    text: ""
                });
            },
            filterFileName: function (data) {
                debugger;
                if (!data || data.code != 200) {
                    $.messager.progress("close");
                    $.messager.alert("错误",data.message);
                    return "";
                }

                return data.data.url;
            },
            onLoadSuccess: function (data) {
                $.messager.progress("close");
                $("#imageUpload").after('<div id="imageUpload1">\n' +
                    '                            </div>');
                oo(1);
                return false;
            }
        });
        function oo(num){
            if(count >8){
                return
            }
            $("#imageUpload"+num).imageUpload({
                width: 171,
                height: 120,
                realInputName: "url",
                url: contextPath + '/fileupload/uploadFile',
                queryParams: {
                    bucket: "activity"
                },
                onBeforeSubmit: function () {
                    $.messager.progress({
                        title: "正在执行",
                        msg: "正在执行,请稍后...",
                        interval: 500,
                        text: ""
                    });
                },
                filterFileName: function (data) {
                    debugger;
                    if (!data || data.code != 200) {
                        $.messager.progress("close");
                        $.messager.alert("错误",data.message);
                        return "";
                    }
                    return data.data.url;
                },
                onLoadSuccess: function (data) {
                    $.messager.progress("close");
                    var nnum = num+1;
                    $("#imageUpload"+num).after('<div id="imageUpload'+nnum+'">  </div>');
                    count = count+1;
                    oo(nnum);
                    return false;
                }
            });
        }



    });
    function submit(){
        $("#publishArticleForm").form("submit",{
            url : "http://localhost:8088/platform/grassArticle/publishArticle",
            onSubmit : function(param) {
                if (!$("#publishArticleForm").form("validate")) {
                    return false;
                }
                var imgs = '';
                $("input[name='url']").each(function(j,item){
                    var url = item.val();
                    if(imgs == ''){
                        imgs = url;
                    }else{
                        imgs = imgs + ","+url;
                    }
                });
                $("#imgs").val(imgs);
                return true;
            },
            success : function(data) {
                if (data) {
                    data = $.parseJSON(data);
                    if (data.code == 200) {
                        $.messager.alert("保存成功");
                    } else {
                        $.messager.alert("保存失败", data.message, "error");
                    }
                } else {
                    $.messager.alert("保存失败", data.message, "error");
                }
            }
        });
    }

    function submit1(){
        debugger

        var imgs = '';
        $("input[name='url']").each(function(j,item){
            var url = item.value;
            if(imgs == ''){
                imgs = url;
            }else{
             imgs = imgs + ","+url;
         }
        });
        $("#imgs").val(imgs);
        $("#publishArticleForm").action="http://localhost:8088/platform/grassArticle/publishArticle";
        $("#publishArticleForm").submit();
    }
</script>
</html>