edit.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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" enctype="multipart/form-data">
  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" th:name="id" th:value="${review.id}"/>
  24. <input type="hidden" class="input-text" th:name="activity_id" th:value="${review.activity_id}"/>
  25. <input type="text" class="input-text" readonly placeholder="点击查找关联活动" th:id="activity_title"
  26. th:name="activity_title" onclick="findActivity()" th:value="${review.activity_title}"/>
  27. </div>
  28. </div>
  29. <div class="row cl">
  30. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>标题:</label>
  31. <div class="formControls col-xs-8 col-sm-7">
  32. <input type="text" class="input-text" value="" placeholder="请输入标题" th:id="title"
  33. th:name="title" th:value="${review.title}"/>
  34. </div>
  35. </div>
  36. <div class="row cl">
  37. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>是否置顶:</label>
  38. <div class="formControls col-xs-8 col-sm-9">
  39. <label style="margin-right: 10px;"><input name="is_top" type="radio" value="0"> 不置顶</label>
  40. <label><input name="is_top" type="radio" value="1"> 置顶</label>
  41. </div>
  42. </div>
  43. <div class="row cl">
  44. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>图片:</label>
  45. <div class="formControls col-xs-8 col-sm-9">
  46. <div class="uploader-thum-container">
  47. <div id="fileList" class="uploader-list"></div>
  48. <div id="filePicker" class="margin-right-10">重新选择图片</div>
  49. <input type="hidden" th:id="img" th:name="img" />
  50. <input type="hidden" value="" th:id="imgName" th:name="imgName"/>
  51. <div id="fileListPre">
  52. <img id="preImg" height=100 width=200 th:src="${fileUrl} +${review.fileDown.file_url}"/>
  53. <input type="hidden" name="fileDown.file_id" id="files" th:value="${review.fileDown.file_id}">
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. <div class="row cl">
  59. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>是否有视频:</label>
  60. <div class="formControls col-xs-8 col-sm-9">
  61. <label style="margin-right: 10px;"><input name="has_video" th:checked="${review.has_video==false }" type="radio" value="0">否</label>
  62. <label><input name="has_video" th:checked="${review.has_video==true }" type="radio" value="1"> 是</label>
  63. </div>
  64. </div>
  65. <div class="row cl" id="videoArea">
  66. <label class="form-label col-xs-4 col-sm-2">视频:</label>
  67. <div class="formControls col-xs-8 col-sm-9">
  68. <div class="uploader-thum-container">
  69. <div id="videoList" class="uploader-list"></div>
  70. <div id="videoPicker" class="margin-right-10">选择视频</div>
  71. <input type="hidden" th:value="${review.video_url}" th:id="video_url" th:name="video_url"/>
  72. <div id="videoListPre" >
  73. <div th:if="${review.has_video==true}">
  74. <a th:href="@{ '' + ${review.videoDown.file_url}}">[[${review.videoDown.file_name}]]</a>
  75. </div>
  76. <!-- <video id="videoElement" class="centeredVideo" controls autoplay width="450" height="400">Your browser is too old which doesn't support HTML5 video.</video>-->
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. <div class="row cl">
  82. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>内容:</label>
  83. <div class="formControls col-xs-8 col-sm-9">
  84. <textarea id="content" name="content" th:name="content" th:utext="*{review.content}"></textarea>
  85. </div>
  86. <!--[[${review?.content}]]-->
  87. </div>
  88. <input type="hidden" id="isPush">
  89. <div class="row cl">
  90. <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
  91. <a onclick="saveAsDraft()" class="btn btn-primary radius">保存草稿</a>
  92. <a onclick="preview()" class="btn btn-secondary radius">预览</a>
  93. <a onclick="publish()" class="btn btn-primary radius">发布</a>
  94. <a onclick="removeIframe();" class="btn btn-default radius" type="button">返回</a>
  95. </div>
  96. </div>
  97. </form>
  98. </article>
  99. <script type="text/javascript" th:src="@{/h-ui/lib/webuploader/0.1.5/webuploader.min.js}"></script>
  100. <script th:inline="javascript">
  101. // var player = document.getElementById('videoElement');
  102. // var video_url = $('#video_url').val();
  103. // if (flvjs.isSupported() && video_url !=null) {
  104. // var flvPlayer = flvjs.createPlayer({
  105. // type: 'flv',
  106. // url: video_url
  107. // });
  108. // flvPlayer.attachMediaElement(videoElement);
  109. // flvPlayer.load(); //加载
  110. // }
  111. //富文本kindeditor初始化
  112. var editor;
  113. KindEditor.ready(function (K) {
  114. editor = K.create('#content', {
  115. uploadJson: pagePath + '/upload/kindEditorUpload',
  116. allowFileManager: false,
  117. allowUpload: true,
  118. width: "750px",
  119. height: "350px",
  120. items: array,
  121. syncType: "form",
  122. // syncType: "auto",
  123. afterBlur: function () {
  124. this.sync();
  125. }
  126. });
  127. });
  128. // 初始化图片上传
  129. var options = {
  130. auto: false,
  131. uploadBtnId: '#filePicker',
  132. picturePreId: 'fileListPre',
  133. //serverUrl: '/government/slides/uploadImg',
  134. hiddenPictureUrl: 'fileDown.file_id',
  135. hiddenPictureName: 'imgName',
  136. accept: {
  137. title: 'Images',
  138. extensions: 'gif,jpg,jpeg,bmp,png',
  139. mimeTypes: 'image/gif,image/jpg,image/jpeg,image/bmp,image/png'
  140. },
  141. width: 81,
  142. height: 81,
  143. fileSizeLimit: 100 * 1024 * 1024,
  144. fileSingleSizeLimit: 100 * 1024 * 1024
  145. // fileNumLimit: 1
  146. };
  147. var webUploadPicture = new $WebUploadPicture(options);
  148. webUploadPicture.init();
  149. // 初始视频上传
  150. var options2 = {
  151. auto: false,
  152. uploadBtnId: '#videoPicker',
  153. docPreId: 'videoListPre',
  154. //serverUrl: '/government/slides/uploadImg',
  155. hiddenDocUrl: 'videoDown.file_id',
  156. hiddenPictureName: 'videoName',
  157. accept: {
  158. title: 'video',
  159. extensions: 'flv',
  160. mimeTypes: 'flv-application/octet-stream'
  161. },
  162. width: 81,
  163. height: 81,
  164. fileSizeLimit: 300 * 1024 * 1024,
  165. fileSingleSizeLimit: 300 * 1024 * 1024
  166. // fileNumLimit: 1
  167. };
  168. var webUploadPicture2 = new $WebUploadDoc(options2);
  169. webUploadPicture2.init();
  170. $("#is_quota").change(function () {
  171. if ($('#is_quota option:selected').val() == "1") {
  172. $("#quota").show()
  173. } else {
  174. $("#quota").hide()
  175. }
  176. });
  177. $(function () {
  178. var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
  179. var isOpera = userAgent.indexOf("Opera") > -1;
  180. //判断是否IE浏览器
  181. if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera) {
  182. $("#activity_starttime").remove();
  183. $("#activity_endtime").remove();
  184. $("#activity_deadline").remove();
  185. } else {
  186. $("#activity_starttimeIE").remove();
  187. $("#activity_endtimeIE").remove();
  188. $("#activity_deadlineIE").remove();
  189. }
  190. var conent = [[${review.content}]];
  191. $("#content").val(conent);
  192. var is_top = [[${review.is_top}]];
  193. console.log(is_top);
  194. if (is_top){
  195. $("input:radio[name='is_top'][value= '1']").prop("checked", true);
  196. }
  197. else {
  198. $("input:radio[name='is_top'][value= '0']").prop("checked", true);
  199. }
  200. var hasVideo = [[${review.has_video}]];
  201. if (hasVideo) {
  202. $("#videoArea").show()
  203. } else {
  204. setTimeout(function () {
  205. $("#videoArea").hide()
  206. }, 500)
  207. }
  208. $('input[type=radio][name=has_video]').change(function() {
  209. if (this.value == '1') {
  210. $("#videoArea").show()
  211. } else {
  212. $("#videoArea").hide()
  213. }
  214. });
  215. });
  216. function findActivity() {
  217. console.log("123456789");
  218. var url = pagePath+ "/activity/review/activityList";
  219. layer_show("选择关联活动",url,800, 500);
  220. }
  221. function saveAsDraft() {
  222. submit(0);
  223. }
  224. function publish() {
  225. submit(1);
  226. }
  227. function preview() {
  228. var url = pagePath + "/activity/review/proview";
  229. layer_show("预览", url, 800, 500);
  230. }
  231. function submit(status) {
  232. var activity_title = $("#activity_title").val();
  233. console.log(activity_title);
  234. if (activity_title == ''){
  235. errorMessage("活动不能为空");
  236. return;
  237. }
  238. var title = $("#title").val();
  239. console.log(title);
  240. if (title.replace(/\s+/g,"") == ''){
  241. errorMessage("标题不能为空");
  242. return;
  243. }
  244. var content = $("#content").val();
  245. console.log(content);
  246. content = editor.html();
  247. if (content.replace(/\s+/g,"") == ''){
  248. errorMessage("内容不能为空");
  249. return;
  250. }
  251. $("#content").val(content);
  252. $("#form-review-add").ajaxSubmit({
  253. type: 'post',
  254. url: pagePath + "/activity/review/update",
  255. dataType: "json",
  256. data: {
  257. status: status
  258. },
  259. success: function (data) {
  260. if (data.success) {
  261. succeedMessage(data.message);
  262. setTimeClose();
  263. } else {
  264. errorMessage(data.message);
  265. }
  266. },
  267. error: function () {
  268. errorMessage('系统错误!');
  269. }
  270. });
  271. }
  272. /**
  273. * 取消
  274. */
  275. function removeIframe() {
  276. var index = parent.layer.getFrameIndex(window.name);
  277. parent.layer.close(index);
  278. }
  279. </script>
  280. </body>
  281. </html>