admin
2020-11-10 e130e13ef0cc4a827aa2c8d9e47d619a4cea40d0
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
//跳转参数控制器
var jumpParamsContorls = {
    types: [{
            name: '京东可转链网页(网页跳转方式)',
            template: "{\"url\":\"http://apph5.banliapp.com/help/jd.html?url={内容}\"}"
        },
        {
            name: '百川网页',
            template: "{\"url\":\"http://apph5.banliapp.com/help/tb.html?url={内容}\"}"
        },
        {
            name: '团油',
            template: "{\"url\":\"http://apph5.banliapp.com/help/tuanyou.html\"}"
        },
        {
            name: '通用链接(网页/百川跳转方式)',
            template: "{\"url\":\"{内容}\"}"
        }
    ],
    init: function(navContainer) {
        //加入弹出层
        var html = "";
        html += "    <div id=\"jumpParamsDialog\" style=\"display: none;\">";
        html += "    <form class=\"layui-form\" lay-filter='p-form'>";
        html += "        <div style=\"width: 100%;height: auto;padding:0.1rem;\" >";
 
        html += "<div class='layui-form-item layui-form-text'>";
        html += "  <label class='layui-form-label'>跳转类型</label>";
        html += "  <div class='layui-input-inline'>";
        html += "<select id='jumpParamsType' >";
        for (var i = 0; i < jumpParamsContorls.types.length; i++) {
            html += "<option value=" + i + ">" + jumpParamsContorls.types[i].name + "</option>";
        }
        html += "</select>";
        html += "  </div>";
        html += "</div>";
 
        html += "<div class='layui-form-item layui-form-text'>";
        html += "  <label class='layui-form-label'>内容</label>";
        html += "  <div class='layui-input-block' style='width:200px;min-width:200px;max-width:200px;'>";
        html +=
            "    <textarea placeholder='请输入内容' class='layui-textarea' style='width:50%;max-width:100%' id='jumpParamsContent'></textarea>";
        html += "  </div>";
        html += "</div>";
        html += "<div id=\"control\" style=\"position: absolute;bottom: 10px;right: 10px;\">";
        html += "        <div class=\"layui-btn layui-btn-primary cancel\">取消</div>";
        html += "        <button class=\"layui-btn sure\" lay-submit lay-filter=\"sure\">确定</button>";
        html += "</div>";
        html += "</div>";
        html += "</form>";
        html += "</div>";
        $("body").append(html);
    },
    show: function(callback) {
        var dialog = layer.open({
            type: 1,
            title: '跳转参数选择',
            shadeClose: true,
            shade: 0.8,
            area: ['650px', '300px'],
            content: $("#jumpParamsDialog").html(), //iframe的url
        });
 
        layui.use('form', function() {
            form = layui.form;
        });
        //监听提交
        form.on('submit(sure)', function(data) {
            var index = parseInt($(".layui-layer-content").find("#jumpParamsType").eq(0).val());
            var type = jumpParamsContorls.types[index];
            var content = $(".layui-layer-content").find("#jumpParamsContent").eq(0).val();
            callback(type.template.replace("{内容}", content));
            layer.close(dialog);
            return false;
        });
 
        setTimeout(function() {
            form.render();
        }, 100);
 
        setTimeout(function() {
            $("#control .cancel").bind("click", function() {
                layer.close(dialog);
            });
        }, 100);
    }
};