global.js 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008
  1. //工具栏上的所有的功能按钮和下拉框,可以在new编辑器的实例时选择自己需要的重新定义
  2. window.UEDITOR_HOME_URL = __root_dir__+"/public/plugins/Ueditor/";
  3. var ueditor_toolbars = [[
  4. 'fullscreen', 'source', '|', 'undo', 'redo', '|',
  5. 'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', '|',
  6. 'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
  7. 'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
  8. 'directionalityltr', 'directionalityrtl', 'indent', '|',
  9. 'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
  10. 'link', 'unlink', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
  11. 'simpleupload', 'insertimage', 'emotion', 'insertvideo', 'attachment', 'map', 'insertframe', 'insertcode', '|',
  12. 'horizontal', 'spechars', '|',
  13. 'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
  14. 'preview', 'searchreplace', 'drafts'
  15. ]];
  16. var layer_tips; // 全局提示框的对象
  17. var ey_unknown_error = '未知错误,无法继续!';
  18. $(function(){
  19. auto_notic_tips();
  20. /**
  21. * 自动小提示
  22. */
  23. function auto_notic_tips()
  24. {
  25. var html = '<a class="ui_tips" href="javascript:void(0);" onmouseover="layer_tips = layer.tips($(this).parent().find(\'p.notic\').html(), this, {time:100000});" onmouseout="layer.close(layer_tips);">提示</a>';
  26. $.each($('dd.opt > p.notic'), function(index, item){
  27. if ($(item).html() != '') {
  28. $(item).before(html);
  29. }
  30. });
  31. }
  32. });
  33. /**
  34. * 批量复制
  35. */
  36. function func_batch_copy(obj, name)
  37. {
  38. var a = [];
  39. var k = 0;
  40. aids = '';
  41. $('input[name^='+name+']').each(function(i,o){
  42. if($(o).is(':checked')){
  43. a.push($(o).val());
  44. if (k > 0) {
  45. aids += ',';
  46. }
  47. aids += $(o).val();
  48. k++;
  49. }
  50. })
  51. if(a.length == 0){
  52. layer.alert('请至少选择一项', {icon: 2, title:false});
  53. return;
  54. }
  55. var url = $(obj).attr('data-url');
  56. //iframe窗
  57. layer.open({
  58. type: 2,
  59. title: '批量复制',
  60. fixed: true, //不固定
  61. shadeClose: false,
  62. shade: 0.3,
  63. maxmin: false, //开启最大化最小化按钮
  64. area: ['450px', '300px'],
  65. content: url
  66. });
  67. }
  68. /**
  69. * 批量删除提交
  70. */
  71. function batch_del(obj, name) {
  72. var url = $(obj).attr('data-url');
  73. var a = [];
  74. $('input[name^='+name+']').each(function(i,o){
  75. if($(o).is(':checked')){
  76. a.push($(o).val());
  77. }
  78. })
  79. if(a.length == 0){
  80. layer.alert('请至少选择一项', {icon: 2, title:false});
  81. return;
  82. }
  83. var deltype = $(obj).attr('data-deltype');
  84. if ('pseudo' == deltype) {
  85. batch_del_pseudo(obj, a);
  86. } else {
  87. title = '此操作不可恢复,确定批量删除?';
  88. btn = ['确定', '取消']; //按钮
  89. // 删除按钮
  90. layer.confirm(title, {
  91. title: false,
  92. btn: btn //按钮
  93. }, function () {
  94. layer_loading('正在处理');
  95. $.ajax({
  96. type: "POST",
  97. url: url,
  98. data: {del_id:a, _ajax:1},
  99. dataType: 'json',
  100. success: function (data) {
  101. layer.closeAll();
  102. if(data.code == 1){
  103. layer.msg(data.msg, {icon: 1});
  104. //window.location.reload();
  105. /* 生成静态页面代码 */
  106. var slice_start = url.indexOf('m=admin&c=');
  107. slice_start = parseInt(slice_start) + 10;
  108. var slice_end = url.indexOf('&a=');
  109. var ctl_name = url.slice(slice_start,slice_end);
  110. $.ajax({
  111. url:__root_dir__+"/index.php?m=home&c=Buildhtml&a=upHtml&lang="+__lang__,
  112. type:'POST',
  113. dataType:'json',
  114. data: {del_ids:a,ctl_name:ctl_name,_ajax:1},
  115. success:function(data){
  116. window.location.reload();
  117. },
  118. error: function(){
  119. window.location.reload();
  120. }
  121. });
  122. /* end */
  123. // layer.alert(data.msg, {
  124. // icon: 1,
  125. // closeBtn: 0
  126. // }, function(){
  127. // window.location.reload();
  128. // });
  129. }else{
  130. layer.alert(data.msg, {icon: 2, title:false});
  131. }
  132. },
  133. error:function(){
  134. layer.closeAll();
  135. layer.alert(ey_unknown_error, {icon: 2, title:false});
  136. }
  137. });
  138. }, function (index) {
  139. layer.closeAll(index);
  140. });
  141. }
  142. }
  143. /**
  144. * 批量删除-针对临时存放在回收站的数据
  145. */
  146. function batch_del_pseudo(obj, a) {
  147. var url = $(obj).attr('data-url');
  148. // 删除按钮
  149. layer.confirm('将批量删除文档,请选择操作?', {
  150. title: false,
  151. btn: ['彻底删除', '放入回收站'] //按钮
  152. }, function () {
  153. layer_loading('正在处理');
  154. $.ajax({
  155. type: "POST",
  156. url: url,
  157. data: {del_id:a, thorough:1, _ajax:1},
  158. dataType: 'json',
  159. success: function (data) {
  160. layer.closeAll();
  161. if(data.code == 1){
  162. layer.msg(data.msg, {icon: 1});
  163. /* 生成静态页面代码 */
  164. var slice_start = url.indexOf('m=admin&c=');
  165. slice_start = parseInt(slice_start) + 10;
  166. var slice_end = url.indexOf('&a=');
  167. var ctl_name = url.slice(slice_start,slice_end);
  168. $.ajax({
  169. url:__root_dir__+"/index.php?m=home&c=Buildhtml&a=upHtml&lang="+__lang__,
  170. type:'POST',
  171. dataType:'json',
  172. data: {del_ids:a,ctl_name:ctl_name,_ajax:1},
  173. success:function(data){
  174. window.location.reload();
  175. },
  176. error: function(){
  177. window.location.reload();
  178. }
  179. });
  180. /* end */
  181. }else{
  182. layer.alert(data.msg, {icon: 2, title:false});
  183. }
  184. },
  185. error:function(){
  186. layer.closeAll();
  187. layer.alert(ey_unknown_error, {icon: 2, title:false});
  188. }
  189. });
  190. }, function (index) {
  191. layer_loading('正在处理');
  192. $.ajax({
  193. type: "POST",
  194. url: url,
  195. data: {del_id:a, _ajax:1},
  196. dataType: 'json',
  197. success: function (data) {
  198. layer.closeAll();
  199. if(data.code == 1){
  200. layer.msg(data.msg, {icon: 1});
  201. /* 生成静态页面代码 */
  202. var slice_start = url.indexOf('m=admin&c=');
  203. slice_start = parseInt(slice_start) + 10;
  204. var slice_end = url.indexOf('&a=');
  205. var ctl_name = url.slice(slice_start,slice_end);
  206. $.ajax({
  207. url:__root_dir__+"/index.php?m=home&c=Buildhtml&a=upHtml&lang="+__lang__,
  208. type:'POST',
  209. dataType:'json',
  210. data: {del_ids:a,ctl_name:ctl_name,_ajax:1},
  211. success:function(data){
  212. window.location.reload();
  213. },
  214. error: function(){
  215. window.location.reload();
  216. }
  217. });
  218. /* end */
  219. }else{
  220. layer.alert(data.msg, {icon: 2, title:false});
  221. }
  222. },
  223. error:function(){
  224. layer.closeAll();
  225. layer.alert(ey_unknown_error, {icon: 2, title:false});
  226. }
  227. });
  228. });
  229. }
  230. /**
  231. * 单个删除
  232. */
  233. function delfun(obj) {
  234. var url = $(obj).attr('data-url');
  235. var deltype = $(obj).attr('data-deltype');
  236. if ('pseudo' == deltype) {
  237. delfun_pseudo(obj);
  238. } else {
  239. title = '此操作不可恢复,确定删除?';
  240. btn = ['确定', '取消']; //按钮
  241. layer.confirm(title, {
  242. title: false,
  243. btn: btn //按钮
  244. }, function(){
  245. // 确定
  246. layer_loading('正在处理');
  247. $.ajax({
  248. type : 'POST',
  249. url : url,
  250. data : {del_id:$(obj).attr('data-id'), _ajax:1},
  251. dataType : 'json',
  252. success : function(data){
  253. layer.closeAll();
  254. if(data.code == 1){
  255. layer.msg(data.msg, {icon: 1});
  256. //window.location.reload();
  257. /* 生成静态页面代码 */
  258. var slice_start = url.indexOf('m=admin&c=');
  259. slice_start = parseInt(slice_start) + 10;
  260. var slice_end = url.indexOf('&a=');
  261. var ctl_name = url.slice(slice_start,slice_end);
  262. $.ajax({
  263. url:__root_dir__+"/index.php?m=home&c=Buildhtml&a=upHtml&lang="+__lang__,
  264. type:'POST',
  265. dataType:'json',
  266. data: {del_ids:$(obj).attr('data-id'),ctl_name:ctl_name,_ajax:1},
  267. success:function(data){
  268. window.location.reload();
  269. },
  270. error: function(){
  271. window.location.reload();
  272. }
  273. });
  274. /* end */
  275. }else{
  276. layer.alert(data.msg, {icon: 2, title:false});
  277. }
  278. },
  279. error:function(){
  280. layer.closeAll();
  281. layer.alert(ey_unknown_error, {icon: 2, title:false});
  282. }
  283. })
  284. }, function(index){
  285. layer.close(index);
  286. return false;// 取消
  287. }
  288. );
  289. }
  290. }
  291. /**
  292. * 单个删除-针对临时存放在回收站的数据
  293. */
  294. function delfun_pseudo(obj) {
  295. var url = $(obj).attr('data-url');
  296. layer.confirm('将删除该文档,请选择操作?', {
  297. title: false,
  298. btn: ['彻底删除', '放入回收站'] //按钮
  299. }, function(){
  300. // 直接删除
  301. layer_loading('正在处理');
  302. $.ajax({
  303. type : 'POST',
  304. url : url,
  305. data : {del_id:$(obj).attr('data-id'), thorough:1, _ajax:1},
  306. dataType : 'json',
  307. success : function(data){
  308. layer.closeAll();
  309. if(data.code == 1){
  310. layer.msg(data.msg, {icon: 1});
  311. /* 生成静态页面代码 */
  312. var slice_start = url.indexOf('m=admin&c=');
  313. slice_start = parseInt(slice_start) + 10;
  314. var slice_end = url.indexOf('&a=');
  315. var ctl_name = url.slice(slice_start,slice_end);
  316. $.ajax({
  317. url:__root_dir__+"/index.php?m=home&c=Buildhtml&a=upHtml&lang="+__lang__,
  318. type:'POST',
  319. dataType:'json',
  320. data: {del_ids:$(obj).attr('data-id'),ctl_name:ctl_name,_ajax:1},
  321. success:function(data){
  322. window.location.reload();
  323. },
  324. error: function(){
  325. window.location.reload();
  326. }
  327. });
  328. /* end */
  329. }else{
  330. layer.alert(data.msg, {icon: 2, title:false});
  331. }
  332. },
  333. error:function(){
  334. layer.closeAll();
  335. layer.alert(ey_unknown_error, {icon: 2, title:false});
  336. }
  337. })
  338. }, function(index){
  339. // 确定
  340. layer_loading('正在处理');
  341. $.ajax({
  342. type : 'POST',
  343. url : url,
  344. data : {del_id:$(obj).attr('data-id'), _ajax:1},
  345. dataType : 'json',
  346. success : function(data){
  347. layer.closeAll();
  348. if(data.code == 1){
  349. layer.msg(data.msg, {icon: 1});
  350. //window.location.reload();
  351. /* 生成静态页面代码 */
  352. var slice_start = url.indexOf('m=admin&c=');
  353. slice_start = parseInt(slice_start) + 10;
  354. var slice_end = url.indexOf('&a=');
  355. var ctl_name = url.slice(slice_start,slice_end);
  356. $.ajax({
  357. url:__root_dir__+"/index.php?m=home&c=Buildhtml&a=upHtml&lang="+__lang__,
  358. type:'POST',
  359. dataType:'json',
  360. data: {del_ids:$(obj).attr('data-id'),ctl_name:ctl_name,_ajax:1},
  361. success:function(data){
  362. window.location.reload();
  363. },
  364. error: function(){
  365. window.location.reload();
  366. }
  367. });
  368. /* end */
  369. }else{
  370. layer.alert(data.msg, {icon: 2, title:false});
  371. }
  372. },
  373. error:function(){
  374. layer.closeAll();
  375. layer.alert(ey_unknown_error, {icon: 2, title:false});
  376. }
  377. })
  378. }
  379. );
  380. }
  381. /**
  382. * 全选
  383. */
  384. function selectAll(name,obj){
  385. $('input[name*='+name+']').prop('checked', $(obj).checked);
  386. }
  387. /**
  388. * 远程/本地上传图片切换
  389. */
  390. function clickRemote(obj, id)
  391. {
  392. try {
  393. if ($(obj).is(':checked')) {
  394. $('#'+id+'_remote').show();
  395. $('.div_'+id+'_local').hide();
  396. if ($("input[name="+id+"_remote]").val().length > 0) {
  397. $("input[name=is_litpic]").attr('checked', true); // 自动勾选属性[图片]
  398. } else {
  399. $("input[name=is_litpic]").attr('checked', false); // 自动取消属性[图片]
  400. }
  401. } else {
  402. $('.div_'+id+'_local').show();
  403. $('#'+id+'_remote').hide();
  404. if ($("input[name="+id+"_local]").val().length > 0) {
  405. $("input[name=is_litpic]").attr('checked', true); // 自动勾选属性[图片]
  406. } else {
  407. $("input[name=is_litpic]").attr('checked', false); // 自动取消属性[图片]
  408. }
  409. }
  410. }catch(e){}
  411. }
  412. /**
  413. * 监听远程图片文本框的按键输入事件
  414. */
  415. function keyupRemote(obj, id)
  416. {
  417. try {
  418. var value = $(obj).val();
  419. if (value != '') {
  420. $("input[name=is_litpic]").attr('checked', true); // 自动勾选属性[图片]
  421. } else {
  422. $("input[name=is_litpic]").attr('checked', false); // 自动取消属性[图片]
  423. }
  424. }catch(e){}
  425. }
  426. /**
  427. * 批量移动操作
  428. */
  429. function batch_move(obj, name) {
  430. var url = $(obj).attr('data-url');
  431. var a = [];
  432. $('input[name^='+name+']').each(function(i,o){
  433. if($(o).is(':checked')){
  434. a.push($(o).val());
  435. }
  436. })
  437. if(a.length == 0){
  438. layer.alert('请至少选择一项', {icon: 2, title:false});
  439. return;
  440. }
  441. // 删除按钮
  442. layer.confirm('确认批量移动?', {
  443. btn: ['确定', '取消'] //按钮
  444. }, function () {
  445. layer_loading('正在处理');
  446. $.ajax({
  447. type: "POST",
  448. url: url,
  449. data: {move_id:a, _ajax:1},
  450. dataType: 'json',
  451. success: function (data) {
  452. layer.closeAll();
  453. if(data.status == 1){
  454. layer.msg(data.msg, {icon: 1});
  455. window.location.reload();
  456. }else{
  457. layer.alert(data.msg, {icon: 2, title:false});
  458. }
  459. },
  460. error:function(){
  461. layer.closeAll();
  462. layer.alert(ey_unknown_error, {icon: 2, title:false});
  463. }
  464. });
  465. }, function (index) {
  466. layer.closeAll(index);
  467. });
  468. }
  469. /**
  470. * 输入为空检查
  471. * @param name '#id' '.id' (name模式直接写名称)
  472. * @param type 类型 0 默认是id或者class方式 1 name='X'模式
  473. */
  474. function is_empty(name,type){
  475. if(type == 1){
  476. if($('input[name="'+name+'"]').val() == ''){
  477. return true;
  478. }
  479. }else{
  480. if($(name).val() == ''){
  481. return true;
  482. }
  483. }
  484. return false;
  485. }
  486. /**
  487. * 邮箱格式判断
  488. * @param str
  489. */
  490. function checkEmail(str){
  491. var reg = /^[a-z0-9]([a-z0-9\\.]*[-_]{0,4}?[a-z0-9-_\\.]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+([\.][\w_-]+){1,5}$/i;
  492. if(reg.test(str)){
  493. return true;
  494. }else{
  495. return false;
  496. }
  497. }
  498. /**
  499. * 手机号码格式判断
  500. * @param tel
  501. * @returns {boolean}
  502. */
  503. function checkMobile(tel) {
  504. var reg = /(^1[0-9]{10}$)/;
  505. if (reg.test(tel)) {
  506. return true;
  507. }else{
  508. return false;
  509. };
  510. }
  511. /*
  512. * 上传图片 后台专用
  513. * @access public
  514. * @null int 一次上传图片张图
  515. * @elementid string 上传成功后返回路径插入指定ID元素内
  516. * @path string 指定上传保存文件夹,默认存在public/upload/temp/目录
  517. * @callback string 回调函数(单张图片返回保存路径字符串,多张则为路径数组 )
  518. */
  519. var layer_GetUploadify;
  520. function GetUploadify(num,elementid,path,callback,url)
  521. {
  522. if (layer_GetUploadify){
  523. layer.close(layer_GetUploadify);
  524. }
  525. if (num > 0) {
  526. if (!url) {
  527. url = GetUploadify_url;
  528. }
  529. if (url.indexOf('?') > -1) {
  530. url += '&';
  531. } else {
  532. url += '?';
  533. }
  534. var width = '85%';
  535. var height = '85%';
  536. if ('adminlogo' == path) { // 上传后台logo
  537. width = '50%';
  538. height = '66%';
  539. }
  540. var upurl = url+'num='+num+'&input='+elementid+'&path='+path+'&func='+callback;
  541. layer_GetUploadify = layer.open({
  542. type: 2,
  543. title: '上传图片',
  544. shadeClose: false,
  545. shade: 0.3,
  546. maxmin: true, //开启最大化最小化按钮
  547. area: [width, height],
  548. content: upurl
  549. });
  550. } else {
  551. layer.alert('允许上传0张图片', {icon:2, title:false});
  552. return false;
  553. }
  554. }
  555. /*
  556. * 上传图片 在弹出窗里的上传图片
  557. * @access public
  558. * @null int 一次上传图片张图
  559. * @elementid string 上传成功后返回路径插入指定ID元素内
  560. * @path string 指定上传保存文件夹,默认存在public/upload/temp/目录
  561. * @callback string 回调函数(单张图片返回保存路径字符串,多张则为路径数组 )
  562. */
  563. var layer_GetUploadifyFrame;
  564. function GetUploadifyFrame(num,elementid,path,callback,url)
  565. {
  566. if (layer_GetUploadifyFrame){
  567. layer.close(layer_GetUploadifyFrame);
  568. }
  569. if (num > 0) {
  570. if (url.indexOf('?') > -1) {
  571. url += '&';
  572. } else {
  573. url += '?';
  574. }
  575. var upurl = url + 'num='+num+'&input='+elementid+'&path='+path+'&func='+callback;
  576. layer_GetUploadifyFrame = layer.open({
  577. type: 2,
  578. title: '上传图片',
  579. shadeClose: false,
  580. shade: 0.3,
  581. maxmin: true, //开启最大化最小化按钮
  582. area: ['85%', '85%'],
  583. content: upurl
  584. });
  585. } else {
  586. layer.alert('允许上传0张图片', {icon:2, title:false});
  587. return false;
  588. }
  589. }
  590. /*
  591. * 上传图片 后台(图片新闻)专用
  592. * @access public
  593. * @null int 一次上传图片张图
  594. * @elementid string 上传成功后返回路径插入指定ID元素内
  595. * @path string 指定上传保存文件夹,默认存在public/upload/temp/目录
  596. * @callback string 回调函数(单张图片返回保存路径字符串,多张则为路径数组 )
  597. */
  598. function GetUploadifyProduct(id,num,elementid,path,callback)
  599. {
  600. var upurl = eyou_basefile + '?m='+module_name+'&c=Uploadify&a=upload_product&aid='+id+'&num='+num+'&input='+elementid+'&path='+path+'&func='+callback;
  601. layer.open({
  602. type: 2,
  603. title: '上传图片',
  604. shadeClose: true,
  605. shade: false,
  606. maxmin: true, //开启最大化最小化按钮
  607. area: ['50%', '60%'],
  608. content: upurl
  609. });
  610. }
  611. // 获取活动剩余天数 小时 分钟
  612. //倒计时js代码精确到时分秒,使用方法:注意 var EndTime= new Date('2013/05/1 10:00:00'); //截止时间 这一句,特别是 '2013/05/1 10:00:00' 这个js日期格式一定要注意,否则在IE6、7下工作计算不正确哦。
  613. //js代码如下:
  614. function GetRTime(end_time){
  615. // var EndTime= new Date('2016/05/1 10:00:00'); //截止时间 前端路上 http://www.51xuediannao.com/qd63/
  616. var EndTime= new Date(end_time); //截止时间 前端路上 http://www.51xuediannao.com/qd63/
  617. var NowTime = new Date();
  618. var t =EndTime.getTime() - NowTime.getTime();
  619. /*var d=Math.floor(t/1000/60/60/24);
  620. t-=d*(1000*60*60*24);
  621. var h=Math.floor(t/1000/60/60);
  622. t-=h*60*60*1000;
  623. var m=Math.floor(t/1000/60);
  624. t-=m*60*1000;
  625. var s=Math.floor(t/1000);*/
  626. var d=Math.floor(t/1000/60/60/24);
  627. var h=Math.floor(t/1000/60/60%24);
  628. var m=Math.floor(t/1000/60%60);
  629. var s=Math.floor(t/1000%60);
  630. if(s >= 0)
  631. return d + '天' + h + '小时' + m + '分' +s+'秒';
  632. }
  633. /**
  634. * 获取多级联动
  635. */
  636. function get_select_options(t,next){
  637. var parent_id = $(t).val();
  638. var url = $(t).attr('data-url');
  639. if(!parent_id > 0 || url == ''){
  640. return;
  641. }
  642. url = url + '?pid='+ parent_id;
  643. $.ajax({
  644. type : "GET",
  645. url : url,
  646. data : {_ajax:1},
  647. error: function(request) {
  648. alert(ey_unknown_error);
  649. return;
  650. },
  651. success: function(v) {
  652. $('#'+next).html(v);
  653. }
  654. });
  655. }
  656. // 读取 cookie
  657. function getCookie(c_name)
  658. {
  659. if (document.cookie.length>0)
  660. {
  661. c_start = document.cookie.indexOf(c_name + "=")
  662. if (c_start!=-1)
  663. {
  664. c_start=c_start + c_name.length+1
  665. c_end=document.cookie.indexOf(";",c_start)
  666. if (c_end==-1) c_end=document.cookie.length
  667. return unescape(document.cookie.substring(c_start,c_end))
  668. }
  669. }
  670. return "";
  671. }
  672. function setCookies(name, value, time)
  673. {
  674. var cookieString = name + "=" + escape(value) + ";";
  675. if (time != 0) {
  676. var Times = new Date();
  677. Times.setTime(Times.getTime() + time);
  678. cookieString += "expires="+Times.toGMTString()+";"
  679. }
  680. document.cookie = cookieString+"path=/";
  681. }
  682. function delCookie(name){
  683. var exp=new Date();
  684. exp.setTime(exp.getTime()-1);
  685. var cval=getCookie(name);
  686. if(cval!=null){
  687. document.cookie=name+"="+cval+";expires="+exp.toGMTString() +"path=/";
  688. }
  689. }
  690. function layConfirm(msg , callback){
  691. layer.confirm(msg, {
  692. btn: ['确定','取消'] //按钮
  693. }, function(){
  694. callback();
  695. layer.closeAll();
  696. }, function(index){
  697. layer.close(index);
  698. return false;// 取消
  699. }
  700. );
  701. }
  702. function isMobile(){
  703. return "yes";
  704. }
  705. // 判断是否手机浏览器
  706. function isMobileBrowser()
  707. {
  708. var sUserAgent = navigator.userAgent.toLowerCase();
  709. var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
  710. var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
  711. var bIsMidp = sUserAgent.match(/midp/i) == "midp";
  712. var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
  713. var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
  714. var bIsAndroid = sUserAgent.match(/android/i) == "android";
  715. var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
  716. var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
  717. if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM ){
  718. return true;
  719. }else
  720. return false;
  721. }
  722. function getCookieByName(name) {
  723. var start = document.cookie.indexOf(name + "=");
  724. var len = start + name.length + 1;
  725. if ((!start) && (name != document.cookie.substring(0, name.length))) {
  726. return null;
  727. }
  728. if (start == -1)
  729. return null;
  730. var end = document.cookie.indexOf(';', len);
  731. if (end == -1)
  732. end = document.cookie.length;
  733. return unescape(document.cookie.substring(len, end));
  734. }
  735. function showErrorMsg(msg){
  736. // layer.open({content:msg,time:2000});
  737. layer.msg(msg, {icon: 2,time: 2000});
  738. }
  739. //关闭页面
  740. function CloseWebPage(){
  741. if (navigator.userAgent.indexOf("MSIE") > 0) {
  742. if (navigator.userAgent.indexOf("MSIE 6.0") > 0) {
  743. window.opener = null;
  744. window.close();
  745. } else {
  746. window.open('', '_top');
  747. window.top.close();
  748. }
  749. }
  750. else if (navigator.userAgent.indexOf("Firefox") > -1 || navigator.userAgent.indexOf("Chrome") > -1) {
  751. window.location.href = 'about:blank';
  752. } else {
  753. window.opener = null;
  754. window.open('', '_self', '');
  755. window.close();
  756. }
  757. }
  758. function getHsonLength(json){
  759. var jsonLength=0;
  760. for (var i in json) {
  761. jsonLength++;
  762. }
  763. return jsonLength;
  764. }
  765. // post提交之前,切换编辑器从【源代码】到【设计】视图
  766. function ueditorHandle()
  767. {
  768. try {
  769. var funcStr = "";
  770. $('textarea[class*="ckeditor"]').each(function(index, item){
  771. var func = $(item).data('func');
  772. if (undefined != func && func) {
  773. funcStr += func+"();";
  774. }
  775. });
  776. eval(funcStr);
  777. }catch(e){}
  778. }
  779. /**
  780. * 封装的加载层
  781. */
  782. function layer_loading(msg){
  783. ueditorHandle(); // post提交之前,切换编辑器从【源代码】到【设计】视图
  784. var loading = layer.msg(
  785. msg+'...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请勿刷新页面',
  786. {
  787. icon: 1,
  788. time: 3600000, //1小时后后自动关闭
  789. shade: [0.2] //0.1透明度的白色背景
  790. });
  791. //loading层
  792. var index = layer.load(3, {
  793. shade: [0.1,'#fff'] //0.1透明度的白色背景
  794. });
  795. return loading;
  796. }
  797. /**
  798. * 父窗口 - 封装的加载层
  799. */
  800. function parent_layer_loading(msg){
  801. var loading = parent.layer.msg(
  802. msg+'...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请勿刷新页面',
  803. {
  804. icon: 1,
  805. time: 3600000, //1小时后后自动关闭
  806. shade: [0.2] //0.1透明度的白色背景
  807. });
  808. //loading层
  809. var index = parent.layer.load(3, {
  810. shade: [0.1,'#fff'] //0.1透明度的白色背景
  811. });
  812. return loading;
  813. }
  814. function tipsText(){
  815. $('.ui-text').each(function(){
  816. var _this = $(this);
  817. var elm = _this.find('.ui-input');
  818. var txtElm = _this.find('.ui-textTips');
  819. var maxNum = _this.find('.ui-input').attr('data-num') || 500;
  820. // console.log($.support.leadingWhitespace);
  821. changeNum(elm,txtElm,maxNum,_this);
  822. if(!$.support.leadingWhitespace){
  823. _this.find('textarea').on('propertychange',function(){
  824. changeNum(elm,txtElm,maxNum,_this);
  825. });
  826. _this.find('input').on('propertychange',function(){
  827. changeNum(elm,txtElm,maxNum,_this);
  828. });
  829. } else {
  830. _this.on('input',function(){
  831. changeNum(elm,txtElm,maxNum,_this);
  832. });
  833. }
  834. });
  835. }
  836. //获取文字输出字数,可以遍历使用
  837. //txtElm动态改变的dom,maxNum获取data-num值默认为120个字,ps数字为最大字数*2
  838. function changeNum(elm,txtElm,maxNum,_this) {
  839. //汉字的个数
  840. //var str = (elm.val().replace(/\w/g, "")).length;
  841. //非汉字的个数
  842. //var abcnum = elm.val().length - str;
  843. var bigtxtElm = _this.find('.ui-big-text');
  844. total = elm.val().length;
  845. if(total <= maxNum ){
  846. texts = maxNum - total;
  847. txtElm.html('还可以输入<em>'+texts+'</em>个字符');
  848. if (bigtxtElm) {
  849. bigtxtElm.hide();
  850. }
  851. }else{
  852. texts = total - maxNum ;
  853. txtElm.html('已超出<em class="error">'+texts+'</em>个字符');
  854. if (bigtxtElm) {
  855. bigtxtElm.show();
  856. }
  857. }
  858. return ;
  859. }
  860. // 查看大图
  861. function Images(links, max_width, max_height){
  862. var img = "<img src='"+links+"'/>";
  863. $(img).load(function() {
  864. width = this.width;
  865. height = this.height;
  866. if (width > height) {
  867. if (width > max_width) {
  868. width = max_width;
  869. }
  870. width += 'px';
  871. } else {
  872. width = 'auto';
  873. }
  874. if (width < height) {
  875. if (height > max_height) {
  876. height = max_height;
  877. }
  878. height += 'px';
  879. } else {
  880. height = 'auto';
  881. }
  882. var links_img = "<img style='width:"+width+";height:"+height+";' src="+links+">";
  883. layer.open({
  884. type: 1,
  885. title: false,
  886. closeBtn: true,
  887. area: [width, height],
  888. skin: 'layui-layer-nobg', //没有背景色
  889. content: links_img
  890. });
  891. });
  892. }
  893. function gourl(url)
  894. {
  895. window.location.href = url;
  896. }
  897. // 百度自动推送
  898. function push_zzbaidu(url, type)
  899. {
  900. $.ajax({
  901. url:__root_dir__+"/index.php?m=api&c=Ajax&a=push_zzbaidu&lang="+__lang__,
  902. type:'POST',
  903. dataType:'json',
  904. data:{"url":url,"type":type,"_ajax":1},
  905. success:function(res){
  906. console.log(res.msg);
  907. },
  908. error: function(e){
  909. console.log(e);
  910. }
  911. });
  912. }
  913. // 更新sitemap.xml地图
  914. function update_sitemap(controller, action)
  915. {
  916. $.ajax({
  917. url:__root_dir__+"/index.php?m=admin&c=Ajax&a=update_sitemap&lang="+__lang__,
  918. type:'POST',
  919. dataType:'json',
  920. data:{"controller":controller,"action":action,"_ajax":1},
  921. success:function(res){
  922. console.log(res.msg);
  923. },
  924. error: function(e){
  925. console.log(e);
  926. }
  927. });
  928. }
  929. //在iframe内打开易优官网的页面
  930. function click_to_eyou_1575506523(url,title) {
  931. //iframe窗
  932. layer.open({
  933. type: 2,
  934. title: title,
  935. fixed: true, //不固定
  936. shadeClose: false,
  937. shade: 0.3,
  938. maxmin: true, //开启最大化最小化按钮
  939. area: ['80%', '80%'],
  940. content: url
  941. });
  942. }