mitao
2024-07-08 022a7ff7abf82cd2546e18071ade5228b4e2339f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
@layout("/common/_container.html"){
<div class="row">
    <div class="col-sm-12">
        <div class="ibox float-e-margins">
            <div class="ibox-content">
                <div class="row row-lg">
                    <div class="col-sm-12">
                        <div class="tabs-container">
                            <ul class="nav nav-tabs" id="li_tabs"></ul>
                            <div class="tab-content">
                                <input type="hidden" id="active_key">
                                <div id="tab_content" class="tab-pane">
                                    <div class="panel-body">
                                        <textarea id="editor" type="text/plain" style="width:1200px;height:400px;"></textarea>
                                        <div class="row btn-group-m-t">
                                            <div class="col-sm-10 col-sm-offset-3">
                                                <#button btnCss="info" name="保存" id="ensure" icon="fa-check" clickFun="update_();"/>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@for(info in keys) {
<input type="hidden" value="${info}" class="show_key">
@}
@for(info in contents) {
    <div style="display: none" id="key_${info.key}">${info.content}</div>
@}
 
<link type="text/css" rel="stylesheet" href="${ctxPath}/static/js/plugins/umeditor/themes/default/css/umeditor.css">
<script type="text/javascript" charset="utf-8" src="${ctxPath}/static/js/plugins/umeditor/umeditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="${ctxPath}/static/js/plugins/umeditor/umeditor.js"></script>
<script type="text/javascript" charset="utf-8" src="${ctxPath}/static/js/plugins/umeditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
    var editor_um = null, active = 1,
        editor_key = [],
        editor_name = {
            1:"商务合作",
            2:"关于我们",
            3:"服务协议",
            4:"隐私政策",
            5:"购买须知协议",
            6:"套餐权益说明书",
            7:"套餐实物消费券",
            8:"用户注销协议",
            9:"实物消费券使用说明书",
            10:"有价优惠券须知",
            201:"有价优惠券使用说明",
            202:"公司介绍",
            203:"注册协议",
            204:"个人信息处理规则",
            205:"入司须知协议书"
        }
 
    $(function () {
        editor_um = UM.getEditor('editor');
 
        $( ".show_key").each(function(){ editor_key.push( this.value); })
        var $tab_lis = $( "#li_tabs");
        $.each( editor_key, function (i, key) {
            console.log(i + "______" + key);
            var $li = $( '<li class=""><a data-toggle="tab" href="#tab_content" id="tab_'+ key +'" aria-expanded="'+ (active==key ? "true":"false") +'">'+ editor_name[ key] +'</a></li>');
            $tab_lis.append( $li);
            $li.on( "click", function() {
                $( "#active_key").val( key);
                change_tab( key);
            });
        });
 
        $tab_lis.find( "#tab_" + active).trigger("click");
    });
 
    function change_tab( key) {
        var html = $("#key_" + key).html();
        editor_um.setContent( html);
    }
    function update_(){
        var key =  $( "#active_key").val();
        submitData( key, editor_um.getContent());
    }
 
    function submitData(type, content) {
        //提交信息
        var ajax = new $ax(Feng.ctxPath + "/tAppSet/updateHtml", function(data){
            Feng.success("编辑成功!");
        },function(data){
            Feng.error("编辑失败!" + data.responseJSON.message + "!");
        });
        ajax.set("id", type);
        ajax.set("content", content);
        ajax.start();
    }
</script>
@}