add.html 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <!DOCTYPE HTML>
  2. <html xmlns:th="http://www.thymeleaf.org"
  3. xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
  4. layout:decorate="~{admin/common/common}">
  5. <head>
  6. <title>活动管理新增</title>
  7. <style>
  8. .push-names span {
  9. display: inline-block;
  10. background: #f5f5f5;
  11. padding: 5px 10px;
  12. border-radius: 3px;
  13. margin: 0 5px 5px 0;
  14. }
  15. </style>
  16. </head>
  17. <body layout:fragment="content">
  18. <article class="page-container">
  19. <form class="form form-horizontal" id="form-review-add">
  20. <div class="row cl">
  21. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>关联活动:</label>
  22. <div class="formControls col-xs-8 col-sm-7">
  23. <input type="hidden" class="input-text" value="" required th:id="activity_id" th:name="activity_id"/>
  24. <input type="text" class="input-text" value="" readonly placeholder="点击查找关联活动" th:id="activity_title"
  25. th:name="activity_title" onclick="findActivity()"/>
  26. </div>
  27. </div>
  28. <div class="row cl">
  29. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>标题:</label>
  30. <div class="formControls col-xs-8 col-sm-7">
  31. <input type="text" class="input-text" value="" placeholder="请输入标题" th:id="title"
  32. th:name="title"/>
  33. </div>
  34. </div>
  35. <div class="row cl">
  36. <label class="form-label col-xs-4 col-sm-2"><!--<span class="c-red">*</span>-->是否置顶:</label>
  37. <div class="formControls col-xs-8 col-sm-9">
  38. <label style="margin-right: 10px;"><input name="is_top" checked type="radio" value="0"> 不置顶</label>
  39. <label><input name="is_top" type="radio" value="1"> 置顶</label>
  40. </div>
  41. </div>
  42. <div class="row cl">
  43. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>图片:</label>
  44. <div class="formControls col-xs-8 col-sm-9">
  45. <div class="uploader-thum-container">
  46. <div id="fileList" class="uploader-list"></div>
  47. <div id="filePicker" class="margin-right-10">选择图片</div>
  48. <input type="hidden" value="11" th:id="img" th:name="img"/>
  49. <div id="fileListPre"></div>
  50. </div>
  51. </div>
  52. </div>
  53. <div class="row cl">
  54. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>是否有视频:</label>
  55. <div class="formControls col-xs-8 col-sm-9">
  56. <label style="margin-right: 10px;"><input name="has_video" checked type="radio" value="0">否</label>
  57. <label><input name="has_video" type="radio" value="1"> 是</label>
  58. </div>
  59. </div>
  60. <div class="row cl" id="videoArea">
  61. <label class="form-label col-xs-4 col-sm-2">视频:</label>
  62. <div class="formControls col-xs-8 col-sm-9">
  63. <div class="uploader-thum-container">
  64. <div id="videoList" class="uploader-list"></div>
  65. <div id="videoPicker" class="margin-right-10">选择视频</div>
  66. <input type="hidden" value="11" th:id="video_url" th:name="video_url"/>
  67. <div id="videoListPre"></div>
  68. </div>
  69. </div>
  70. </div>
  71. <div class="row cl">
  72. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>内容:</label>
  73. <div class="formControls col-xs-8 col-sm-9">
  74. <textarea id="content" name="content"></textarea>
  75. </div>
  76. </div>
  77. <input type="hidden" id="isPush">
  78. <div class="row cl">
  79. <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
  80. <a onclick="saveAsDraft()" class="btn btn-primary radius">保存草稿</a>
  81. <a onclick="preview()" class="btn btn-secondary radius">预览</a>
  82. <a onclick="publish()" class="btn btn-primary radius">发布</a>
  83. <a onclick="removeIframe();" class="btn btn-default radius" type="button">返回</a>
  84. </div>
  85. </div>
  86. </form>
  87. </article>
  88. <script type="text/javascript" th:src="@{/h-ui/lib/webuploader/0.1.5/webuploader.min.js}"></script>
  89. <script th:inline="javascript">
  90. //富文本kindeditor初始化
  91. var editor;
  92. KindEditor.ready(function (K) {
  93. editor = K.create('#content', {
  94. uploadJson: pagePath + '/upload/kindEditorUpload',
  95. allowFileManager: false,
  96. allowUpload: true,
  97. width: "750px",
  98. height: "350px",
  99. items: array,
  100. syncType: "auto",
  101. afterBlur: function () {
  102. this.sync();
  103. }
  104. });
  105. });
  106. // 初始化图片上传
  107. var options = {
  108. auto: false,
  109. uploadBtnId: '#filePicker',
  110. picturePreId: 'fileListPre',
  111. //serverUrl: '/government/slides/uploadImg',
  112. hiddenPictureUrl: 'fileDown.file_id',
  113. hiddenPictureName: 'imgName',
  114. accept: {
  115. title: 'Images',
  116. extensions: 'gif,jpg,jpeg,bmp,png',
  117. mimeTypes: 'image/gif,image/jpg,image/jpeg,image/bmp,image/png'
  118. },
  119. width: 81,
  120. height: 81,
  121. fileSizeLimit: 100 * 1024 * 1024,
  122. fileSingleSizeLimit: 100 * 1024 * 1024
  123. // fileNumLimit: 1
  124. };
  125. var webUploadPicture = new $WebUploadPicture(options);
  126. webUploadPicture.init();
  127. // 初始视频上传
  128. // 初始视频上传
  129. var options2 = {
  130. auto: false,
  131. uploadBtnId: '#videoPicker',
  132. docPreId: 'videoListPre',
  133. //serverUrl: '/government/slides/uploadImg',
  134. hiddenDocUrl: 'videoDown.file_id',
  135. hiddenPictureName: 'videoName',
  136. accept: {
  137. title: 'video',
  138. extensions: 'flv',
  139. mimeTypes: 'flv-application/octet-stream'
  140. },
  141. width: 81,
  142. height: 81,
  143. fileSizeLimit: 300 * 1024 * 1024,
  144. fileSingleSizeLimit: 300 * 1024 * 1024
  145. // fileNumLimit: 1
  146. };
  147. var webUploadPicture2 = new $WebUploadDoc(options2);
  148. webUploadPicture2.init();
  149. $("#is_quota").change(function () {
  150. if ($('#is_quota option:selected').val() == "1") {
  151. $("#quota").show()
  152. } else {
  153. $("#quota").hide()
  154. }
  155. });
  156. $(function () {
  157. var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
  158. var isOpera = userAgent.indexOf("Opera") > -1;
  159. //判断是否IE浏览器
  160. if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera) {
  161. $("#activity_starttime").remove();
  162. $("#activity_endtime").remove();
  163. $("#activity_deadline").remove();
  164. } else {
  165. $("#activity_starttimeIE").remove();
  166. $("#activity_endtimeIE").remove();
  167. $("#activity_deadlineIE").remove();
  168. }
  169. // 视频区域设置
  170. $('input[type=radio][name=has_video]').change(function() {
  171. if (this.value == '1') {
  172. $("#videoArea").show()
  173. } else {
  174. $("#videoArea").hide()
  175. }
  176. });
  177. setTimeout(function () {
  178. $("#videoArea").hide()
  179. }, 300)
  180. });
  181. function findActivity() {
  182. console.log("123456789");
  183. var url = pagePath+ "/activity/review/activityList";
  184. layer_show("选择关联活动",url,800, 500);
  185. }
  186. function saveAsDraft() {
  187. submit(0);
  188. }
  189. function publish() {
  190. submit(1);
  191. }
  192. function preview() {
  193. var url = pagePath + "/activity/review/proview";
  194. layer_show("预览", url, 800, 500);
  195. }
  196. function submit(status) {
  197. var activity_title = $("#activity_title").val();
  198. console.log(activity_title);
  199. if (activity_title == ''){
  200. errorMessage("活动不能为空");
  201. return;
  202. }
  203. var title = $("#title").val();
  204. console.log(title);
  205. if (title.replace(/\s+/g,"") == ''){
  206. errorMessage("标题不能为空");
  207. return;
  208. }
  209. var content = $("#content").val();
  210. console.log(content);
  211. if (content.replace(/\s+/g,"") == ''){
  212. errorMessage("内容不能为空");
  213. return;
  214. }
  215. $("#form-review-add").ajaxSubmit({
  216. type: 'post',
  217. url: pagePath + "/activity/review/save",
  218. dataType: "json",
  219. data: {
  220. status: status
  221. },
  222. success: function (data) {
  223. if (data.success) {
  224. succeedMessage(data.message);
  225. setTimeClose();
  226. } else {
  227. errorMessage(data.message);
  228. }
  229. },
  230. error: function () {
  231. errorMessage('系统错误!');
  232. }
  233. });
  234. }
  235. /**
  236. * 取消
  237. */
  238. function removeIframe() {
  239. var index = parent.layer.getFrameIndex(window.name);
  240. parent.layer.close(index);
  241. }
  242. </script>
  243. </body>
  244. </html>