common.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. $(function () {
  2. /**
  3. * 打开app
  4. */
  5. $('.ect-open-app').click(function () {
  6. location.href = '/wechat/openApp';
  7. });
  8. });
  9. /**
  10. * 页面重定向
  11. * @param url
  12. * @param data
  13. */
  14. function redirect(url, data = null, e = null) {
  15. if (e) {
  16. e.stopPropagation();
  17. }
  18. if (data) {
  19. $.each(data, function (i, item) {
  20. url += '/' + item;
  21. });
  22. console.log(url);
  23. }
  24. location.href = url;
  25. }
  26. /**
  27. * 切换导航
  28. * @param obj
  29. */
  30. function switchNav(obj) {
  31. obj.addClass('active').siblings().removeClass('active');
  32. }
  33. /**
  34. * 打开隐藏模块
  35. * @param obj
  36. * @param hideObj
  37. */
  38. function openHideDiv(obj, hideObj = []) {
  39. $('body,html').addClass('ect-overflow-hidden');
  40. $.each(obj, function (i, item) {
  41. $(item).show();
  42. });
  43. if (hideObj.length > 0) {
  44. $.each(hideObj, function (i, item) {
  45. $(item).hide();
  46. });
  47. }
  48. }
  49. /**
  50. * 隐藏打开的模块
  51. * @param obj
  52. * @param openObj
  53. */
  54. function closeOpenDiv(obj, openObj = []) {
  55. $('body,html').removeClass('ect-overflow-hidden');
  56. $.each(obj, function (i, item) {
  57. $(item).hide();
  58. });
  59. if (openObj.length > 0) {
  60. $.each(openObj, function (i, item) {
  61. $(item).show();
  62. });
  63. }
  64. }
  65. /**
  66. * 复制输入框内容
  67. * @param obj
  68. * @param msg
  69. */
  70. function copyInputValue(obj, msg = '复制成功') {
  71. var input = document.getElementById(obj);
  72. input.setAttribute('readonly', 'readonly');
  73. input.setSelectionRange(0, input.value.length);
  74. input.select();
  75. try {
  76. document.execCommand('copy', true);
  77. layer.msg(msg);
  78. } catch (err) {
  79. layer.msg('复制失败');
  80. }
  81. }