123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- {extend name="base"/}
- {block name="resources"}
- <style>
- .ns-form {margin-top: 0;}
- </style>
- {/block}
- {block name="main"}
- <div class="layui-form ns-form">
- <div class="layui-form-item">
- <label class="layui-form-label"><span class="required">*</span>广告位置名:</label>
- <div class="layui-input-block">
- <input name="ap_name" type="text" lay-verify="required" class="layui-input ns-len-long">
- </div>
- </div>
-
- <div class="layui-form-item">
- <label class="layui-form-label"><span class="required">*</span>广告关键字:</label>
- <div class="layui-input-block">
- <input name="keyword" type="text" lay-verify="required" class="layui-input ns-len-long">
- </div>
- </div>
-
- <div class="layui-form-item">
- <label class="layui-form-label">广告位简介:</label>
- <div class="layui-input-block ns-len-long">
- <textarea name="ap_intro" class="layui-textarea"></textarea>
- </div>
- </div>
-
- <div class="layui-form-item">
- <label class="layui-form-label">广告位宽度:</label>
- <div class="layui-input-block">
- <input name="ap_width" value="650" type="number" lay-verify="int" class="layui-input ns-len-short">
- </div>
- <div class="ns-word-aux">单位:px 宽度值不能小于0(例:首页轮播图一般为650px * 280px)</div>
- </div>
-
- <div class="layui-form-item">
- <label class="layui-form-label">广告位高度:</label>
- <div class="layui-input-block">
- <input name="ap_height" value="280" type="number" lay-verify="int" class="layui-input ns-len-short">
- </div>
- <div class="ns-word-aux">单位:px 高度值不能小于0(例:首页轮播图一般为650px * 280px)</div>
- </div>
-
- <div class="layui-form-item">
- <label class="layui-form-label">广告位类型:</label>
- <div class="layui-input-inline" id="type">
- <input type="radio" name="type" lay-filter="type" value="1" title="pc端" checked>
- <input type="radio" name="type" lay-filter="type" value="2" title="手机端" >
- </div>
- </div>
-
- <div class="layui-form-item">
- <label class="layui-form-label">广告位背景色:</label>
- <div class="layui-input-inline">
- <div id="bg_color"></div>
- </div>
- </div>
-
- <div class="ns-form-row">
- <button class="layui-btn ns-bg-color" lay-submit lay-filter="save">保存</button>
- <button class="layui-btn layui-btn-primary" onclick="back()">返回</button>
- </div>
-
- <input type="hidden" name="ap_background_color" id="ap_background_color" value="#FFFFFF" />
- </div>
- {/block}
- {block name="script"}
- <script>
- layui.use(['form', 'colorpicker'], function () {
- var form = layui.form,
- colorpicker = layui.colorpicker,
- repeat_flag = false; //防重复标识
- form.render();
- /**
- * 颜色
- */
- colorpicker.render({
- elem: '#bg_color', //绑定元素
- color: "#FFFFFF",
- done: function(color) {
- $(".tdrag-name").css("color", color);
- $("#ap_background_color").val(color);
- }
- });
-
- /**
- * 监听提交
- */
- form.on('submit(save)', function(data) {
- if (repeat_flag) return;
- repeat_flag = true;
-
- $.ajax({
- url: ns.url("admin/adv/addPosition"),
- data: data.field,
- dataType: 'JSON',
- type: 'POST',
- success: function(res) {
- repeat_flag = false;
-
- if (res.code == 0) {
- layer.confirm('添加成功', {
- title:'操作提示',
- btn: ['返回列表', '继续添加'],
- yes: function() {
- location.href = ns.url("admin/adv/index")
- },
- btn2: function() {
- location.href = ns.url("admin/adv/addPosition")
- }
- });
- } else {
- layer.msg(res.message);
- }
- }
- });
- });
-
- /**
- * 表单验证
- */
- form.verify({
- int: function (value) {
- if (value == '') {
- return;
- }
- if (value < 0 || value%1 != 0) {
- return '请输入0或正整数!'
- }
- }
- });
- });
-
- function back() {
- location.href = ns.url("admin/adv/index")
- }
- </script>
- {/block}
|