<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <title>insert</title>
    <link rel="stylesheet" href="/component/pear/css/pear.css" />
    <link rel="stylesheet" href="/admin/css/reset.css" />
</head>
<body>

<form class="layui-form" action="">
    <div class="main-container mr-5">
        <div class="layui-form-item">
            <label class="layui-form-label">关键词</label>
            <div class="layui-input-inline layui-input-wrap">
                <input type="text" name="keyword" lay-verify="required" autocomplete="off" lay-affix="clear" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">监控平台</label>
            <div class="layui-input-block">
                <input type="checkbox" name="platform[]" value="1" title="百度PC">
                <input type="checkbox" name="platform[]" value="2" title="百度WAP">
                <input type="checkbox" name="platform[]" value="3" title="头条PC">
                <input type="checkbox" name="platform[]" value="4" title="头条WAP">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="button-container">
                <button type="submit" class="pear-btn pear-btn-primary pear-btn-md" lay-submit="" lay-filter="insert">
                    提交
                </button>
            </div>
        </div>
    </div>
</form>
<script src="/component/layui/layui.js?v=2.8.12"></script>
<script src="/component/pear/pear.js"></script>
<script>
    // api
    const INSERT_API = "/admin/api/keywords/monitor/insert"; // 插入新闻

    layui.use(['upload', 'jquery', 'popup'], function(){
        const $ = layui.jquery;

        layui.form.on("submit(insert)", function (data) {
            console.log(data)
            layui.$.ajax({
                url: INSERT_API,
                type: "POST",
                dateType: "json",
                data: data.field,
                success: function (res) {
                    if (res.code) {
                        return layui.popup.failure(res.msg);
                    }

                    return layui.popup.success("操作成功", function () {
                        parent.refreshTable();
                        parent.layer.close(parent.layer.getFrameIndex(window.name));
                    });
                }
            });
            return false;
        });
    });
</script>
</body>
</html>
