控制台应用,yzncms本身基于tp5.1框架,里面的队列用不了,bug,坑
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. layui.define(['layer', 'laytpl', 'form', 'element', 'util','yznForm'], function(exports) {
  2. var $ = layui.jquery,
  3. layer = layui.layer,
  4. laytpl = layui.laytpl,
  5. form = layui.form,
  6. element = layui.element,
  7. yznForm = layui.yznForm,
  8. util = layui.util,
  9. device = layui.device(),
  10. DISABLED = 'layui-btn-disabled';
  11. //阻止IE7以下访问
  12. if (device.ie && device.ie < 10) {
  13. layer.alert('如果您非得使用 IE 浏览器访问,那么请使用 IE10+');
  14. }
  15. $('.lay-tips').hover(function() {
  16. var title = $(this).attr('title');
  17. layer.tips(title, $(this))
  18. }, function() {
  19. layer.closeAll('tips')
  20. })
  21. layui.focusInsert = function(obj, str) {
  22. var result, val = obj.value;
  23. obj.focus();
  24. if (document.selection) { //ie
  25. result = document.selection.createRange();
  26. document.selection.empty();
  27. result.text = str;
  28. } else {
  29. result = [val.substring(0, obj.selectionStart), str, val.substr(obj.selectionEnd)];
  30. obj.focus();
  31. obj.value = result.join('');
  32. }
  33. };
  34. //显示当前tab
  35. if (location.hash) {
  36. element.tabChange('user', location.hash.replace(/^#/, ''));
  37. }
  38. element.on('tab(user)', function() {
  39. var othis = $(this),
  40. layid = othis.attr('lay-id');
  41. if (layid) {
  42. location.hash = layid;
  43. }
  44. });
  45. form.on('radio(type)', function(data) {
  46. var type = data.value;
  47. if (type == 'email') {
  48. $("input[name='mobile']").attr('lay-verify', '');
  49. $("input[name='email']").attr('lay-verify', 'email|required');
  50. }
  51. if (type == 'mobile') {
  52. $("input[name='email']").attr('lay-verify', '');
  53. $("input[name='mobile']").attr('lay-verify', 'phone|required');
  54. }
  55. $("div.layui-form-item[data-type]").addClass("layui-hide");
  56. $("div.layui-form-item[data-type='" + type + "']").removeClass("layui-hide");
  57. $(".btn-captcha").data("url", $(this).data("send-url")).data("type", type);
  58. });
  59. //发送验证码
  60. $(document).on("click", ".btn-captcha", function(e) {
  61. var that = this;
  62. var type = $(that).data("type") ? $(that).data("type") : 'mobile';
  63. var element = $("input[name='" + type + "']");
  64. var si = {};
  65. var data = { event: $(that).data("event") };
  66. data[type] = element.val();
  67. $(that).attr('disabled', true).text("发送中...");
  68. $.post($(that).data("url"), data, function(data) {
  69. if (data.code == 1) {
  70. var seconds = 120;
  71. si[type] = setInterval(function() {
  72. seconds--;
  73. if (seconds <= 0) {
  74. clearInterval(si[type]);
  75. $(that).removeClass("layui-btn-disabled").text("获取验证码").attr("disabled", false);
  76. } else {
  77. $(that).addClass("layui-btn-disabled").text(seconds + "秒后可发送");
  78. }
  79. }, 1000);
  80. } else {
  81. $(that).removeClass("layui-btn-disabled").text("获取验证码").attr("disabled", false);
  82. layer.msg(data.msg,{icon: 2});
  83. }
  84. })
  85. return false;
  86. })
  87. //加载特定模块
  88. if (layui.cache.page && layui.cache.page !== 'index') {
  89. var extend = {};
  90. extend[layui.cache.page] = layui.cache.page;
  91. layui.extend(extend);
  92. layui.use(layui.cache.page);
  93. }
  94. //手机设备的简单适配
  95. var treeMobile = $('.site-tree-mobile'),
  96. shadeMobile = $('.site-mobile-shade')
  97. treeMobile.on('click', function() {
  98. $('body').addClass('site-mobile');
  99. });
  100. shadeMobile.on('click', function() {
  101. $('body').removeClass('site-mobile');
  102. });
  103. exports('fly', {});
  104. });