add.html 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. {include file="common/header"/}
  2. <div class="LM-container">
  3. <div class="LM-main">
  4. <div class="admin-main layui-anim layui-anim-upbit">
  5. <fieldset class="layui-elem-field layui-field-title">
  6. <legend>{$title}</legend>
  7. </fieldset>
  8. <form class="layui-form layui-form-pane" lay-filter="form">
  9. <div class="layui-form-item">
  10. <label class="layui-form-label">所属位置</label>
  11. <div class="layui-input-inline">
  12. <select name="pid" lay-verify="required">
  13. <option value="0">默认顶级</option>
  14. {volist name="ArticleCate" id="vo"}
  15. <option value="{$vo.id}" {if !empty($info) && $info.pid==$vo.id} selected {/if} >{$vo.ltitle}</option>
  16. {/volist}
  17. </select>
  18. </div>
  19. </div>
  20. <div class="layui-form-item">
  21. <label class="layui-form-label">文章名</label>
  22. <div class="layui-input-inline">
  23. <input type="text" name="title" lay-verify="required" placeholder="{:lang('pleaseEnter')}标题" class="layui-input">
  24. </div>
  25. </div>
  26. <div class="layui-form-item">
  27. <label class="layui-form-label">描述</label>
  28. <div class="layui-input-inline">
  29. <input type="text" name="description" placeholder="{:lang('pleaseEnter')}描述" class="layui-input">
  30. </div>
  31. </div>
  32. <div class="layui-form-item">
  33. <label class="layui-form-label">关键词</label>
  34. <div class="layui-input-inline">
  35. <input type="text" name="keywords" placeholder="{:lang('pleaseEnter')}关键词" class="layui-input">
  36. </div>
  37. <div class="layui-form-mid layui-word-aux">
  38. (多个关键词用空格隔开)
  39. </div>
  40. </div>
  41. <!-- <div class="layui-form-item">-->
  42. <!-- <label class="layui-form-label">链接</label>-->
  43. <!-- <div class="layui-input-inline">-->
  44. <!-- <input type="text" name="link" lay-verify="url" placeholder="{:lang('pleaseEnter')}链接" class="layui-input">-->
  45. <!-- </div>-->
  46. <!-- <div class="layui-form-mid layui-word-aux">-->
  47. <!-- 必须是https 或者http-->
  48. <!-- </div>-->
  49. <!-- </div>-->
  50. <div class="layui-form-item">
  51. <label class="layui-form-label">缩略图</label>
  52. <input type="hidden" name="thumb" id="avatar">
  53. <div class="layui-input-inline">
  54. <div class="layui-upload">
  55. <button type="button" class="layui-btn layui-btn-primary" id="addBtn"><i class="icon icon-upload3"></i>点击上传</button>
  56. <div class="layui-upload-list">
  57. <img class="layui-upload-img" id="addPic">
  58. <p id="notice"></p>
  59. </div>
  60. </div>
  61. </div>
  62. </div>
  63. <div class="layui-form-item">
  64. <label class="layui-form-label">点击量</label>
  65. <div class="layui-input-inline">
  66. <input type="text" name="click" value="0" lay-verify="number" placeholder="{:lang('pleaseEnter')}点击量" class="layui-input">
  67. </div>
  68. </div>
  69. <!-- <div class="layui-form-item">-->
  70. <!-- <label class="layui-form-label">{:lang('email')}</label>-->
  71. <!-- <div class="layui-input-inline">-->
  72. <!-- <input type="text" name="author_email" lay-verify="email" placeholder="{:lang('pleaseEnter')}邮箱" class="layui-input">-->
  73. <!-- </div>-->
  74. <!-- </div>-->
  75. <div class="layui-form-item">
  76. <label class="layui-form-label">{:lang('status')}</label>
  77. <div class="layui-input-inline">
  78. <input type="radio" name="status" value="1" title="启用">
  79. <input type="radio" name="status" value="0" title="禁用">
  80. </div>
  81. </div>
  82. <div class="layui-form-item">
  83. <label class="layui-form-label">内容</label>
  84. </div>
  85. <script id="container" name="content" type="text/plain"></script>
  86. <div class="layui-form-item">
  87. <div class="layui-input-inline">
  88. <input type="hidden" name="id" >
  89. <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('submit')}</button>
  90. <a href="{:url('index')}" class="layui-btn layui-btn-primary">{:lang('back')}</a>
  91. </div>
  92. </div>
  93. </form>
  94. </div>
  95. </div>
  96. </div>
  97. {include file="common/footer"/}
  98. {$ueditor|raw};
  99. <script>
  100. layui.use(['form', 'layer','upload'], function () {
  101. var form = layui.form, layer = layui.layer,$= layui.jquery,upload = layui.upload;
  102. var info = '';
  103. info = {:json_encode($info)};
  104. form.val("form", info);
  105. if(info){
  106. $('#addPic').attr('src',info.thumb);
  107. }
  108. form.render();
  109. form.on('submit(submit)', function (data) {
  110. loading =layer.load(1, {shade: [0.1,'#fff']});
  111. $.post("", data.field, function (res) {
  112. layer.close(loading);
  113. if (res.code > 0) {
  114. layer.msg(res.msg, {time: 1800, icon: 1}, function () {
  115. location.href = res.url;
  116. });
  117. } else {
  118. layer.msg(res.msg, {time: 1800, icon: 2});
  119. }
  120. });
  121. });
  122. //普通图片上传
  123. var uploadInt = upload.render({
  124. elem: '#addBtn'
  125. ,url: '{:url("uploads/uploads")}'
  126. ,before: function(obj){
  127. //预读本地文件示例,不支持ie8
  128. obj.preview(function(index, file, result){
  129. $('#addPic').attr('src', result); //图片链接(base64)
  130. });
  131. },
  132. done: function(res){
  133. if(res.code>0){
  134. $('#avatar').val(res.url);
  135. }else{
  136. //如果上传失败
  137. return layer.msg('上传失败');
  138. }
  139. }
  140. ,error: function(){
  141. //演示失败状态,并实现重传
  142. var notice = $('#notice');
  143. notice.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
  144. notice.find('.demo-reload').on('click', function(){
  145. uploadInt.upload();
  146. });
  147. }
  148. });
  149. });
  150. </script>