rewardsEdit.html 11.3 KB
<!DOCTYPE html>
<div id="tt" class="easyui-layout" fit="true" style="overflow-y: scroll">
    <form name="activityAddForm" id="activityAddForm" method="post" enctype="multipart/form-data">
        <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 width="10%"><span style="color:red">*</span><label>活动类型</label></td>
                    <td>
                        <input class="easyui-combobox" id="rewardType" name="type" style="width: 380px;">
                        </input>
                    </td>
                </tr>

                <tr style="height: 60px">
                    <td width="10%"><span style="color:red">*</span>活动名称</td>
                    <td width="50%">
                        <input id="rewardNameN" name="rewardName" class="easyui-textbox" style="width: 380px;"/></td>
                </tr>
                <tr style="height: 60px">
                    <td width="10%">活动描述</td>
                    <td width="50%">
                        <input id="descriptionN" name="description" class="easyui-textbox" style="width: 380px;"/></td>
                </tr>



                <tr  style="height: 60px">
                    <td width="10%"><span style="color:red">*</span>活动时间</td>
                    <td width="40%">
                        <input id="startTimeStr" name="startTimeStr" class="easyui-datetimebox" data-options="prompt:'开始时间'"/>~

                        <input id="endTimeStr" name="endTimeStr" class="easyui-datetimebox" data-options="prompt:'结束时间'"/>
                    </td>
                </tr>
                <tr style="height: 60px">
                    <td width="10%"><span style="color:red">*</span>优先级</td>
                    <td width="50%">
                        <input id="priorityN" name="priority"  class="easyui-textbox" style="width: 380px;"/></td>
                </tr>

                <tr style="height: 60px">
                    <td width="10%"><span style="color:red">*</span>奖励类型</td>
                    <td width="50%">
                        <input id="coin" name="rewardType"  class="easyui-combobox" style="width: 380px;"/></td>
                </tr>

                <tr style="height: 60px">
                    <td width="10%"><span style="color:red">*</span>单次奖励数量</td>
                    <td width="50%">
                        <input id="numN" name="num" type="number"  class="easyui-textbox" style="width: 380px;"/></td>
                </tr>


                <tr class="interval" style="height: 60px">
                    <td width="10%"><span style="color:red">*</span>奖励次数/周期</td>
                    <td width="50%">
                        <input id="maxTimeN" name="maxTime" type="number"  class="easyui-textbox" style="width: 160px;"/>次/
                        <input id="rewardIntervalN" name="rewardInterval" type="number"  class="easyui-textbox" style="width: 160px;"/>
                    </td>
                </tr>

                <tr class="topic" style="height: 60px">
                    <td width="10%"><span style="color:red">*</span>关联话题</td>
                    <td width="30%">
                        <input type="radio" id="allRadio" name="type" value="1" checked>全部话题&nbsp;&nbsp;
                        <input type="radio" id="normalRadio" name="type" value="2">部分话题&nbsp;&nbsp;
                        <br>
                        <textarea id="includeTopicsN" name="includeTopics"   style="width: 380px;"/>
                        <input id="allTopic" name="allTopic"  type="hidden" />
                    </td>

                </tr>

                <tr class="config" style="height: 60px">
                    <td width="10%">活动短语(文案中NUM将被替换成活动配置的奖励数量)</td>
                    <td width="50%">
                        <input id="context" name="context"  class="easyui-textbox" style="width: 380px;"/></td>
                </tr>


                <tr  class="config" style="height: 60px">
                    <td width="20%">活动图片</td>
                    <td>
                        <div id="imageUpload">
                        </div>
                        <span style=" margin-left: 10px; color: red"> 图片宽高(186x170)</span>
                    </td>
                </tr>


            </table>
        </div>
    </form>
