add_position.html 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. {extend name="base"/}
  2. {block name="resources"}
  3. <style>
  4. .ns-form {margin-top: 0;}
  5. </style>
  6. {/block}
  7. {block name="main"}
  8. <div class="layui-form ns-form">
  9. <div class="layui-form-item">
  10. <label class="layui-form-label"><span class="required">*</span>广告位置名:</label>
  11. <div class="layui-input-block">
  12. <input name="ap_name" type="text" lay-verify="required" class="layui-input ns-len-long">
  13. </div>
  14. </div>
  15. <div class="layui-form-item">
  16. <label class="layui-form-label"><span class="required">*</span>广告关键字:</label>
  17. <div class="layui-input-block">
  18. <input name="keyword" type="text" lay-verify="required" class="layui-input ns-len-long">
  19. </div>
  20. </div>
  21. <div class="layui-form-item">
  22. <label class="layui-form-label">广告位简介:</label>
  23. <div class="layui-input-block ns-len-long">
  24. <textarea name="ap_intro" class="layui-textarea"></textarea>
  25. </div>
  26. </div>
  27. <div class="layui-form-item">
  28. <label class="layui-form-label">广告位宽度:</label>
  29. <div class="layui-input-block">
  30. <input name="ap_width" value="650" type="number" lay-verify="int" class="layui-input ns-len-short">
  31. </div>
  32. <div class="ns-word-aux">单位:px &nbsp;&nbsp; 宽度值不能小于0(例:首页轮播图一般为650px * 280px)</div>
  33. </div>
  34. <div class="layui-form-item">
  35. <label class="layui-form-label">广告位高度:</label>
  36. <div class="layui-input-block">
  37. <input name="ap_height" value="280" type="number" lay-verify="int" class="layui-input ns-len-short">
  38. </div>
  39. <div class="ns-word-aux">单位:px &nbsp;&nbsp; 高度值不能小于0(例:首页轮播图一般为650px * 280px)</div>
  40. </div>
  41. <div class="layui-form-item">
  42. <label class="layui-form-label">广告位类型:</label>
  43. <div class="layui-input-inline" id="type">
  44. <input type="radio" name="type" lay-filter="type" value="1" title="pc端" checked>
  45. <input type="radio" name="type" lay-filter="type" value="2" title="手机端" >
  46. </div>
  47. </div>
  48. <div class="layui-form-item">
  49. <label class="layui-form-label">广告位背景色:</label>
  50. <div class="layui-input-inline">
  51. <div id="bg_color"></div>
  52. </div>
  53. </div>
  54. <div class="ns-form-row">
  55. <button class="layui-btn ns-bg-color" lay-submit lay-filter="save">保存</button>
  56. <button class="layui-btn layui-btn-primary" onclick="back()">返回</button>
  57. </div>
  58. <input type="hidden" name="ap_background_color" id="ap_background_color" value="#FFFFFF" />
  59. </div>
  60. {/block}
  61. {block name="script"}
  62. <script>
  63. layui.use(['form', 'colorpicker'], function () {
  64. var form = layui.form,
  65. colorpicker = layui.colorpicker,
  66. repeat_flag = false; //防重复标识
  67. form.render();
  68. /**
  69. * 颜色
  70. */
  71. colorpicker.render({
  72. elem: '#bg_color', //绑定元素
  73. color: "#FFFFFF",
  74. done: function(color) {
  75. $(".tdrag-name").css("color", color);
  76. $("#ap_background_color").val(color);
  77. }
  78. });
  79. /**
  80. * 监听提交
  81. */
  82. form.on('submit(save)', function(data) {
  83. if (repeat_flag) return;
  84. repeat_flag = true;
  85. $.ajax({
  86. url: ns.url("admin/adv/addPosition"),
  87. data: data.field,
  88. dataType: 'JSON',
  89. type: 'POST',
  90. success: function(res) {
  91. repeat_flag = false;
  92. if (res.code == 0) {
  93. layer.confirm('添加成功', {
  94. title:'操作提示',
  95. btn: ['返回列表', '继续添加'],
  96. yes: function() {
  97. location.href = ns.url("admin/adv/index")
  98. },
  99. btn2: function() {
  100. location.href = ns.url("admin/adv/addPosition")
  101. }
  102. });
  103. } else {
  104. layer.msg(res.message);
  105. }
  106. }
  107. });
  108. });
  109. /**
  110. * 表单验证
  111. */
  112. form.verify({
  113. int: function (value) {
  114. if (value == '') {
  115. return;
  116. }
  117. if (value < 0 || value%1 != 0) {
  118. return '请输入0或正整数!'
  119. }
  120. }
  121. });
  122. });
  123. function back() {
  124. location.href = ns.url("admin/adv/index")
  125. }
  126. </script>
  127. {/block}