addActivityAdsVideo.jsp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  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. .upload {
  74. position: relative;
  75. display: inline-block;
  76. background: #D0EEFF;
  77. border: 1px solid #99D3F5;
  78. border-radius: 4px;
  79. padding: 4px 12px;
  80. color: #1E88C7;
  81. text-decoration: none;
  82. text-indent: 0;
  83. line-height: 20px;
  84. margin-left: 20px;
  85. cursor: pointer;
  86. width: 52px;
  87. height: 20px;
  88. }
  89. .upload input {
  90. position: absolute;
  91. width: 170px;
  92. font-size: 20px;
  93. right: 0;
  94. top: 0;
  95. opacity: 0;
  96. cursor: pointer;
  97. }
  98. .upload:hover {
  99. background: #AADFFD;
  100. border-color: #78C3F3;
  101. color: #004974;
  102. text-decoration: none;
  103. }
  104. .add-submit {
  105. position: relative;
  106. display: inline;
  107. background: #D0EEFF;
  108. border: 1px solid #99D3F5;
  109. border-radius: 4px;
  110. padding: 4px 12px;
  111. color: #1E88C7;
  112. text-decoration: none;
  113. text-indent: 0;
  114. line-height: 20px;
  115. margin-left: 20px;
  116. cursor: pointer;
  117. width: 52px;
  118. height: 30px;
  119. }
  120. .add-submit input {
  121. position: absolute;
  122. width: 50px;
  123. font-size: 20px;
  124. right: 0;
  125. top: 0;
  126. opacity: 0;
  127. cursor: pointer;
  128. }
  129. .add-submit:hover {
  130. background: #AADFFD;
  131. border-color: #78C3F3;
  132. color: #004974;
  133. text-decoration: none;
  134. }
  135. .aaa {
  136. color: #2fa4e7;
  137. font-size: 12px;
  138. cursor: pointer;
  139. margin-left: 20px;
  140. }
  141. </style>
  142. <script type="text/javascript">
  143. $(document).ready(function () {
  144. $("#inputForm").validate({
  145. submitHandler: function (form) {
  146. var beginTime = $("#beginTime").val();
  147. var endTime = $("#endTime").val();
  148. if (beginTime > endTime) {
  149. alertx("开始时间不能晚于结束时间!");
  150. return;
  151. } else {
  152. loading('正在提交,请稍等...');
  153. form.submit();
  154. }
  155. },
  156. errorContainer: "#messageBox",
  157. errorPlacement: function (error, element) {
  158. $("#messageBox").text("输入有误,请先更正。");
  159. if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
  160. error.appendTo(element.parent().parent());
  161. } else {
  162. error.insertAfter(element);
  163. }
  164. }
  165. });
  166. });
  167. </script>
  168. </head>
  169. <body>
  170. <br/>
  171. <form:form id="inputForm" modelAttribute="floorImage" action="" method="post" class="form-horizontal">
  172. <form:hidden path="id" id="id"/>
  173. <sys:message content="${message}"/>
  174. <div class="control-group iconBox">
  175. <label class="control-label"><span class="help-inline"><font color="red">*</font> </span>视频封面</label>
  176. <div class="controls upload-content" id="imageBox">
  177. <div class="conList">
  178. <form:hidden id="image" path="image" htmlEscape="false" maxlength="255" class="input-xlarge required"/>
  179. <sys:ckfinder input="image" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100"
  180. maxHeight="100"/>
  181. <br>
  182. <label>${pcImageSize}</label>
  183. </div>
  184. <div hidden><input id="proId" value=${pageId}></div>
  185. </div>
  186. </div>
  187. <%-- <div class="control-group iconBox">--%>
  188. <%-- <label class="control-label"><span class="help-inline"><font color="red">*</font> </span>小程序图片:</label>--%>
  189. <%-- <div class="controls upload-content" id="appletsImageBox">--%>
  190. <%-- <div class="conList">--%>
  191. <%-- <form:hidden id="appletsImage" path="appletsImage" htmlEscape="false" maxlength="255" class="input-xlarge required"/>--%>
  192. <%-- <sys:ckfinder input="appletsImage" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100"--%>
  193. <%-- maxHeight="100"/>--%>
  194. <%-- <br>--%>
  195. <%-- <label>${appletsImageSize}</label>--%>
  196. <%-- </div>--%>
  197. <%-- </div>--%>
  198. <%-- </div>--%>
  199. <div class="control-group" style="display: ${type eq 'adsImage'?'none':''}">
  200. <label class="control-label"><font color="red">*</font>标题:</label>
  201. <div class="controls">
  202. <form:input path="name" id="name" htmlEscape="false" class="input-xlarge required"/>
  203. </div>
  204. </div>
  205. <div class="control-group" style="display: ${type eq 'adsImage'?'none':''}">
  206. <label class="control-label"><font color="red">*</font>内容:</label>
  207. <div class="controls">
  208. <form:textarea path="content" id="content" htmlEscape="false" class="input-xlarge required"/>
  209. </div>
  210. </div>
  211. <div class="control-group">
  212. <div class="control-group">
  213. <label class="control-label" style="margin-top:10px"><font color="red">*</font>视频路径:</label>
  214. <div class="controls" style="margin-top:10px">
  215. <input id="uploadFileName" type="text" style="display: inline;" placeholder="支持mp4" disabled="true" class="input-xlarge required" />
  216. <div class="upload">
  217. <input type="file" name="file" id="productFile" accept=".mp4" >选择文件
  218. </div>
  219. <div class="add-submit">
  220. <input id="addSubmit" type="button" value="上传"/>上传
  221. </div>
  222. <div class="upload-loading" hidden>
  223. <img alt="gif" src="/static/images/upload.gif" width="32px" border="none">
  224. </div>
  225. </div>
  226. </div>
  227. <div class="control-group">
  228. <div id='file-list-display' style="margin-left:180px" hidden>
  229. <%-- <c:if test="${not empty cmBaikeProduct.videoList}">--%>
  230. <%-- <c:forEach items="${cmBaikeProduct.videoList}" var="videoFile" varStatus="statusIndex">--%>
  231. <%-- <p>${videoFile.fileTitle}--%>
  232. <input type="text" id="videoName" disabled>
  233. <div hidden> <input type="text" id="link" disabled/></div>
  234. <span class="aaa"><a id="bf">预览</a></span> <%-- ${floorImage.id} </c:if>--%>
  235. <span class="aaa" id="sc">删除</span>
  236. <%-- </p>--%>
  237. <%-- </c:forEach>--%>
  238. <%-- </c:if>--%>
  239. </div>
  240. </div>
  241. </div>
  242. <%-- <div class="control-group">--%>
  243. <%-- <label class="control-label">跳转链接:</label>--%>
  244. <%-- <div class="controls">--%>
  245. <%-- <form:input path="link" id="link" htmlEscape="false" cssStyle="position: relative" class="input-xlarge required"/>--%>
  246. <%-- </div>--%>
  247. <%-- </div>--%>
  248. <%-- <div class="control-group iconBox">--%>
  249. <%-- <label class="control-label">小程序内容宣传图:</label>--%>
  250. <%-- <div class="controls upload-content" id="adsImageBox">--%>
  251. <%-- <div class="conList">--%>
  252. <%-- <form:hidden id="adsImage" path="adsImage" htmlEscape="false" maxlength="255" class="input-xlarge required"/>--%>
  253. <%-- <sys:ckfinder input="adsImage" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100"--%>
  254. <%-- maxHeight="100"/>--%>
  255. <%-- <br>--%>
  256. <%-- <label>建议图片尺寸宽度750px</label>--%>
  257. <%-- </div>--%>
  258. <%-- </div>--%>
  259. <%-- </div>--%>
  260. <div class="control-group">
  261. <label class="control-label"><font color="red">*</font> 排序:</label>
  262. <div class="controls">
  263. <form:input path="sort" id="sort" htmlEscape="false" maxlength="11" onkeyup="onlynum(this)" class="input-xlarge required"/>
  264. </div>
  265. </div>
  266. <div class="control-group">
  267. <label class="control-label">网站状态:</label>
  268. <div class="controls">
  269. <form:select path="pcStatus" id="pcStatus" class="input-medium required">
  270. <form:option value="1" label="启动"/>
  271. <form:option value="0" label="停用"/>
  272. </form:select>
  273. </div>
  274. </div>
  275. <div class="control-group">
  276. <label class="control-label">小程序状态:</label>
  277. <div class="controls">
  278. <form:select path="appletsStatus" id="appletsStatus" class="input-medium required">
  279. <form:option value="1" label="启动"/>
  280. <form:option value="0" label="停用"/>
  281. </form:select>
  282. </div>
  283. </div>
  284. </form:form>
  285. <script type="text/javascript">
  286. $(document).ready(function () {
  287. //弹出框去滚动条
  288. top.$('#jbox-content').css("overflow-y", "hidden");
  289. show_title(30);
  290. });
  291. $(function () {
  292. $('.upload-content .conList .btn:nth-of-type(1)').html('<div><span>+</span><h5>选择图片</h5></div>');
  293. $('.upload-content .conList .btn:nth-of-type(2)').after('<img class="cancel-upload" src="/static/images/close-btn1.png">').remove();
  294. $('.upload-content .conList').find('.cancel-upload').hide();
  295. var observeEle = document.getElementsByClassName('upload-content')[0];
  296. var observeEle1 = document.getElementsByClassName('upload-content')[1];
  297. var observeEle2 = document.getElementsByClassName('upload-content')[2];
  298. var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
  299. var MutationObserverConfig = {
  300. childList: true,
  301. subtree: true,
  302. characterData: true
  303. };
  304. var observer = new MutationObserver(function (mutations) {
  305. $.each(mutations, function (index, item) {
  306. if (item.type === 'childList') {
  307. // 在创建新的 element 时调用
  308. var target = $(item.target),
  309. thisWrapper = target.closest('.conList'),
  310. nextEle = thisWrapper.next();
  311. thisWrapper.find('li').css('z-index', 99);
  312. thisWrapper.find('.cancel-upload').show();
  313. if (nextEle.hasClass('hide-pic')) {
  314. nextEle.removeClass('hide-pic');
  315. }
  316. }
  317. })
  318. });
  319. observer.observe(observeEle, MutationObserverConfig);
  320. observer.observe(observeEle1, MutationObserverConfig);
  321. observer.observe(observeEle2, MutationObserverConfig);
  322. $('body').on('click', '.upload-content li', function () {
  323. var index = $(this).closest('.conList').index() + 1,
  324. str = 'remarkImage' + index + 'FinderOpen';
  325. eval(str + '()');
  326. });
  327. $('body').on('click', '.cancel-upload', function () {
  328. var wrapper = $(this).closest('.conList');
  329. wrapper.find('li').css('z-index', '-1');
  330. wrapper.find('input').val('');
  331. $(this).hide();
  332. wrapper.removeClass("hide-pic");
  333. wrapper.parent().append(wrapper.clone());
  334. wrapper.remove();
  335. $(".conList").each(function (i, ele) {
  336. if ($(ele).find("input.input-xlarge").val()) {
  337. $(ele).next().removeClass("hide-pic")
  338. }
  339. })
  340. });
  341. $(window).on("load", function () {
  342. setTimeout(function () {
  343. $("#imageBox").find("input.input-xlarge").each(function (i, ele) {
  344. if ($(ele).val()) {
  345. $(ele).next().find("li").css("z-index", "99");
  346. $(ele).parents(".conList").find(".cancel-upload").show();
  347. $(ele).parents(".conList").next().removeClass("hide-pic")
  348. }
  349. })
  350. $("#appletsImageBox").find("input.input-xlarge").each(function (i, ele) {
  351. if ($(ele).val()) {
  352. $(ele).next().find("li").css("z-index", "99");
  353. $(ele).parents(".conList").find(".cancel-upload").show();
  354. $(ele).parents(".conList").next().removeClass("hide-pic")
  355. }
  356. })
  357. $("#adsImageBox").find("input.input-xlarge").each(function (i, ele) {
  358. if ($(ele).val()) {
  359. $(ele).next().find("li").css("z-index", "99");
  360. $(ele).parents(".conList").find(".cancel-upload").show();
  361. $(ele).parents(".conList").next().removeClass("hide-pic")
  362. }
  363. })
  364. }, 500);
  365. });
  366. });
  367. function getCheckedItems() {
  368. var items = {
  369. "id": $('#id').val(),
  370. "productId": "",
  371. "image": $('#image').val(),
  372. "appletsImage": $('#appletsImage').val(),
  373. "adsImage": $('#adsImage').val(),
  374. "name": $('#name').val(),
  375. "content": $('#content').val(),
  376. "link": $('#link').val(),
  377. "sort": $('#sort').val(),
  378. "pcStatus": $('#pcStatus').val(),
  379. "appletsStatus": $('#appletsStatus').val(),
  380. "label": $('#label').val(),
  381. "createDate": ""
  382. };
  383. return items;
  384. }
  385. /**
  386. * @param obj
  387. * jquery控制input只能输入数字
  388. */
  389. function onlynum(obj) {
  390. obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
  391. }
  392. //删除文件
  393. function dataDelete(that, id) {
  394. console.log($(that).text());
  395. $(that).parent().remove();
  396. var fileIds = $("#fileIds").val();
  397. // if (fileIds.indexOf(id)) {
  398. // fileIds = fileIds.replace(id + ',', '');
  399. // $("#fileIds").val(fileIds);
  400. // }
  401. $.ajax({
  402. url: "${ctx}/baike/cmBaikeProduct/deleteFile",
  403. data: {"fileId": id},
  404. async: false,
  405. type: "POST"
  406. });
  407. }
  408. function previewVideo(url) {
  409. var url = "${ctx}/archive/cmProductArchiveContent/preview?url=" + encodeURIComponent(url);
  410. var title = "视频播放";
  411. top.$.jBox("iframe:" + url, {
  412. iframeScrolling: 'yes',
  413. width: 1000,
  414. height: 750,
  415. persistent: true,
  416. title: title,
  417. buttons: {"关闭": '-1'}
  418. });
  419. }
  420. var fileIds=$('#id').val()
  421. //点击上传按钮后上传文件
  422. $('#addSubmit').click(function () {
  423. // var fileIdArr = fileIds.split(',');
  424. // if (fileIdArr.length >= 7) {
  425. // alertx('最多上传6个视频');
  426. // return;
  427. // }
  428. var filesById = document.getElementById('productFile');
  429. var files = $('#productFile');
  430. var filevalue = document.getElementById('productFile').value;
  431. var fileList = files.prop('files');
  432. var fileTitle = $('#fileTitle').val();
  433. // var fileName = $('#addSubmit').val();
  434. var fileName = $('#uploadFileName').val();
  435. // if (fileTitle == '') {
  436. // alertx('请输入视频标题')
  437. // return;
  438. // }
  439. // if (files === '' || files.length == 0 || fileName == '') {
  440. // alertx('请选择上传文件');
  441. // return;
  442. // }
  443. if (filevalue === '') {
  444. alertx('请选择上传文件');
  445. return;
  446. }
  447. $("#fileTitle").val("");
  448. $("#uploadFileName").val("");
  449. var data = new FormData();
  450. var productId = $("#proId").val();
  451. data.append('file', fileList[0]);
  452. data.append('fileTitle', fileTitle);
  453. data.append('fileName', fileName);
  454. data.append('productId', productId);
  455. data.append('fileIds', fileIds);
  456. $('.upload-loading').css("display", "inline");
  457. $.ajax({
  458. url: "${ctx}/baike/cmBaikeProduct/upload",
  459. data: data,
  460. type: "POST",
  461. processData: false,
  462. contentType: false,
  463. dataType: "json",
  464. success: function (res) {
  465. if (res.success) {
  466. filesById.value = '';
  467. var ossUrl=res.productFile.ossUrl;
  468. var fileid=res.productFile.id;
  469. var videoname=res.productFile.fileName;
  470. console.log(res);
  471. console.log(res.productFile);
  472. document.getElementById('bf').setAttribute("onclick", "previewVideo('" + ossUrl + "')");
  473. document.getElementById('sc').setAttribute("onclick", "dataDelete(this,'"+fileid+"')");
  474. // console.log(ss.ossUrl);
  475. // renderFileList(res.productFile);
  476. document.getElementById('videoName').setAttribute("value",videoname);
  477. document.getElementById('link').setAttribute("value",ossUrl);
  478. $('.upload-loading').hide();
  479. $('#file-list-display').show();
  480. } else {
  481. $.jBox.tip(res.msg, 'error');
  482. $("#uploadFileName").val(fileName);
  483. $('.upload-loading').hide();
  484. }
  485. },
  486. error: function (json) {
  487. }
  488. });
  489. })
  490. var files = document.getElementById("productFile");
  491. //选择上传文件后显示文件名称
  492. files.addEventListener("change", function (event) {
  493. var name = event.target.files[0].name;
  494. console.log(name)
  495. $('#uploadFileName').val(name);
  496. });
  497. </script>
  498. </body>
  499. </html>