</div>
<script>


    function getStrLength(str) {
        var cArr = str.match(/[^\x00-\xff]/ig);
        return str.length + (cArr == null ? 0 : cArr.length);
    }

    $(function () {
        $("#imageUpload").imageUpload({
            width: 171,
            height: 120,
            realInputName: "imageUrl",
            url: serverContextPath + '/fileupload/upload',
            queryParams: {
                bucket: "grassImg"
            },
            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;
            },
            onLoadSuccess: function (data) {
                $.messager.progress("close");

                return false;
            }
        });

        // 名称不能为空
        $("#rewardNameN").textbox({
            required: true,
            missingMessage: "活动名称不能为空",
            prompt: "请输入活动名称(不能超过30个字)",
            onChange: function(data){
                if (data!="" && getStrLength(data) > 30) {
                    $.messager.alert("提示", "活动名称长度不能超过30个字", "info");
                    $("#rewardNameN").focus();
                    $("#rewardNameN").textbox("setValue","");
                }
            }
        });

        // 优先级
        $("#priorityN").textbox({
            required: true,
            missingMessage: "优先级不能为空",
            prompt: "正整数",
            onChange: function(data){
                if(data != "" && Number(data) < 0 ){
                    $.messager.alert("提示", "优先级必须为正整数!", "info");
                    $("#priorityN").textbox("setValue","");
                }
            }
        });

        $("#numN").textbox({
            required: true,
            prompt: "有货币数量",
            onChange: function(data){
                debugger
                if(data != "" && Number(data) < 0){
                    $.messager.alert("提示", "有货币数量必须大于0!", "info");
                    $("#numN").textbox("setValue","");
                }

            }
        });

        $("#maxTimeN").textbox({
            required: true,
            prompt: "最大次数",
            onChange: function(data){
                debugger
                if(data != "" && Number(data) < 0){
                    $.messager.alert("提示", "最大次数必须大于0!", "info");
                    $("#maxTimeN").textbox("setValue","");
                }

            }
        });
        $("#rewardIntervalN").textbox({
            required: true,
            prompt: "奖励周期",
            onChange: function(data){
                debugger
                if(data != "" && Number(data) < 0){
                    $.messager.alert("提示", "奖励周期必须大于0!", "info");
                    $("#rewardIntervalN").textbox("setValue","");
                }

            }
        });

        $("#coin").combobox({
            valueField : "value",
            textField : "text",
            required:true,
            prompt: "请选择奖品类型",
            disabled:true,
            data:[{text:"有货币奖励",value:"1"}]
        });
        $("#coin").combobox('setValue',1);


        $("#includeTopicsN").hide();

        $("#allRadio").click(function(){
            $("#includeTopicsN").hide();
        });
        $("#normalRadio").click(function(){
            $("#includeTopicsN").show();
        });
        debugger
        var data = paramObject.mkData;


        $("#rewardType").combobox({
            valueField : "value",
            textField : "text",
            required:true,
            prompt: "请选择奖品类型",
            data:[{text:"首发奖励",value:"3"},{text:"发布奖励",value:"1"},{text:"话题奖励",value:"2"}],
            onChange: function(){
                var type =$("#rewardType").combobox("getValue");
                debugger
                if(type == 1){
                    $(".interval").attr("style","display:");
                    $(".topic").attr("style","display:none");
                    $(".config").attr("style","display:");
                    $("#maxTimeN").textbox({disabled:false});
                    $("#rewardIntervalN").textbox({disabled:false});
                }
                if(type ==2){
                    $(".interval").attr("style","display:");
                    $(".topic").attr("style","display:");
                    $(".config").attr("style","display:");
                    $("#maxTimeN").textbox({disabled:false});
                    $("#rewardIntervalN").textbox({disabled:false});
                }
                if(type ==3){
                    $(".interval").attr("style","display:");
                    $(".topic").attr("style","display:none");
                    $(".config").attr("style","display:none");
                    $("#maxTimeN").textbox("setValue","1");
                    $("#rewardIntervalN").textbox("setValue","0");
                    $("#maxTimeN").textbox({disabled:true});
                    $("#rewardIntervalN").textbox({disabled:true});
                }
            }
        });
        $("#rewardType").combobox('setValue',1);


        if (data){
            if(data.allTopic==1){
                $("#allRadio").prop("checked",true);
                $("#normalRadio").prop("checked",false);
            }else {
                $("#allRadio").prop("checked",false);
                $("#normalRadio").prop("checked",true);
                $("#includeTopicsN").show();
            }
            $("#startTimeStr").datetimebox('setValue',data.startTimeStr);
            $("#endTimeStr").datetimebox('setValue',data.endTimeStr);


            $("#maxTimeN").textbox("setValue", data.maxTime);
            $("#numN").textbox("setValue", data.num);
            $("#priorityN").textbox("setValue", data.priority);
            $("#rewardIntervalN").textbox("setValue", data.rewardInterval);
            $("#includeTopicsN").val( data.includeTopics);
            $("#descriptionN").textbox("setValue", data.description);
            $("#rewardNameN").textbox("setValue", data.rewardName);
            $("#context").textbox("setValue", data.context);
            $("#rewardType").combobox('setValue',data.type);
            $("#rewardType").combobox('readonly',true);
            $("#imageUpload").imageUpload('setValue',data.imageUrl);

        }

    });



</script>