add_progress.html 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. {extend name="public/layout"/} {block name="title"}VR楼书{/block} {block name="body"}
  2. <link rel="stylesheet" href="__STATIC__/css/csspc.css">
  3. <link rel="stylesheet" href="__STATIC__/css/font.css">
  4. <style type="text/css">
  5. html,
  6. body {
  7. height: 100%;
  8. min-width: 800px;
  9. }
  10. .body {
  11. background: #fff;
  12. height: 100%;
  13. overflow-y: auto;
  14. width: 100%;
  15. box-sizing: border-box;
  16. padding: 25px;
  17. }
  18. .layui-form-box .layui-form-label {
  19. width: 200px;
  20. text-align: right;
  21. float: left;
  22. line-height: 46px;
  23. padding: 0 10px;
  24. }
  25. .layui-form-box .layui-input-block {
  26. float: left;
  27. margin-left: 0;
  28. max-width: 25%;
  29. width: 100%;
  30. }
  31. .layui-input {
  32. height: 46px;
  33. }
  34. .radio_input {
  35. width: 22px;
  36. height: 22px;
  37. }
  38. .addImages {
  39. display: inline-block;
  40. width: 145px !important;
  41. height: 87px !important;
  42. -webkit-box-sizing: border-box;
  43. -moz-box-sizing: border-box;
  44. box-sizing: border-box;
  45. border: 1px dashed darkgray;
  46. background: #f8f8f8;
  47. position: relative;
  48. overflow: hidden;
  49. }
  50. .addImages .upload_ico {
  51. font-size: 50px;
  52. color: #28A1FF;
  53. margin-top: 2px;
  54. display: inline-block;
  55. }
  56. .imageDiv {
  57. display: inline-block;
  58. width: 145px;
  59. height: 87px;
  60. -webkit-box-sizing: border-box;
  61. -moz-box-sizing: border-box;
  62. box-sizing: border-box;
  63. border: 1px dashed darkgray;
  64. background: #f8f8f8;
  65. position: relative;
  66. overflow: hidden;
  67. margin-right: 10px;
  68. }
  69. .imageDiv div {
  70. width: 100%;
  71. height: 100%;
  72. position: absolute;
  73. top: 0px;
  74. background-color: #e6e6e600;
  75. }
  76. .imageDiv div:hover {
  77. background-color: #e6e6e680;
  78. }
  79. .imageDiv div:hover i {
  80. display: block;
  81. cursor: pointer;
  82. }
  83. .text-detail {
  84. text-align: center;
  85. }
  86. .imageDiv div i {
  87. display: none;
  88. font-size: 31px;
  89. line-height: 87px;
  90. text-align: center;
  91. }
  92. .isshow {
  93. display: none;
  94. }
  95. .vrdelbtn {
  96. height: 46px;
  97. }
  98. .lanse {
  99. color: #28A1FF;
  100. }
  101. .isimgupload {
  102. width: 190px;
  103. height: 114px;
  104. margin-bottom: 10px;
  105. overflow:hidden;
  106. }
  107. .imageDivs {
  108. position: absolute;
  109. top: 0;
  110. left: 0;
  111. width: 100%;
  112. height: 100%;
  113. background: rgba(230, 230, 230, .5);
  114. display: none;
  115. }
  116. .imageDivs i {
  117. display: block;
  118. width: 18px;
  119. height: 18px;
  120. position: absolute;
  121. top: 0;
  122. left: 0;
  123. bottom: 0;
  124. right: 0;
  125. margin: auto;
  126. }
  127. .layui-upload-drag {
  128. padding: 18px 62px;
  129. }
  130. #vrWorks {
  131. position: relative;
  132. top: 5px;
  133. }
  134. </style>
  135. <body>
  136. <div class="body">
  137. <form class="layui-form layui-form-box">
  138. <div class="layui-form-item width100_ mdt30">
  139. <label class="layui-form-label"> 阶段命名:</label>
  140. <div class="layui-input-block">
  141. <input type="text" name="name" required placeholder="请输入标题" autocomplete="off" class="layui-input">
  142. </div>
  143. </div>
  144. <div class="layui-form-item">
  145. <label class="layui-form-label"> 标签:</label>
  146. <div class="layui-input-block">
  147. <select name="label_id" id="label_id">
  148. <option value="">请选择标签</option>
  149. {volist name="label" id="v"}
  150. <option value="{$v.id}">{$v.name}</option>
  151. {/volist}
  152. </select>
  153. </div>
  154. </div>
  155. <div class="layui-form-item woverflow mdt20">
  156. <label class="layui-form-label"><i style="color:red;">*</i> 更新类型:</label>
  157. <div class="layui-input-block lh45 mdl20" style="max-width: 400px !important;">
  158. <input type="radio" id="1" class="radio_input" lay-filter="types" name="type" value="img" title="图片"
  159. checked>
  160. <input type="radio" id="2" class="radio_input" lay-filter="types" name="type" value="vr"
  161. title="VR链接">
  162. <input type="radio" id="3" class="radio_input" lay-filter="types" name="type" value="video"
  163. title="视频">
  164. <input type="radio" id="4" class="radio_input" lay-filter="types" name="type" value="group"
  165. title="VR作品">
  166. </div>
  167. </div>
  168. <div class="layui-form-item woverflow mdt20">
  169. <div class="isshow" style="display: block;">
  170. <label class="layui-form-label"><i style="color:red;">*</i> 图片:</label>
  171. <div class="layui-input-block" style="max-width: 70%;">
  172. <div class="picDiv" id="draggable" style="margin: 20px 0px;">
  173. <div class="addImages" id="img">
  174. <div class="text-detail">
  175. <i class="layui-icon upload_ico">&#xe681;</i>
  176. <p>选择单、多图</p>
  177. </div>
  178. </div>
  179. </div>
  180. </div>
  181. <div class="layui-form-item">
  182. <label class="layui-form-label"></label>
  183. <div style="margin-left: 193px;"><i style="color:red;margin-right: 5px;">*</i><span>注:不支持拖拽文件
  184. 宽:高=5:3</span></div>
  185. </div>
  186. </div>
  187. <div class="isshow">
  188. <label class="layui-form-label"><i style="color:red;">*</i> VR链接:</label>
  189. <div class="wleft width50_ vrurllist">
  190. </div>
  191. </div>
  192. <input id="category_name" type="hidden" value="evidence" />
  193. <div class="isshow">
  194. <div class="layui-form-item">
  195. <label class="layui-form-label">视频封面图</label>
  196. <div class="layui-input-inline isimgupload" style="position: relative;">
  197. <div class="" id="upload-drag">
  198. <div class="layui-upload-drag">
  199. <i class="layui-icon">&#xe681;</i>
  200. <p>上传图片</p>
  201. </div>
  202. </div>
  203. <div class="imageDivs"><i class="layui-icon layui-icon-delete" prop="del"></i></div>
  204. </div>
  205. <div class="layui-form-item">
  206. <label class="layui-form-label"></label>
  207. <div style="margin-left: 197px;"><i
  208. style="color:red;margin-right: 5px;">*</i><span>注:不支持拖拽文件 宽:高=5:3</span></div>
  209. </div>
  210. </div>
  211. <label class="layui-form-label"><span style="color: red;">*</span>视频</label>
  212. <div class="layui-input-inline" style="width: 290px;display: block;" id="container">
  213. <a class="layui-btn btn layui-border-btn" id="selectfiles" href="javascript:void(0);">选择视频</a>
  214. <a class="layui-btn btn layui-border-btn" id="postfiles" href="javascript:void(0);">开始上传</a>
  215. <div id="ossfile"></div>
  216. <div id="symbshowed"></div>
  217. <div class="layui-form-mid layui-word-aux" style="color: red!important;margin-left:10px;">
  218. 注:选择视频并上传,限制100M内</div>
  219. <!--报错信息返回展示-->
  220. <pre id="console"></pre>
  221. <input type="hidden" value="" id="fileuri">
  222. <!--上传到OSS哪个文件下,在这里定义 -->
  223. <input type="hidden" value="dailyWechatArticle" id="wechat_label_name">
  224. </div>
  225. </div>
  226. <div class="isshow">
  227. <label class="layui-form-label"><span style="color: red;">*</span>VR作品</label>
  228. <div class="layui-input-inline" style="width: 400px;display: block;">
  229. <a class="layui-btn btn layui-border-btn" style="margin-top: 5px;" id="selectVRCreate" href="javascript:void(0);">选择VR作品</a>
  230. <span id="vrWorks"></span>
  231. </div>
  232. </div>
  233. </div>
  234. <!-- <p class="wleft wpsr width50_" style="color:red;height: 136px;">
  235. <span class="wpsa font14 bottom0 left0">注:不支持拖拽文件 宽:高=1:1</span>
  236. </p> -->
  237. <div class="layui-form-item woverflow mdt30">
  238. <label class="layui-form-label">内容:</label>
  239. <div class="layui-input-block mdl20 wleft" style="max-width: 70%;">
  240. <textarea name="content" id="content" rows="10" autocomplete="off"
  241. class="layui-textarea width100_ pdtb15"></textarea>
  242. </div>
  243. </div>
  244. <div class="mdt50 mdl200">
  245. <button type="button" class="layui-btn layui-btn-normal layuiSubmit pdlr30" lay-submit
  246. lay-filter="spellgroup-submit" id="spellgroup-submit">保存</button>
  247. </div>
  248. </form>
  249. </div>
  250. </body>
  251. <script type="text/javascript" src="__STATIC__/js/plupload/js/plupload.full.min.js"></script>
  252. <script type="text/javascript" src="__STATIC__/js/plupload/ossupload.js"></script>
  253. {/block} {block name="js"}
  254. <script>
  255. layui.config({
  256. base: '__LAYUI__/',
  257. urlbase: '/sys'
  258. }).extend({
  259. index: 'lib/index' //主入口模块
  260. }).use(['index', 'element', 'upload', 'form'], function () {
  261. var $ = layui.$,
  262. layer = layui.layer,
  263. upload = layui.upload,
  264. element = layui.element,
  265. form = layui.form,
  266. set_List = [{
  267. name: ''
  268. }],
  269. vrlinkVal = 0,
  270. files = [],
  271. ossConfig = {};
  272. var imglist = [];
  273. var imglistlen = [];
  274. form.render()
  275. let building_id = "{$building_id}";
  276. form.on('radio(types)', function (data) {
  277. var this_ = $(this).attr('id') - 1;
  278. $('.isshow').eq(this_).show().siblings().hide();
  279. });
  280. //视频封面图
  281. upload.render({
  282. elem: '#upload-drag',
  283. accept: 'image',
  284. exts: 'png|jpg|jpeg',
  285. auto: false,
  286. field: 'cover',
  287. size: 3 * 1024,
  288. choose: function (obj) {
  289. obj.preview(function (index, file, result) {
  290. $('#upload-drag').html('<img class="fmimages" src="' + result + '" style="width:100%;">');
  291. });
  292. }
  293. });
  294. $('.isimgupload').hover(function () {
  295. if ($("#upload-drag:has(img.fmimages)").length > 0) {
  296. $('.imageDivs').show();
  297. }
  298. }, function () {
  299. $('.imageDivs').hide();
  300. })
  301. $('.imageDivs').on('click', function (e) {
  302. var that = this;
  303. layer.confirm('确定删除该图片么?', { title: ['信息', 'color:#333333;background-color:#D8E6F1;'], }, function (index) {
  304. var imgDiv = $('#upload-drag').find('img');
  305. imgDiv.remove();
  306. $('#upload-drag').html('<div class="layui-upload-drag"><i class="layui-icon">&#xe681;</i><p>上传图片</p></div>');
  307. layer.close(index);
  308. });
  309. });
  310. var loadindex;
  311. var load_status = 0;
  312. var load_end = 0;
  313. //多图片上传
  314. upload.render({
  315. elem: '#img',
  316. accept: 'images',
  317. url: '{:url("building/fileupload")}',
  318. exts: 'jpg|png|bmp|jpeg|JPG|PNG|BMP|JPEG',
  319. field: 'file',
  320. size: 5 * 1024,
  321. auto: true,
  322. multiple: true,
  323. choose: function (obj) {
  324. files = obj.pushFile();
  325. length = $('.imageDiv').length;
  326. imglist = [];
  327. obj.preview(function (index, file, result) {
  328. length++;
  329. if (length > 9) {
  330. loadindex = layer.msg('限制九张图片以下..', {
  331. icon: 16
  332. , shade: 0.3
  333. , time: false
  334. });
  335. delete files[index];
  336. } else {
  337. load_status = length;
  338. if (length == 1) {
  339. loadindex = layer.msg('加载中..', {
  340. icon: 16
  341. , shade: 0.3
  342. , time: false
  343. });
  344. }
  345. $('.picDiv').prepend('<div class="imageDiv" data-id="' + index + '"><img src="' + result + '" alt="' + file.name + '" class="layui-upload-img" width="100%" height="100%"><div><i class="layui-icon layui-icon-delete" prop="del"></i> <i class="layui-icon layui-icon-search" prop="view" data-image="' + result + '" style="margin-left:25px;"></i></div></div>');
  346. }
  347. });
  348. },
  349. done: function (res) {
  350. load_end++;
  351. console.log(load_end)
  352. if (res.code == 0) {
  353. if (imglist.length < 9) {
  354. imglist.push(res.data.src);
  355. if (load_status == load_end) {
  356. layer.close(loadindex);
  357. }
  358. }
  359. }
  360. }
  361. });
  362. $('.picDiv').on('click', 'i', function (e) {
  363. var that = this;
  364. if (e.target.attributes[1].nodeValue === 'del') {
  365. layer.confirm('确定删除该图片么?', { title: ['信息', 'color:#333333;background-color:#D8E6F1;'], }, function (index) {
  366. var imgDiv = $(that).closest('.imageDiv');
  367. imglist.splice(imgDiv.index(), 1);
  368. if (id = imgDiv.data('id')) {
  369. delete files[id];
  370. }
  371. imgDiv.remove();
  372. layer.close(index);
  373. });
  374. } else {
  375. layer.photos({ photos: { "data": [{ "src": e.target.attributes[2].nodeValue }] }, closeBtn: true });
  376. }
  377. });
  378. set_step_Html(set_List);
  379. function set_step_Html(set_List) {
  380. $('.vrurllist')[0].innerHTML = $.map(set_List, (v, i) => {
  381. return `<div class="woverflow width100_ mdb20">
  382. <div class="layui-input-block" style="max-width:50% !important; ">
  383. <input type="text" data-type="name" data-index="${i}" placeholder="请输入标题" autocomplete="off" class="layui-input" value="${v.name}">
  384. </div>
  385. <p class="wleft lh46 wpsr mdl10 href vrdelbtn add_step font32" data-index="${set_List.length + 1}">
  386. <span class="wpsa wpsauto lanse ds">+</span>
  387. </p>
  388. <p class="wleft lh40 wpsr mdl40 href vrdelbtn delete font50" data-index="${i}">
  389. <span class="wpsa wpsauto lanse ds">-</span>
  390. </p>
  391. </div>`
  392. }).join('');
  393. setTimeout(() => {
  394. $('.add_step').click((e) => {
  395. let index = parseInt(e.target.dataset.index);
  396. if (set_List.length < 9) {
  397. set_List.push({
  398. id: 0,
  399. name: ''
  400. });
  401. set_step_Html(set_List)
  402. } else {
  403. layer.msg('最多设置9个VR链接');
  404. }
  405. })
  406. $('.delete').click((e) => {
  407. if (set_List.length <= 1) {
  408. layer.msg('只剩最后一个了');
  409. } else {
  410. let index = parseInt(e.target.dataset.index);
  411. set_List.splice(index, 1);
  412. set_step_Html(set_List)
  413. }
  414. })
  415. $('input').change((e) => {
  416. let type = e.target.dataset.type;
  417. let val = e.target.value;
  418. if (type && type != undefined) {
  419. let index = parseInt(e.target.dataset.index);
  420. set_List[index][type] = val;
  421. }
  422. })
  423. }, 500)
  424. }
  425. form.on('submit(spellgroup-submit)', function (data) {
  426. // 单击之后提交按钮不可选,防止重复提交
  427. var formData = new FormData(data.form);
  428. formData.delete('file');
  429. if ($("#upload-drag:has(img.fmimages)").length < 1) {
  430. formData.delete('cover');
  431. }
  432. formData.append('building_id', building_id);
  433. // Object.keys(files).forEach((v,i) => {
  434. // formData.append(`img[${i}]`, files[v])
  435. // })
  436. if (data.field.type == 'img') {
  437. // if (!Object.keys(files).length) {
  438. // layer.msg('请添加图片')
  439. // return;
  440. // }
  441. if (imglist.length == 0) {
  442. layer.msg('请添加图片')
  443. return;
  444. }
  445. formData.append('img', imglist)
  446. formData.append('vr', '')
  447. } else if (data.field.type == 'vr') {
  448. let list = set_List.filter(v => v.name);
  449. if (!list.length) {
  450. layer.msg('请添加VR链接')
  451. return;
  452. }
  453. let vrStr = set_List.map(v => v.name).join(',')
  454. formData.append('img', '');
  455. formData.append('vr', vrStr)
  456. } else if (data.field.type == 'group') {
  457. if (vrlinkVal==0) {
  458. layer.msg('请选择VR作品')
  459. return;
  460. }
  461. formData.append('img', '')
  462. formData.append('vr', '')
  463. formData.append('vr_group_ids', vrlinkVal);
  464. } else {
  465. var video_url = $('#fileuri').val();
  466. //video_url = 'Building/62a060cb2a61c.jpg';
  467. formData.append('video', video_url);
  468. formData.append('vr', '')
  469. if (video_url == '') {
  470. layer.msg('请选择视频', { anim: 6, time: 1000, icon: 5 });
  471. return false;
  472. }
  473. }
  474. var DISABLED = 'layui-btn-disabled';
  475. var target = '#spellgroup-submit';
  476. $(target).addClass(DISABLED);
  477. $(target).attr('disabled', 'disabled');
  478. loadindex = layer.msg('正在提交..', {
  479. icon: 16
  480. , shade: 0.3
  481. , time: false
  482. });
  483. $.ajax({
  484. url: '{:url("building/add_progress")}',
  485. type: 'post',
  486. data: formData,
  487. dataType: 'json',
  488. processData: false,
  489. contentType: false,
  490. success: function (res) {
  491. if (res.code === 0) {
  492. layer.close(loadindex);
  493. layer.msg(res.msg, {
  494. anim: 0, time: 1000, icon: 6,
  495. }, function () {
  496. var index = parent.layer.getFrameIndex(window.name);
  497. parent.layer.close(index);
  498. });
  499. } else {
  500. $(target).removeClass(DISABLED);
  501. $(target).removeAttr('disabled');
  502. layer.msg(res.msg, { anim: 0, time: 1000, icon: 5 });
  503. }
  504. },
  505. error: function (e) {
  506. $(target).removeClass(DISABLED);
  507. $(target).removeAttr('disabled');
  508. }
  509. });
  510. return false;
  511. })
  512. //vr作品
  513. $('#selectVRCreate').click(function(){
  514. layer.open({
  515. type: 2,
  516. title: ['选择VR作品', 'color:#333333;background-color:#D8E6F1;'],
  517. content: '{:url("building/group")}?id=' + "{$building_id}",
  518. area: ['80%', '80%'],
  519. btn: ['确定', '取消'],
  520. yes: function (index, layero) {
  521. let data = layero.find('iframe').contents().find("#hiddentext").val();
  522. if (data) {
  523. let vrObject = JSON.parse(data);
  524. vrlinkVal = vrObject.id;
  525. $("#vrWorks").text(vrObject.name);
  526. }
  527. layer.close(index);
  528. //点击确认触发 iframe 内容中的按钮提交
  529. }
  530. });
  531. })
  532. })
  533. </script>
  534. {/block}