news.html 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. {template 'common/header'}
  2. {template 'article/common'}
  3. {if $do == 'list'}
  4. <div class="clearfix">
  5. <div class="search-box we7-margin-bottom ">
  6. <select name="" id="" class="we7-margin-right">
  7. <option data-url="{php echo filter_url('cateid:0');}" {if $_GPC['cateid'] == 0}selected{/if}>新闻分类</option>
  8. {loop $categorys $category}
  9. <option data-url="{php echo filter_url('cateid:' . $category['id']);}" {if $_GPC['cateid'] == $category['id']}selected{/if}>{$category['title']}</option>
  10. {/loop}
  11. </select>
  12. <select name="" id="" class="we7-margin-right">
  13. <option data-url="{php echo filter_url('createtime:0');}" {if $_GPC['createtime'] == 0}selected{/if}>时间</option>
  14. <option data-url="{php echo filter_url('createtime:3');}" {if $_GPC['createtime'] == 3}selected{/if}>三天内</option>
  15. <option data-url="{php echo filter_url('createtime:7');}" {if $_GPC['createtime'] == 7}selected{/if}>一周内</option>
  16. <option data-url="{php echo filter_url('createtime:30');}" {if $_GPC['createtime'] == 30}selected{/if}>一月内</option>
  17. <option data-url="{php echo filter_url('createtime:90');}" {if $_GPC['createtime'] == 90}selected{/if}>三月内</option>
  18. </select>
  19. <form action="" method="get" class="search-form " role="form">
  20. <input type="hidden" name="c" value="article">
  21. <input type="hidden" name="a" value="news">
  22. <input type="hidden" name="do" value="list">
  23. <input type="hidden" name="cateid" value="{$_GPC['cateid']}">
  24. <input type="hidden" name="createtime" value="{$_GPC['createtime']}">
  25. <div class=" ">
  26. <div class="input-group">
  27. <input class="form-control" name="title" id="" placeholder="标题" type="text" value="{$_GPC['title']}">
  28. <div class="input-group-btn">
  29. <button class="btn btn-default"><i class="fa fa-search"></i> </button>
  30. </div>
  31. </div>
  32. </div>
  33. </form>
  34. <a href="javascript:;" data-toggle="modal" data-target="#displaysetting" class="btn btn-primary we7-margin-right">排序设置</a>
  35. <a href="{php echo url('article/news/post');}" class="btn btn-primary">添加新闻</a>
  36. </div>
  37. <table class="table we7-table table-hover">
  38. <col width="80px"/>
  39. <col width="90px"/>
  40. <col width="150px"/>
  41. <col width="100px"/>
  42. <col width="90px"/>
  43. <col width="80px"/>
  44. <col width="140px"/>
  45. <col width="120px"/>
  46. <tr>
  47. <th>排序</th>
  48. <th>阅读次数</th>
  49. <th>标题</th>
  50. <th>所属分类</th>
  51. <th>在首页显示</th>
  52. <th>是否显示</th>
  53. <th>添加时间</th>
  54. <th class="text-right">操作</th>
  55. </tr>
  56. {loop $news $new}
  57. <tr>
  58. <td>
  59. <span>{$new['displayorder']}</span>
  60. </td>
  61. <td>
  62. <span>{$new['click']}</span>
  63. </td>
  64. <td>
  65. <span>{$new['title']}</span>
  66. </td>
  67. <td>{$categorys[$new['cateid']]['title']}</td>
  68. <td>
  69. {if $new['is_show_home'] == 1}
  70. <span class="label label-success">是</span>
  71. {else}
  72. <span class="label label-danger">否</span>
  73. {/if}
  74. </td>
  75. <td>
  76. {if $new['is_display'] == 1}
  77. <span class="label label-success">显示中</span>
  78. {else}
  79. <span class="label label-danger">已隐藏</span>
  80. {/if}
  81. </td>
  82. <td class="">{php echo date('Y-m-d H:i', $new['createtime']);}</td>
  83. <td>
  84. <div class="link-group">
  85. <a href="{php echo url('article/news-show/detail', array('id' => $new['id']));}" target="_blank">预览</a>
  86. <a href="{php echo url('article/news/post', array('id' => $new['id']));}">编辑</a>
  87. <a href="javascript:void(0);" class="del" data-id="{php echo $new['id']}" onclick="deleteArticle('{php echo $new["id"]}')">删除</a>
  88. </div>
  89. </td>
  90. </tr>
  91. {/loop}
  92. {if !$news}
  93. <tr>
  94. <td colspan="100">
  95. <div class="we7-empty-block">暂无新闻</div>
  96. </td>
  97. </tr>
  98. {/if}
  99. </table>
  100. <div class="modal fade" id="displaysetting" tabindex="-1" role="dialog" aria-hidden="true">
  101. <div class="we7-modal-dialog modal-dialog we7-form">
  102. <div class="modal-content">
  103. <div class="modal-header">
  104. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
  105. <div class="modal-title">修改新闻排序设置</div>
  106. </div>
  107. <form action="" method="get">
  108. <input type="hidden" name="c" value="article">
  109. <input type="hidden" name="a" value="news">
  110. <input type="hidden" name="do" value="displaysetting">
  111. <div class="modal-body">
  112. <div class="form-group">
  113. <select name="setting" class="we7-select">
  114. <option value="order">按排序数字大小倒序</option>
  115. <option value="createtime">按添加时间倒序</option>
  116. </select>
  117. <span class="help-block"></span>
  118. </div>
  119. </div>
  120. <div class="modal-footer">
  121. <button name="submit" class="btn btn-primary" value="submit">确定</button>
  122. <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
  123. </div>
  124. </form>
  125. </div>
  126. </div>
  127. </div>
  128. <div class="text-right">
  129. {$pager}
  130. </div>
  131. </div>
  132. {elseif $do == 'post'}
  133. <div class="clearfix">
  134. <form action="{php echo url('article/news/post');}" method="post" class="we7-form" role="form" id="form1">
  135. <input type="hidden" name="id" value="{$new['id']}"/>
  136. <div class="form-group">
  137. <label class="col-sm-2 control-label">新闻标题</label>
  138. <div class="col-sm-8">
  139. <input type="text" class="form-control" name="title" value="{$new['title']}" placeholder="新闻标题"/>
  140. <div class="help-block">请填写新闻标题</div>
  141. </div>
  142. </div>
  143. <div class="form-group">
  144. <label class="col-sm-2 control-label">新闻分类</label>
  145. <div class="col-sm-8">
  146. <select name="cateid" id="cateid" class="form-control">
  147. <option value="">==请选择新闻分类==</option>
  148. {loop $categorys $category}
  149. <option value="{$category['id']}" {if $new['cateid'] == $category['id']}selected{/if}>{$category['title']}</option>
  150. {/loop}
  151. </select>
  152. <div class="help-block">还没有分类,点我 <a href="{php echo url('article/news/category_post');}" target="_blank"><i class="fa fa-plus-circle"></i> 添加分类</a></div>
  153. </div>
  154. </div>
  155. <div class="form-group">
  156. <label class="col-sm-2 control-label">缩略图</label>
  157. <div class="col-sm-8">
  158. {php echo tpl_form_field_image('thumb', $new['thumb'], '', array('dest_dir' => 'articles'));}
  159. </div>
  160. </div>
  161. <div class="form-group">
  162. <label class="col-sm-2 control-label"></label>
  163. <div class="col-sm-8">
  164. <div class="help-block"><input type="checkbox" id="autolitpic" name="autolitpic" value="1"{if empty($item['thumb'])} checked="true"{/if}><><label for="autolitpic">提取内容的第一个图片为缩略图</label></div>
  165. </div>
  166. </div>
  167. <div class="form-group">
  168. <label class="col-sm-2 control-label">内容</label>
  169. <div class="col-sm-8">
  170. {php echo tpl_ueditor('content', $new['content']);}
  171. </div>
  172. </div>
  173. <div class="form-group">
  174. <label class="col-sm-2 control-label">新闻来源</label>
  175. <div class="col-sm-8">
  176. <input type="text" class="form-control" name="source" value="{$new['source']}" placeholder="新闻来源"/>
  177. </div>
  178. </div>
  179. <div class="form-group">
  180. <label class="col-sm-2 control-label">新闻作者</label>
  181. <div class="col-sm-8">
  182. <input type="text" class="form-control" name="author" value="{$new['author']}" placeholder="新闻作者"/>
  183. </div>
  184. </div>
  185. <div class="form-group">
  186. <label class="col-sm-2 control-label">阅读次数</label>
  187. <div class="col-sm-8">
  188. <input type="text" class="form-control" name="click" value="{$new['click']}" placeholder="阅读次数"/>
  189. <div class="help-block">默认为0。您可以设置一个初始值,阅读次数会在该初始值上增加。</div>
  190. </div>
  191. </div>
  192. <div class="form-group">
  193. <label class="col-sm-2 control-label">排序</label>
  194. <div class="col-sm-8">
  195. <input type="text" class="form-control" name="displayorder" value="{$new['displayorder']}" placeholder="阅读次数"/>
  196. <div class="help-block">数字越大,越靠前。</div>
  197. </div>
  198. </div>
  199. <div class="form-group">
  200. <label class="col-sm-2 control-label">是否显示</label>
  201. <div class="col-sm-8">
  202. <input id="is_display-1" type="radio" name="is_display" value="1" {if $new['is_display'] == 1} checked{/if}> <label for="is_display-1">显示</label>
  203. <input id="is_display-2" type="radio" name="is_display" value="0" {if $new['is_display'] == 0} checked{/if}> <label for="is_display-2">不显示</label>
  204. </div>
  205. </div>
  206. <div class="form-group">
  207. <label class="col-sm-2 control-label">显示在首页</label>
  208. <div class="col-sm-8">
  209. <input type="radio" id="is_show_home-1" name="is_show_home" value="1" {if $new['is_show_home'] == 1} checked{/if}><label class="radio-inline" for="is_show_home-1"> 是</label>
  210. <input type="radio" id="is_show_home-2" name="is_show_home" value="0" {if $new['is_show_home'] == 0} checked{/if}><label class="radio-inline" for="is_show_home-1"> 否</label>
  211. </div>
  212. </div>
  213. <div class="form-group">
  214. <div class="">
  215. <input type="submit" class="btn btn-primary" name="submit" value="提交" />
  216. <input type="hidden" name="token" value="{$_W['token']}" />
  217. </div>
  218. </div>
  219. </form>
  220. </div>
  221. {/if}
  222. <script>
  223. function deleteArticle(id) {
  224. var url = "{php echo url('article/news/del', array('id' => $new['id']));}";
  225. url += "&id=" + id;
  226. util.confirm(function () {
  227. window.location.href = url;
  228. }, function () {
  229. }, '确认删除吗?');
  230. }
  231. $(function(){
  232. $('#form1').submit(function(){
  233. if(!$.trim($(':text[name="title"]').val())) {
  234. util.message('请填写新闻标题', '', 'error');
  235. return false;
  236. }
  237. if(!$.trim($('#cateid').val())) {
  238. util.message('请选择新闻分类', '', 'error');
  239. return false;
  240. }
  241. if(!$.trim($('textarea[name="content"]').val())) {
  242. util.message('请填写新闻内容', '', 'error');
  243. return false;
  244. }
  245. return true;
  246. });
  247. });
  248. </script>
  249. {template 'common/footer'}