uploadimg.html 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  1. <<<<<<< HEAD
  2. <!-- <div class="cl pd-5 bg-1 bk-gray">
  3. <a href="{:url('/file_manager/selectpicture')}" class="btn btn-default radius sethumb">
  4. <i class="Hui-iconfont">&#xe600;</i> 站内选择 </a>&nbsp;&nbsp;
  5. <a href="javascript:void(0);" class="btn btn-primary radius sethumb">
  6. <i class="Hui-iconfont">&#xe600;</i> 本地上传 </a>&nbsp;&nbsp;
  7. <a href="{:url('/file_manager/onlinepicture')}" class="btn btn-default radius sethumb">
  8. <i class="Hui-iconfont">&#xe600;</i> 网络图片 </a>&nbsp;&nbsp;
  9. </div> -->
  10. <!-- 本地上传 -->
  11. <style>
  12. #online {
  13. width: 100%;
  14. height: 224px;
  15. padding: 10px 0 0 0;
  16. }
  17. #online #imageList {
  18. width: 100%;
  19. height: 100%;
  20. overflow-x: hidden;
  21. overflow-y: auto;
  22. position: relative;
  23. margin-left: 20px;
  24. }
  25. #online ul {
  26. display: block;
  27. list-style: none;
  28. margin: 0;
  29. padding: 0;
  30. }
  31. #online li {
  32. float: left;
  33. display: block;
  34. list-style: none;
  35. padding: 0;
  36. width: 113px;
  37. height: 113px;
  38. margin: 0 0 9px 9px;
  39. background-color: #eee;
  40. overflow: hidden;
  41. cursor: pointer;
  42. position: relative;
  43. }
  44. #online li img {
  45. cursor: pointer;
  46. }
  47. #online li .icon {
  48. cursor: pointer;
  49. width: 113px;
  50. height: 113px;
  51. position: absolute;
  52. top: 0;
  53. left: 0;
  54. z-index: 2;
  55. border: 0;
  56. background-repeat: no-repeat;
  57. }
  58. #online li .icon:hover {
  59. width: 107px;
  60. height: 107px;
  61. border: 3px solid #1094fa;
  62. }
  63. #online li.selected .icon {
  64. background-image: url(/static/images/success.png);
  65. background-image: url(images/success.gif)\9;
  66. background-position: 75px 75px;
  67. }
  68. #online li.clearFloat {
  69. float: none;
  70. clear: both;
  71. display: block;
  72. width: 0;
  73. height: 0;
  74. margin: 0;
  75. padding: 0;
  76. }
  77. </style>
  78. <div id="tab-img" class="HuiTab">
  79. <div class="tabBar clearfix">
  80. <span>本地上传</span>
  81. <span>网络文件上传</span>
  82. <a onclick="onlinepicture(1)"><span>服务器图片选择</span></a>
  83. </div>
  84. <div class="tabCon">
  85. <div class="step1 active" style="margin-left:30px;">
  86. <form id="form-uploadimg" method="post" action="" enctype="multipart/form-data">
  87. <div class="row cl" style="margin-top:20px;">
  88. <label class="form-label col-xs-2 col-sm-2"><span class="c-red">*</span>图片要求: </label>
  89. <div class="formControls col-xs-8 col-sm-8">
  90. 格式 jpg,png,gif,jpeg,webp; 大小不超过4M.
  91. </div>
  92. <div class="col-3"> </div>
  93. </div>
  94. <div class="row cl" style="margin-top:20px;">
  95. <label class="form-label col-xs-2 col-sm-2">
  96. <span class="c-red">*</span>本地上传:</label>
  97. <div class="formControls col-xs-4 col-sm-4">
  98. <input type="file" class="input-text" name="upload_file" id="upload_file">
  99. </div>
  100. <div class="col-3"> </div>
  101. </div>
  102. <div class="row cl" style="margin-top:20px;">
  103. <input type="hidden" name="img_id" value={$img_id}>
  104. <div class="formControls col-xs-12 col-sm-8">
  105. <div class="skin-minimal">
  106. <div class="check-box">
  107. <input type="checkbox" name="overwrite" value="{$overwrite}" {$overwrite ? 'checked'
  108. : "" }>
  109. <label for="overwrite">覆盖原图</label>
  110. </div>
  111. <div class="check-box">
  112. <input type="checkbox" name="water" value="{$water}" {$water ? 'checked' : "" }>
  113. <label for="water">水印</label>
  114. </div>
  115. <div class="check-box">
  116. <input type="checkbox" name="thumb" value="{$thumb}" {$thumb ? 'checked' : "" }>
  117. <label for="thumb-1">缩略图</label>
  118. <input type="text" class="input-text" name="width" value={$width}
  119. style="width: 80px;">缩略图宽度
  120. <input type="text" class="input-text" name="height" value={$height}
  121. style="width: 80px;">缩略图高度
  122. </div>
  123. </div>
  124. </div>
  125. </div>
  126. <div class="row cl" style="margin-top:30px;margin-left:30px;">
  127. <div class="col-xs-6 col-sm-5 col-xs-offset-2 col-sm-offset-2">
  128. <input class="btn btn-primary radius" type="button" value="&nbsp;确&nbsp;定&nbsp;"
  129. onCLick="uploadImg()">
  130. <input class="btn btn-default radius" type="button" value="&nbsp;取&nbsp;消&nbsp;"
  131. onClick="layer_close();">
  132. </div>
  133. </div>
  134. </form>
  135. </div>
  136. <!-- 本地上传end -->
  137. </div>
  138. <div class="tabCon">
  139. </div>
  140. <!-- 在线图片 -->
  141. <div class="tabCon">
  142. </div>
  143. </div>
  144. <!--请在下方写此页面业务相关的脚本-->
  145. <script type="text/javascript">
  146. jQuery.Huitab = function (tabBar, tabCon, class_name, tabEvent, i) {
  147. var $tab_menu = $(tabBar);
  148. // 初始化操作
  149. $tab_menu.removeClass(class_name);
  150. $(tabBar).eq(i).addClass(class_name);
  151. $(tabCon).hide();
  152. $(tabCon).eq(i).show();
  153. $tab_menu.bind(tabEvent, function () {
  154. $tab_menu.removeClass(class_name);
  155. $(this).addClass(class_name);
  156. var index = $tab_menu.index(this);
  157. $(tabCon).hide();
  158. $(tabCon).eq(index).show()
  159. })
  160. }
  161. $(function () {
  162. $.Huitab("#tab-img .tabBar span", "#tab-img .tabCon", "current", "click", "0");
  163. $(document).on("click", "#online li", function(){
  164. $("#online li").removeClass('selected');
  165. $(this).addClass('selected');
  166. img = $(this).children('img').attr('_src');
  167. $("#online_file").val(img);
  168. })
  169. });
  170. function onlinepicture(page) {
  171. var data = { "page": page };
  172. $.ajax({
  173. url: '{:url("file_manager/onlineimg")}',
  174. type: 'GET',
  175. async: true,
  176. cache: false,
  177. data: 'page=' + page,
  178. processData: false,
  179. contentType: false,
  180. dataType: "json",
  181. success: function (res) {
  182. if (res.code == 0) {
  183. html_str = "";
  184. res.list.forEach(element => {
  185. html_str += '<li><img width="170" height="113" src="' + element.url + '?noCache=' + element.mtime + '"';
  186. html_str += '_src="' + element.url + '">';
  187. html_str += '<span class="icon"></span></li>';
  188. });
  189. $('ul.list').prepend(html_str);
  190. }
  191. }
  192. });
  193. }
  194. //step1本地上传图片
  195. function uploadImg() {
  196. if ($("#upload_file").val() == '') {
  197. layer.msg("请选择要上传的文件", {
  198. icon: 6,
  199. time: 1000
  200. });
  201. return false;
  202. } else {
  203. var formData = new FormData($("#form-uploadimg")[0]);
  204. $.ajax({
  205. url: '{:url("file_manager/uploadimg")}',
  206. type: 'POST',
  207. async: true,
  208. cache: false,
  209. data: formData,
  210. processData: false,
  211. contentType: false,
  212. dataType: "json",
  213. beforeSend: function () {
  214. // loadIndex = layer.load();
  215. },
  216. success: function (res) {
  217. if (res.code == 0) {
  218. // layer.close(loadIndex);
  219. console.log(res);
  220. var img = res.picture_url + res.picname;
  221. window.parent.$("#" + res.img_id).val(img);
  222. if (res.thumbname) {
  223. img = res.picture_url + res.thumbname;
  224. window.parent.$("#thumb").val(img);
  225. }
  226. window.parent.$("#view-" + res.img_id).attr('src', img);
  227. layer_close();
  228. } else {
  229. // layer.close(loadIndex);
  230. layer.msg(res.msg, {
  231. icon: 5,
  232. time: 1000
  233. });
  234. return false;
  235. }
  236. }
  237. });
  238. }
  239. }
  240. // 网络图片
  241. function uploadUrlImg() {
  242. if ($("#url_file").val() == '') {
  243. layer.msg("文件地址不可以为空", {
  244. icon: 6,
  245. time: 1000
  246. });
  247. return false;
  248. } else {
  249. var formData = new FormData($("#form-uploadurlimg")[0]);
  250. $.ajax({
  251. url: '{:url("file_manager/uploadurlimg")}',
  252. type: 'POST',
  253. async: true,
  254. cache: false,
  255. data: formData,
  256. processData: false,
  257. contentType: false,
  258. dataType: "json",
  259. beforeSend: function () {
  260. // loadIndex = layer.load();
  261. },
  262. success: function (res) {
  263. if (res.code == 0) {
  264. console.log(res);
  265. // layer.close(loadIndex);
  266. var img = res.picture_url + res.picname;
  267. window.parent.$("#" + res.img_id).val(img);
  268. if (res.thumbname) {
  269. img = res.picture_url + res.thumbname;
  270. window.parent.$("#thumb").val(img);
  271. }
  272. window.parent.$("#view-" + res.img_id).attr('src', img);
  273. layer_close();
  274. } else {
  275. // layer.close(loadIndex);
  276. layer.msg(res.msg, {
  277. icon: 5,
  278. time: 1000
  279. });
  280. return false;
  281. }
  282. }
  283. });
  284. }
  285. }
  286. function uploadOnlineImg() {
  287. if ($("#online_file").val() == '') {
  288. layer.msg("文件地址不可以为空", {
  289. icon: 6,
  290. time: 1000
  291. });
  292. return false;
  293. } else {
  294. var formData = new FormData($("#form-uploadonlineimg")[0]);
  295. $.ajax({
  296. url: '{:url("file_manager/uploadonlineimg")}',
  297. type: 'POST',
  298. async: true,
  299. cache: false,
  300. data: formData,
  301. processData: false,
  302. contentType: false,
  303. dataType: "json",
  304. beforeSend: function () {
  305. // loadIndex = layer.load();
  306. },
  307. success: function (res) {
  308. if (res.code == 0) {
  309. // console.log(res);
  310. // layer.close(loadIndex);
  311. var img = res.picname;
  312. window.parent.$("#" + res.img_id).val(img);
  313. if (res.thumbname) {
  314. img = res.thumbname;
  315. window.parent.$("#thumb").val(img);
  316. }
  317. window.parent.$("#view-" + res.img_id).attr('src', img);
  318. layer_close();
  319. } else {
  320. // layer.close(loadIndex);
  321. layer.msg(res.msg, {
  322. icon: 5,
  323. time: 1000
  324. });
  325. return false;
  326. }
  327. }
  328. });
  329. }
  330. }
  331. </script>
  332. <!--请在上方写此页面业务相关的脚本-->
  333. =======
  334. <div id="tab-img" class="HuiTab">
  335. <div class="tabBar clearfix">
  336. <span>本地上传</span>
  337. <span>网络文件上传</span>
  338. <span>服务器图片选择</span>
  339. <input type="hidden" name="layer" id="layer" value="{$layer}">
  340. <input type="hidden" name="infoid" value={$infoid}>
  341. <input type="hidden" name="cjid" value={$cjid}>
  342. </div>
  343. <!-- 本地上传 -->
  344. <div class="tabCon">
  345. <div class="step1 active" style="margin-left:30px;">
  346. <form id="form-uploadimg" method="post" action="" enctype="multipart/form-data">
  347. <div class="row cl" style="margin-top:20px;">
  348. <label class="form-label col-xs-2 col-sm-2"><span class="c-red">*</span>图片要求: </label>
  349. <div class="formControls col-xs-8 col-sm-8">
  350. 格式 jpg,png,gif,jpeg,webp; 大小不超过4M.
  351. </div>
  352. <div class="col-3"> </div>
  353. </div>
  354. <div class="row cl" style="margin-top:20px;">
  355. <label class="form-label col-xs-2 col-sm-2">
  356. <span class="c-red">*</span>本地上传:</label>
  357. <div class="formControls col-xs-8 col-sm-8">
  358. <input type="file" class="input-text" name="upload_file" id="upload_file">
  359. </div>
  360. <div class="col-3"> </div>
  361. </div>
  362. <div class="row cl" style="margin-top:20px;">
  363. <input type="hidden" name="img_id" value={$img_id}>
  364. <input type="hidden" name="infoid" value={$infoid}>
  365. <input type="hidden" name="cjid" value={$cjid}>
  366. <div class="formControls col-sm-12">
  367. <div class="skin-minimal">
  368. <div class="check-box">
  369. <input type="checkbox" name="thumb" value="true" {$thumb ? 'checked' : "" }>
  370. <label for="thumb-1">缩略图</label>
  371. <input type="text" class="input-text" name="width" value={$width}
  372. style="width: 80px;">缩略图宽度
  373. <input type="text" class="input-text" name="height" value={$height}
  374. style="width: 80px;">缩略图高度
  375. <input type="checkbox" name="original" value="true" {$original ? 'checked' : "" } style="margin-left: 20px;">
  376. <label for="overwrite">保留原图</label>
  377. </div>
  378. </div>
  379. </div>
  380. </div>
  381. <div class="row cl" style="margin-top:30px;margin-left:30px;">
  382. <div class="col-xs-6 col-sm-5 col-xs-offset-2 col-sm-offset-2">
  383. <input class="btn btn-primary radius" type="button" value="&nbsp;确&nbsp;定&nbsp;"
  384. onCLick="uploadLocalImg();">
  385. <input class="btn btn-default radius" type="button" value="&nbsp;取&nbsp;消&nbsp;"
  386. onClick="layer_close();">
  387. </div>
  388. </div>
  389. </form>
  390. </div>
  391. <!-- 本地上传end -->
  392. </div>
  393. <!-- 网络图片 -->
  394. <div class="tabCon">
  395. <form id="form-uploadurlimg" method="post" action="" enctype="multipart/form-data">
  396. <div class="row cl" style="margin-top:20px;">
  397. <label class="form-label col-xs-2 col-sm-2"><span class="c-red">*</span>图片要求: </label>
  398. <div class="formControls col-xs-8 col-sm-8">
  399. 格式 jpg,png,gif,jpeg,webp; 大小不超过4M.
  400. </div>
  401. <div class="col-3"> </div>
  402. </div>
  403. <div class="row cl" style="margin-top:20px;">
  404. <label class="form-label col-xs-2 col-sm-2">
  405. <span class="c-red">*</span>图片地址:</label>
  406. <div class="formControls col-xs-8 col-sm-8">
  407. <input type="text" class="input-text" name="url_file" id="url_file">
  408. </div>
  409. <div class="col-3"> </div>
  410. </div>
  411. <div class="row cl" style="margin-top:20px;">
  412. <input type="hidden" name="img_id" value={$img_id}>
  413. <div class="formControls col-xs-12 col-sm-12">
  414. <div class="skin-minimal">
  415. <div class="check-box">
  416. <input type="checkbox" name="thumb" value="{$thumb}" {$thumb ? 'checked' : "" }>
  417. <label for="thumb-1">缩略图</label>
  418. <input type="text" class="input-text" name="width" value={$width} style="width: 80px;">缩略图宽度
  419. <input type="text" class="input-text" name="height" value={$height}
  420. style="width: 80px;">缩略图高度
  421. <input type="checkbox" name="original" value="{$original}" {$original ? 'checked' : "" } style="margin-left: 20px;">
  422. <label for="overwrite">保留原图</label>
  423. </div>
  424. </div>
  425. </div>
  426. </div>
  427. <div class="row cl" style="margin-top:30px;margin-left:30px;">
  428. <div class="col-xs-6 col-sm-5 col-xs-offset-2 col-sm-offset-2">
  429. <input class="btn btn-primary radius" type="button" value="&nbsp;确&nbsp;定&nbsp;"
  430. onCLick="uploadUrlImg()">
  431. <input class="btn btn-default radius" type="button" value="&nbsp;取&nbsp;消&nbsp;"
  432. onClick="layer_close();">
  433. </div>
  434. </div>
  435. </form>
  436. </div>
  437. <!-- 在线图片 -->
  438. <style>
  439. a.active-btn {
  440. color: #fff;
  441. background-color: #3bb4f2;
  442. border-color: #3bb4f2;
  443. }
  444. </style>
  445. <div class="tabCon">
  446. <a class="btn radius active-btn" id="database_picture"><i class="Hui-iconfont Hui-iconfont-jifen"></i>数据库模式</a>
  447. <a class="btn radius" id="directory_picture"><i class="Hui-iconfont Hui-iconfont-pages"></i> 目录模式</a>
  448. <div class="database online-picture">
  449. {include file="file_manager/database_picture" /}
  450. </div>
  451. <div class="directory online-picture" style="display: none;">
  452. {include file="file_manager/directory_picture" /}
  453. </div>
  454. <form id="form-uploadonlineimg" method="post" action="" enctype="multipart/form-data">
  455. <div class="row cl" style="margin-top:20px;">
  456. <label class="form-label col-xs-2 col-sm-2">
  457. <span class="c-red">*</span>图片地址:</label>
  458. <div class="formControls col-xs-8 col-sm-8">
  459. <input type="hidden" name="img_id" value={$img_id}>
  460. <input type="text" class="input-text" name="online_file" id="online_file">
  461. </div>
  462. <div class="col-3"> </div>
  463. </div>
  464. <div class="row cl" style="margin-top:30px;margin-left:30px;">
  465. <div class="col-xs-6 col-sm-5 col-xs-offset-2 col-sm-offset-2">
  466. <input class="btn btn-primary radius" type="button" value="&nbsp;确&nbsp;定&nbsp;"
  467. onCLick="uploadOnlineImg()">
  468. <input class="btn btn-default radius" type="button" value="&nbsp;取&nbsp;消&nbsp;"
  469. onClick="layer_close();">
  470. </div>
  471. </div>
  472. </form>
  473. </div>
  474. </div>
  475. <!--请在下方写此页面业务相关的脚本-->
  476. <script type="text/javascript">
  477. jQuery.Huitab = function (tabBar, tabCon, class_name, tabEvent, i) {
  478. var $tab_menu = $(tabBar);
  479. // 初始化操作
  480. $tab_menu.removeClass(class_name);
  481. $(tabBar).eq(i).addClass(class_name);
  482. $(tabCon).hide();
  483. $(tabCon).eq(i).show();
  484. $tab_menu.bind(tabEvent, function () {
  485. $tab_menu.removeClass(class_name);
  486. $(this).addClass(class_name);
  487. var index = $tab_menu.index(this);
  488. $(tabCon).hide();
  489. $(tabCon).eq(index).show()
  490. })
  491. }
  492. $(function () {
  493. $.Huitab("#tab-img .tabBar span", "#tab-img .tabCon", "current", "click", "0");
  494. $("#database_picture").click(function () {
  495. $(".online-picture").css('display', 'none');
  496. $(".database").css('display', 'block');
  497. $(this).addClass('active-btn');
  498. $('#directory_picture').removeClass('active-btn');
  499. });
  500. $("#directory_picture").click(function () {
  501. $(".online-picture").css('display', 'none');
  502. $(".directory").css('display', 'block');
  503. $(this).addClass('active-btn');
  504. $('#database_picture').removeClass('active-btn');
  505. });
  506. });
  507. // 本地上传图片
  508. function uploadLocalImg() {
  509. var layer = $("#layer").val();
  510. if ($("#upload_file").val() == '') {
  511. layer.msg("请选择要上传的文件", {
  512. icon: 6,
  513. time: 1000
  514. });
  515. return false;
  516. } else {
  517. var formData = new FormData($("#form-uploadimg")[0]);
  518. $.ajax({
  519. url: '{:url("file_manager/uploadLocalImg")}',
  520. type: 'POST',
  521. async: true,
  522. cache: false,
  523. data: formData,
  524. processData: false,
  525. contentType: false,
  526. dataType: "json",
  527. beforeSend: function () {
  528. // loadIndex = layer.load();
  529. },
  530. success: function (res) {
  531. if (res.code == 0) {
  532. // layer.close(loadIndex);
  533. if (layer == true) {
  534. var img = res.thumb ? res.thumb : res.picname;
  535. window.parent.$("#" + res.img_id).val(img);
  536. window.parent.$("#view-" + res.img_id).attr('src', img);
  537. layer_close();
  538. } else {
  539. layer.msg('上传成功', {
  540. icon: 1,
  541. time: 1000
  542. }, () => {
  543. window.location.reload();
  544. });
  545. }
  546. } else {
  547. // layer.close(loadIndex);
  548. layer.msg(res.msg, {
  549. icon: 5,
  550. time: 1000
  551. });
  552. return false;
  553. }
  554. }
  555. });
  556. }
  557. }
  558. // 网络图片
  559. function uploadUrlImg() {
  560. var layer = $("#layer").val();
  561. if ($("#url_file").val() == '') {
  562. layer.msg("文件地址不可以为空", {
  563. icon: 6,
  564. time: 1000
  565. });
  566. return false;
  567. } else {
  568. var formData = new FormData($("#form-uploadurlimg")[0]);
  569. $.ajax({
  570. url: '{:url("file_manager/uploadUrlImg")}',
  571. type: 'POST',
  572. async: true,
  573. cache: false,
  574. data: formData,
  575. processData: false,
  576. contentType: false,
  577. dataType: "json",
  578. beforeSend: function () {
  579. // loadIndex = layer.load();
  580. },
  581. success: function (res) {
  582. if (res.code == 0) {
  583. console.log(layer);
  584. // layer.close(loadIndex);
  585. if (layer == true) {
  586. var img = res.picname;
  587. window.parent.$("#" + res.img_id).val(img);
  588. if (res.thumbname) {
  589. img = res.thumbname;
  590. window.parent.$("#thumb").val(img);
  591. }
  592. window.parent.$("#view-" + res.img_id).attr('src', img);
  593. layer_close();
  594. } else {
  595. window.location.reload();
  596. }
  597. } else {
  598. // layer.close(loadIndex);
  599. layer.msg(res.msg, {
  600. icon: 5,
  601. time: 1000
  602. });
  603. return false;
  604. }
  605. }
  606. });
  607. }
  608. }
  609. function uploadOnlineImg() {
  610. var layer = $("#layer").val();
  611. if ($("#online_file").val() == '') {
  612. layer.msg("文件地址不可以为空", {
  613. icon: 6,
  614. time: 1000
  615. });
  616. return false;
  617. } else {
  618. var formData = new FormData($("#form-uploadonlineimg")[0]);
  619. $.ajax({
  620. url: '{:url("file_manager/uploadOnlineImg")}',
  621. type: 'POST',
  622. async: true,
  623. cache: false,
  624. data: formData,
  625. processData: false,
  626. contentType: false,
  627. dataType: "json",
  628. beforeSend: function () {
  629. // loadIndex = layer.load();
  630. },
  631. success: function (res) {
  632. // layer.close(loadIndex);
  633. if (res.code == 0) {
  634. if (layer == true) {
  635. var img = res.picname;
  636. window.parent.$("#" + res.img_id).val(img);
  637. if (res.thumbname) {
  638. img = res.thumbname;
  639. window.parent.$("#thumb").val(img);
  640. }
  641. window.parent.$("#view-" + res.img_id).attr('src', img);
  642. layer_close();
  643. } else {
  644. layer.msg('上传成功', {
  645. icon: 1,
  646. time: 1000
  647. }, () => {
  648. window.location.reload();
  649. });
  650. }
  651. } else {
  652. layer.msg(res.msg, {
  653. icon: 5,
  654. time: 1000
  655. });
  656. return false;
  657. }
  658. }
  659. });
  660. }
  661. }
  662. </script>
  663. <!--请在上方写此页面业务相关的脚本-->
  664. >>>>>>> 78b76253c8ce5873016cf837373af5e30ac80c86