addActivityAdsVideo.jsp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. <%@ page import="com.caimei.modules.baike.entity.CmBaikeProductFile" %><%--
  2. Created by IntelliJ IDEA.
  3. User: Administrator
  4. Date: 2020/4/9
  5. Time: 19:54
  6. To change this template use File | Settings | File Templates.
  7. --%>
  8. <%@ page contentType="text/html;charset=UTF-8" %>
  9. <%@ include file="/WEB-INF/views/include/taglib.jsp" %>
  10. <html>
  11. <head>
  12. <title>选择其他图片</title>
  13. <meta name="decorator" content="default"/>
  14. <style type="text/css">
  15. .table td i {
  16. margin: 0 2px;
  17. }
  18. .iconBox {
  19. font-size: 0;
  20. }
  21. .controls .conList {
  22. display: inline-block;
  23. margin-right: 15px;
  24. }
  25. .conList .btn:nth-of-type(1) {
  26. margin-left: 25px;
  27. }
  28. .upload-content {
  29. margin-top: -70px;
  30. }
  31. .upload-content .conList .btn:nth-of-type(1) {
  32. width: 90px;
  33. height: 100px;
  34. border: 2px solid #eee;
  35. background: #fff;
  36. position: relative;
  37. }
  38. .upload-content .conList .btn:nth-of-type(1) > div {
  39. position: absolute;
  40. top: 50%;
  41. left: 50%;
  42. transform: translate(-50%, -50%);
  43. color: #666;
  44. }
  45. .upload-content .conList .btn:nth-of-type(1) span {
  46. font-size: 35px;
  47. }
  48. .upload-content .conList .btn:nth-of-type(1) h5 {
  49. color: #666;
  50. }
  51. .cancel-upload {
  52. background: transparent;
  53. border: none;
  54. box-shadow: none;
  55. position: relative;
  56. top: -38px;
  57. left: -25px;
  58. cursor: pointer;
  59. z-index: 100;
  60. }
  61. .upload-content .conList ol li {
  62. width: 114px;
  63. min-height: 80px;
  64. text-align: center;
  65. background: #fff;
  66. position: relative;
  67. top: 120px;
  68. margin-left: 2px;
  69. }
  70. .hide-pic {
  71. display: none !important;
  72. }
  73. </style>
  74. <script type="text/javascript">
  75. $(document).ready(function () {
  76. $("#inputForm").validate({
  77. submitHandler: function (form) {
  78. var beginTime = $("#beginTime").val();
  79. var endTime = $("#endTime").val();
  80. if (beginTime > endTime) {
  81. alertx("开始时间不能晚于结束时间!");
  82. return;
  83. } else {
  84. loading('正在提交,请稍等...');
  85. form.submit();
  86. }
  87. },
  88. errorContainer: "#messageBox",
  89. errorPlacement: function (error, element) {
  90. $("#messageBox").text("输入有误,请先更正。");
  91. if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
  92. error.appendTo(element.parent().parent());
  93. } else {
  94. error.insertAfter(element);
  95. }
  96. }
  97. });
  98. });
  99. </script>
  100. </head>
  101. <body>
  102. <br/>
  103. <form:form id="inputForm" modelAttribute="floorImage" action="" method="post" class="form-horizontal">
  104. <form:hidden path="id" id="id"/>
  105. <sys:message content="${message}"/>
  106. <div class="control-group iconBox">
  107. <label class="control-label"><span class="help-inline"><font color="red">*</font> </span>视频封面</label>
  108. <div class="controls upload-content" id="imageBox">
  109. <div class="conList">
  110. <form:hidden id="image" path="image" htmlEscape="false" maxlength="255" class="input-xlarge required"/>
  111. <sys:ckfinder input="image" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100"
  112. maxHeight="100"/>
  113. <br>
  114. <label>${pcImageSize}</label>
  115. </div>
  116. </div>
  117. </div>
  118. <%-- <div class="control-group iconBox">--%>
  119. <%-- <label class="control-label"><span class="help-inline"><font color="red">*</font> </span>小程序图片:</label>--%>
  120. <%-- <div class="controls upload-content" id="appletsImageBox">--%>
  121. <%-- <div class="conList">--%>
  122. <%-- <form:hidden id="appletsImage" path="appletsImage" htmlEscape="false" maxlength="255" class="input-xlarge required"/>--%>
  123. <%-- <sys:ckfinder input="appletsImage" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100"--%>
  124. <%-- maxHeight="100"/>--%>
  125. <%-- <br>--%>
  126. <%-- <label>${appletsImageSize}</label>--%>
  127. <%-- </div>--%>
  128. <%-- </div>--%>
  129. <%-- </div>--%>
  130. <div class="control-group" style="display: ${type eq 'adsImage'?'none':''}">
  131. <label class="control-label"><font color="red">*</font>标题:</label>
  132. <div class="controls">
  133. <form:input path="name" id="name" htmlEscape="false" class="input-xlarge required"/>
  134. </div>
  135. </div>
  136. <div class="control-group" style="display: ${type eq 'adsImage'?'none':''}">
  137. <label class="control-label"><font color="red">*</font>内容:</label>
  138. <div class="controls">
  139. <form:textarea path="content" id="content" htmlEscape="false" class="input-xlarge required"/>
  140. </div>
  141. </div>
  142. <div class="control-group">
  143. <div class="control-group">
  144. <label class="control-label" style="margin-top:10px">视频路径:</label>
  145. <div class="controls" style="margin-top:10px">
  146. <%-- <input id="uploadFileName" type="text" style="display: inline;" placeholder="支持mp4" disabled="true" class="input-xlarge required" />--%>
  147. <div class="upload">
  148. <input type="file" name="file" id="productFile" accept=".mp4" >
  149. </div>
  150. <div class="add-submit">
  151. <input id="addSubmit" type="button" value="上传"/>
  152. </div>
  153. <div class="upload-loading">
  154. <img alt="gif" src="/static/images/upload.gif" width="32px" border="none">
  155. </div>
  156. </div>
  157. </div>
  158. <div class="control-group">
  159. <div id='file-list-display' style="margin-left:180px">
  160. <%-- <c:if test="${not empty cmBaikeProduct.videoList}">--%>
  161. <%-- <c:forEach items="${cmBaikeProduct.videoList}" var="videoFile" varStatus="statusIndex">--%>
  162. <%-- <p>${videoFile.fileTitle}--%>
  163. <span class="del"><a id="bf">预览</a></span> <%-- ${floorImage.id} </c:if>--%>
  164. <span class="del" onclick="dataDelete(this,'${id}')">删除</span>
  165. <%-- </p>--%>
  166. <%-- </c:forEach>--%>
  167. <%-- </c:if>--%>
  168. </div>
  169. </div>
  170. </div>
  171. <%-- <div class="control-group">--%>
  172. <%-- <label class="control-label">跳转链接:</label>--%>
  173. <%-- <div class="controls">--%>
  174. <%-- <form:input path="link" id="link" htmlEscape="false" cssStyle="position: relative" class="input-xlarge required"/>--%>
  175. <%-- </div>--%>
  176. <%-- </div>--%>
  177. <%-- <div class="control-group iconBox">--%>
  178. <%-- <label class="control-label">小程序内容宣传图:</label>--%>
  179. <%-- <div class="controls upload-content" id="adsImageBox">--%>
  180. <%-- <div class="conList">--%>
  181. <%-- <form:hidden id="adsImage" path="adsImage" htmlEscape="false" maxlength="255" class="input-xlarge required"/>--%>
  182. <%-- <sys:ckfinder input="adsImage" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100"--%>
  183. <%-- maxHeight="100"/>--%>
  184. <%-- <br>--%>
  185. <%-- <label>建议图片尺寸宽度750px</label>--%>
  186. <%-- </div>--%>
  187. <%-- </div>--%>
  188. <%-- </div>--%>
  189. <div class="control-group">
  190. <label class="control-label"><font color="red">*</font> 排序:</label>
  191. <div class="controls">
  192. <form:input path="sort" id="sort" htmlEscape="false" maxlength="11" onkeyup="onlynum(this)" class="input-xlarge required"/>
  193. </div>
  194. </div>
  195. <div class="control-group">
  196. <label class="control-label">网站状态:</label>
  197. <div class="controls">
  198. <form:select path="pcStatus" id="pcStatus" class="input-medium required">
  199. <form:option value="1" label="启动"/>
  200. <form:option value="0" label="停用"/>
  201. </form:select>
  202. </div>
  203. </div>
  204. <div class="control-group">
  205. <label class="control-label">小程序状态:</label>
  206. <div class="controls">
  207. <form:select path="appletsStatus" id="appletsStatus" class="input-medium required">
  208. <form:option value="1" label="启动"/>
  209. <form:option value="0" label="停用"/>
  210. </form:select>
  211. </div>
  212. </div>
  213. </form:form>
  214. <script type="text/javascript">
  215. $(document).ready(function () {
  216. //弹出框去滚动条
  217. top.$('#jbox-content').css("overflow-y", "hidden");
  218. show_title(30);
  219. });
  220. $(function () {
  221. $('.upload-content .conList .btn:nth-of-type(1)').html('<div><span>+</span><h5>选择图片</h5></div>');
  222. $('.upload-content .conList .btn:nth-of-type(2)').after('<img class="cancel-upload" src="/static/images/close-btn1.png">').remove();
  223. $('.upload-content .conList').find('.cancel-upload').hide();
  224. var observeEle = document.getElementsByClassName('upload-content')[0];
  225. var observeEle1 = document.getElementsByClassName('upload-content')[1];
  226. var observeEle2 = document.getElementsByClassName('upload-content')[2];
  227. var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
  228. var MutationObserverConfig = {
  229. childList: true,
  230. subtree: true,
  231. characterData: true
  232. };
  233. var observer = new MutationObserver(function (mutations) {
  234. $.each(mutations, function (index, item) {
  235. if (item.type === 'childList') {
  236. // 在创建新的 element 时调用
  237. var target = $(item.target),
  238. thisWrapper = target.closest('.conList'),
  239. nextEle = thisWrapper.next();
  240. thisWrapper.find('li').css('z-index', 99);
  241. thisWrapper.find('.cancel-upload').show();
  242. if (nextEle.hasClass('hide-pic')) {
  243. nextEle.removeClass('hide-pic');
  244. }
  245. }
  246. })
  247. });
  248. observer.observe(observeEle, MutationObserverConfig);
  249. observer.observe(observeEle1, MutationObserverConfig);
  250. observer.observe(observeEle2, MutationObserverConfig);
  251. $('body').on('click', '.upload-content li', function () {
  252. var index = $(this).closest('.conList').index() + 1,
  253. str = 'remarkImage' + index + 'FinderOpen';
  254. eval(str + '()');
  255. });
  256. $('body').on('click', '.cancel-upload', function () {
  257. var wrapper = $(this).closest('.conList');
  258. wrapper.find('li').css('z-index', '-1');
  259. wrapper.find('input').val('');
  260. $(this).hide();
  261. wrapper.removeClass("hide-pic");
  262. wrapper.parent().append(wrapper.clone());
  263. wrapper.remove();
  264. $(".conList").each(function (i, ele) {
  265. if ($(ele).find("input.input-xlarge").val()) {
  266. $(ele).next().removeClass("hide-pic")
  267. }
  268. })
  269. });
  270. $(window).on("load", function () {
  271. setTimeout(function () {
  272. $("#imageBox").find("input.input-xlarge").each(function (i, ele) {
  273. if ($(ele).val()) {
  274. $(ele).next().find("li").css("z-index", "99");
  275. $(ele).parents(".conList").find(".cancel-upload").show();
  276. $(ele).parents(".conList").next().removeClass("hide-pic")
  277. }
  278. })
  279. $("#appletsImageBox").find("input.input-xlarge").each(function (i, ele) {
  280. if ($(ele).val()) {
  281. $(ele).next().find("li").css("z-index", "99");
  282. $(ele).parents(".conList").find(".cancel-upload").show();
  283. $(ele).parents(".conList").next().removeClass("hide-pic")
  284. }
  285. })
  286. $("#adsImageBox").find("input.input-xlarge").each(function (i, ele) {
  287. if ($(ele).val()) {
  288. $(ele).next().find("li").css("z-index", "99");
  289. $(ele).parents(".conList").find(".cancel-upload").show();
  290. $(ele).parents(".conList").next().removeClass("hide-pic")
  291. }
  292. })
  293. }, 500);
  294. });
  295. });
  296. function getCheckedItems() {
  297. var items = {
  298. "id": $('#id').val(),
  299. "productId": "",
  300. "image": $('#image').val(),
  301. "appletsImage": $('#appletsImage').val(),
  302. "adsImage": $('#adsImage').val(),
  303. "name": $('#name').val(),
  304. "content": $('#content').val(),
  305. "link": $('#link').val(),
  306. "sort": $('#sort').val(),
  307. "pcStatus": $('#pcStatus').val(),
  308. "appletsStatus": $('#appletsStatus').val(),
  309. "label": $('#label').val(),
  310. "createDate": ""
  311. };
  312. return items;
  313. }
  314. /**
  315. * @param obj
  316. * jquery控制input只能输入数字
  317. */
  318. function onlynum(obj) {
  319. obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
  320. }
  321. //删除文件
  322. function dataDelete(that, id) {
  323. console.log($(that).text());
  324. $(that).parent().remove();
  325. var fileIds = $("#fileIds").val();
  326. if (fileIds.indexOf(id)) {
  327. fileIds = fileIds.replace(id + ',', '');
  328. $("#fileIds").val(fileIds);
  329. }
  330. $.ajax({
  331. url: "${ctx}/baike/cmBaikeProduct/deleteFile",
  332. data: {"fileId": id},
  333. async: false,
  334. type: "POST"
  335. });
  336. }
  337. function previewVideo(url) {
  338. var url = "${ctx}/archive/cmProductArchiveContent/preview?url=" + encodeURIComponent(url);
  339. var title = "视频播放";
  340. top.$.jBox("iframe:" + url, {
  341. iframeScrolling: 'yes',
  342. width: 1000,
  343. height: 750,
  344. persistent: true,
  345. title: title,
  346. buttons: {"关闭": '-1'}
  347. });
  348. }
  349. var fileIds=$('#id').val()
  350. //点击上传按钮后上传文件
  351. $('#addSubmit').click(function () {
  352. // var fileIdArr = fileIds.split(',');
  353. // if (fileIdArr.length >= 7) {
  354. // alertx('最多上传6个视频');
  355. // return;
  356. // }
  357. var filesById = document.getElementById('productFile');
  358. var files = $('#productFile');
  359. var filevalue = document.getElementById('productFile').value;
  360. var fileList = files.prop('files');
  361. var fileTitle = $('#fileTitle').val();
  362. var fileName = $('#uploadFileName').val();
  363. // if (fileTitle == '') {
  364. // alertx('请输入视频标题')
  365. // return;
  366. // }
  367. // if (files === '' || files.length == 0 || fileName == '') {
  368. // alertx('请选择上传文件');
  369. // return;
  370. // }
  371. if (filevalue === '') {
  372. alertx('请选择上传文件');
  373. return;
  374. }
  375. $("#fileTitle").val("");
  376. $("#uploadFileName").val("");
  377. var data = new FormData();
  378. var productId = $("#id").val();
  379. data.append('file', fileList[0]);
  380. data.append('fileTitle', fileTitle);
  381. data.append('fileName', fileName);
  382. data.append('productId', productId);
  383. data.append('fileIds', fileIds);
  384. $('.upload-loading').css("display", "inline");
  385. $.ajax({
  386. url: "${ctx}/baike/cmBaikeProduct/upload",
  387. data: data,
  388. type: "POST",
  389. processData: false,
  390. contentType: false,
  391. dataType: "json",
  392. success: function (res) {
  393. if (res.success) {
  394. filesById.value = '';
  395. var ossUrl=res.productFile.ossUrl;
  396. console.log(res);
  397. console.log(res.productFile);
  398. document.getElementById('bf').setAttribute("onclick", "previewVideo('" + ossUrl + "')");
  399. // console.log(ss.ossUrl);
  400. // renderFileList(res.productFile);
  401. $('.upload-loading').hide();
  402. } else {
  403. $.jBox.tip(res.msg, 'error');
  404. $("#uploadFileName").val(fileName);
  405. $('.upload-loading').hide();
  406. }
  407. },
  408. error: function (json) {
  409. }
  410. });
  411. })
  412. </script>
  413. </body>
  414. </html>