edit.html 11 KB

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