From a84417c167da14c91ac3ea89d14459752754fe5d Mon Sep 17 00:00:00 2001 From: xuanchen <122383162@qq.com> Date: Fri, 26 Nov 2021 15:37:59 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=96=B0=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E6=89=93=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/index/js/plugin.js | 72 +++++++++++++----------- resources/views/article/search.blade.php | 2 +- resources/views/category/dzjs.blade.php | 8 +-- resources/views/category/fygk.blade.php | 9 ++- resources/views/category/kxyj.blade.php | 14 ++--- resources/views/category/ldbz.blade.php | 4 +- resources/views/category/left.blade.php | 2 +- resources/views/category/list.blade.php | 2 +- resources/views/category/rcdw.blade.php | 8 +-- resources/views/category/show.blade.php | 4 +- resources/views/category/xwdt.blade.php | 8 +-- resources/views/index/index.blade.php | 38 +++++++------ resources/views/layouts/app.blade.php | 2 +- 13 files changed, 90 insertions(+), 83 deletions(-) diff --git a/public/assets/index/js/plugin.js b/public/assets/index/js/plugin.js index ac11c61..335c5e2 100644 --- a/public/assets/index/js/plugin.js +++ b/public/assets/index/js/plugin.js @@ -1,32 +1,34 @@ -$('[data-href]').on('click', function(event) { +$('[data-href]').on('click', function (event) { event.preventDefault(); if ($(this).hasClass('ajax-get') || $(this).hasClass('ajax-post')) { return; } - location.href = $(this).data('href'); + window.open($(this).data('href')); + // location.href = $(this).data('href'); }); // ajax GET 请求 -$('body').on('click', '.ajax-get', function(event) { +$('body').on('click', '.ajax-get', function (event) { event.preventDefault(); if ($(this).hasClass('disabled') || $(this).attr('disabled')) { return false; - }; - var $this = $(this); - var $tips = $this.attr('tip') || '确认要执行该操作吗?'; + } + ; + var $this = $(this); + var $tips = $this.attr('tip') || '确认要执行该操作吗?'; var $target = $this.data('href') || $this.attr('href') || $this.attr('url') || $this.data('url'); if ($this.hasClass('confirm')) { - if(!confirm($tips)){ + if (!confirm($tips)) { return false; } } $.ajax({ type: "GET", url: $target, - success: function(data){ - if(data.code==1){ - updateAlert(data.msg, 'success', function() { + success: function (data) { + if (data.code == 1) { + updateAlert(data.msg, 'success', function () { if ($this.hasClass('no-refresh')) { } else if (data.url == null) { location.reload(); @@ -40,7 +42,7 @@ $('body').on('click', '.ajax-get', function(event) { updateAlert(data.msg); } }, - error: function(error){ + error: function (error) { if (error.responseJSON.message) { updateAlert(error.responseJSON.message, 'warning'); } else { @@ -51,18 +53,19 @@ $('body').on('click', '.ajax-get', function(event) { }); // ajax POST 请求 -$('body').on('click', '.ajax-post', function(event) { +$('body').on('click', '.ajax-post', function (event) { if ($(this).hasClass('disabled') || $(this).attr('disabled')) { return false; - }; + } + ; event.preventDefault(); - var $this = $(this); - var $form = $this.parents('form'); - var $tips = $this.attr('tip') || '确认要执行该操作吗?'; + var $this = $(this); + var $form = $this.parents('form'); + var $tips = $this.attr('tip') || '确认要执行该操作吗?'; var $action = $form.attr("action"); if ($this.hasClass('confirm')) { - if(!confirm($tips)){ + if (!confirm($tips)) { return false; } } @@ -73,12 +76,12 @@ $('body').on('click', '.ajax-post', function(event) { type: "POST", url: $action, data: query, - success: function(data) { + success: function (data) { if (data.code == 0) { updateAlert(data.msg); $this.removeAttr('disabled'); } else { - updateAlert(data.msg, 'success', function() { + updateAlert(data.msg, 'success', function () { if (data.url) { location.href = data.url; } else if (data.url == null) { @@ -89,11 +92,11 @@ $('body').on('click', '.ajax-post', function(event) { }); } }, - error: function(error) { + error: function (error) { $this.removeAttr('disabled'); if (error.responseJSON.errors) { var err = ''; - $.each(error.responseJSON.errors, function(i, n) { + $.each(error.responseJSON.errors, function (i, n) { // err += n + "\r\n"; updateAlert(n[0], 'warning'); return false; @@ -108,32 +111,33 @@ $('body').on('click', '.ajax-post', function(event) { }); }); -$('body').on('click', '.ajax-post-confirm', function(event) { +$('body').on('click', '.ajax-post-confirm', function (event) { if ($(this).hasClass('disabled') || $(this).attr('disabled')) { return false; - }; + } + ; event.preventDefault(); - var $this = $(this); - var $form = $this.parents('form'); + var $this = $(this); + var $form = $this.parents('form'); var $action = $form.attr("action"); - var $tips = $this.attr('tip') || '确认要执行该操作吗?'; + var $tips = $this.attr('tip') || '确认要执行该操作吗?'; var query = $form.serialize(); $this.attr('disabled', 'disabled'); layer.open({ content: $tips - ,btn: ['确定', '取消'] - ,yes: function(index){ + , btn: ['确定', '取消'] + , yes: function (index) { $.ajax({ type: "POST", url: $action, data: query, - success: function(data) { + success: function (data) { if (data.code == 0) { updateAlert(data.msg); $this.removeAttr('disabled'); } else { - updateAlert(data.msg, data.error, function() { + updateAlert(data.msg, data.error, function () { if (data.url) { location.href = data.url; } else if (data.url == null) { @@ -144,11 +148,11 @@ $('body').on('click', '.ajax-post-confirm', function(event) { }); } }, - error: function(error) { + error: function (error) { $this.removeAttr('disabled'); if (error.responseJSON.errors) { var err = ''; - $.each(error.responseJSON.errors, function(i, n) { + $.each(error.responseJSON.errors, function (i, n) { // err += n + "\r\n"; updateAlert(n[0], 'warning'); return false; @@ -166,7 +170,7 @@ $('body').on('click', '.ajax-post-confirm', function(event) { }); }); -window.updateAlert = function(text, type, callback) { +window.updateAlert = function (text, type, callback) { if (typeof type != 'string') { if (type) { type = "success"; @@ -181,7 +185,7 @@ window.updateAlert = function(text, type, callback) { showConfirmButton: false }); if (typeof callback == "function") { - setTimeout(function() { + setTimeout(function () { callback(); }, 1500) } diff --git a/resources/views/article/search.blade.php b/resources/views/article/search.blade.php index 480ca3e..6d25935 100644 --- a/resources/views/article/search.blade.php +++ b/resources/views/article/search.blade.php @@ -14,7 +14,7 @@