微调
This commit is contained in:
188
public/assets/index/js/plugin.js
Normal file
188
public/assets/index/js/plugin.js
Normal file
@@ -0,0 +1,188 @@
|
||||
$('[data-href]').on('click', function(event) {
|
||||
event.preventDefault();
|
||||
if ($(this).hasClass('ajax-get') || $(this).hasClass('ajax-post')) {
|
||||
return;
|
||||
}
|
||||
location.href = $(this).data('href');
|
||||
});
|
||||
|
||||
// ajax GET 请求
|
||||
$('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 $target = $this.data('href') || $this.attr('href') || $this.attr('url') || $this.data('url');
|
||||
|
||||
if ($this.hasClass('confirm')) {
|
||||
if(!confirm($tips)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: $target,
|
||||
success: function(data){
|
||||
if(data.code==1){
|
||||
updateAlert(data.msg, 'success', function() {
|
||||
if ($this.hasClass('no-refresh')) {
|
||||
} else if (data.url == null) {
|
||||
location.reload();
|
||||
} else if (data.url) {
|
||||
location.href = data.url + '?_=' + (new Date()).getTime();
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
updateAlert(data.msg);
|
||||
}
|
||||
},
|
||||
error: function(error){
|
||||
if (error.responseJSON.message) {
|
||||
updateAlert(error.responseJSON.message, 'warning');
|
||||
} else {
|
||||
updateAlert('发生未知错误', 'warning');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// ajax POST 请求
|
||||
$('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 $action = $form.attr("action");
|
||||
if ($this.hasClass('confirm')) {
|
||||
if(!confirm($tips)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$this.attr('disabled', 'disabled');
|
||||
var query = $form.serialize();
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: $action,
|
||||
data: query,
|
||||
success: function(data) {
|
||||
if (data.code == 0) {
|
||||
updateAlert(data.msg);
|
||||
$this.removeAttr('disabled');
|
||||
} else {
|
||||
updateAlert(data.msg, 'success', function() {
|
||||
if (data.url) {
|
||||
location.href = data.url;
|
||||
} else if (data.url == null) {
|
||||
location.reload();
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function(error) {
|
||||
$this.removeAttr('disabled');
|
||||
if (error.responseJSON.errors) {
|
||||
var err = '';
|
||||
$.each(error.responseJSON.errors, function(i, n) {
|
||||
// err += n + "\r\n";
|
||||
updateAlert(n[0], 'warning');
|
||||
return false;
|
||||
})
|
||||
// updateAlert(err, 'warning');
|
||||
} else if (error.responseJSON.message) {
|
||||
updateAlert(error.responseJSON.message, 'warning');
|
||||
} else {
|
||||
updateAlert('发生未知错误', 'warning');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('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 $action = $form.attr("action");
|
||||
var $tips = $this.attr('tip') || '确认要执行该操作吗?';
|
||||
var query = $form.serialize();
|
||||
$this.attr('disabled', 'disabled');
|
||||
layer.open({
|
||||
content: $tips
|
||||
,btn: ['确定', '取消']
|
||||
,yes: function(index){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: $action,
|
||||
data: query,
|
||||
success: function(data) {
|
||||
if (data.code == 0) {
|
||||
updateAlert(data.msg);
|
||||
$this.removeAttr('disabled');
|
||||
} else {
|
||||
updateAlert(data.msg, data.error, function() {
|
||||
if (data.url) {
|
||||
location.href = data.url;
|
||||
} else if (data.url == null) {
|
||||
location.reload();
|
||||
} else {
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function(error) {
|
||||
$this.removeAttr('disabled');
|
||||
if (error.responseJSON.errors) {
|
||||
var err = '';
|
||||
$.each(error.responseJSON.errors, function(i, n) {
|
||||
// err += n + "\r\n";
|
||||
updateAlert(n[0], 'warning');
|
||||
return false;
|
||||
})
|
||||
// updateAlert(err, 'warning');
|
||||
} else if (error.responseJSON.message) {
|
||||
updateAlert(error.responseJSON.message, 'warning');
|
||||
} else {
|
||||
updateAlert('发生未知错误', 'warning');
|
||||
}
|
||||
}
|
||||
});
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
window.updateAlert = function(text, type, callback) {
|
||||
if (typeof type != 'string') {
|
||||
if (type) {
|
||||
type = "success";
|
||||
} else {
|
||||
type = "error";
|
||||
}
|
||||
}
|
||||
swal({
|
||||
title: text,
|
||||
type: type,
|
||||
timer: 1500,
|
||||
showConfirmButton: false
|
||||
});
|
||||
if (typeof callback == "function") {
|
||||
setTimeout(function() {
|
||||
callback();
|
||||
}, 1500)
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,11 @@
|
||||
<div class="swiper-container indexBig">
|
||||
<div class="swiper-wrapper">
|
||||
@foreach (getAdvertsByCate(23) as $advert)
|
||||
@if($advert->url) data-href="" @endif
|
||||
|
||||
<div class="swiper-slide">
|
||||
<div class="ce-img indexImg-img">
|
||||
<div class="ce-img indexImg-img"
|
||||
@if($advert->url) data-href="{{ $advert->url }}" @endif>
|
||||
<span style="background-image: url({{ $advert->cover_path }});"></span>
|
||||
<div class="ce-nowrap indexImg-title">
|
||||
{{ $advert->title }}
|
||||
@@ -146,7 +149,8 @@
|
||||
@if (getArticlesBYCate(24,5,'all',false,'asc')->isNotEmpty())
|
||||
@foreach (getArticlesBYCate(24,5) as $article)
|
||||
@if($loop->index==4)
|
||||
<a href="{{ $article->link }}" class="indexBuild-new" title="{{ $article->title }}">
|
||||
<a href="{{ $article->link }}" class="indexBuild-new"
|
||||
title="{{ $article->title }}">
|
||||
<div class="indexBuild-icon">
|
||||
<img src="/assets/index/images/Build_icon05.png">
|
||||
</div>
|
||||
@@ -228,7 +232,8 @@
|
||||
<div class="col-xs-12 col-md-3 indexflow-img">
|
||||
@if (getAdvertsByCate(21,2)->isNotEmpty())
|
||||
@foreach (getAdvertsByCate(21,2) as $advert)
|
||||
<a href="{{ $advert->url ?? 'javascript:void(0);' }}"><img src="{{ $advert->cover_path }}"/></a>
|
||||
<a href="{{ $advert->url ?? 'javascript:void(0);' }}"><img
|
||||
src="{{ $advert->cover_path }}"/></a>
|
||||
@endforeach
|
||||
@endif
|
||||
</div>
|
||||
@@ -287,7 +292,8 @@
|
||||
@if (getArticlesBYCate(12,5)->isNotEmpty())
|
||||
@foreach (getArticlesBYCate(12,5) as $article)
|
||||
<li>
|
||||
<a href="{{ $article->link }}" title="{{ $article->title }}">
|
||||
<a href="{{ $article->link }}"
|
||||
title="{{ $article->title }}">
|
||||
<div class="ce-nowrap-multi indexNews-ul-name">
|
||||
{{ $article->title }}
|
||||
</div>
|
||||
@@ -304,7 +310,8 @@
|
||||
@if (getArticlesBYCate(30,5)->isNotEmpty())
|
||||
@foreach (getArticlesBYCate(30,5) as $article)
|
||||
<li>
|
||||
<a href="{{ $article->link }}" title="{{ $article->title }}">
|
||||
<a href="{{ $article->link }}"
|
||||
title="{{ $article->title }}">
|
||||
<div class="ce-nowrap-multi indexNews-ul-name">
|
||||
{{ $article->title }}
|
||||
</div>
|
||||
|
||||
@@ -11,9 +11,10 @@
|
||||
<link rel="stylesheet" type="text/css" href="{{ asset('assets/index/css/swiper.min.css') }}"/>
|
||||
</head>
|
||||
|
||||
<body oncontextmenu='return false' ondragstart='return false' onselectstart='return false'
|
||||
onselect='document.selection.empty()' oncopy='document.selection.empty()' onbeforecopy='return false'
|
||||
onmouseup='document.selection.empty()'>
|
||||
{{--<body oncontextmenu='return false' ondragstart='return false' onselectstart='return false'--}}
|
||||
{{-- onselect='document.selection.empty()' oncopy='document.selection.empty()' onbeforecopy='return false'--}}
|
||||
{{-- onmouseup='document.selection.empty()'>--}}
|
||||
<body>
|
||||
<!-- 顶部 -->
|
||||
<div class="indexHead">
|
||||
<div class="container">
|
||||
@@ -62,6 +63,7 @@
|
||||
<script src="{{ asset('assets/index/js/jquery-3.2.1.min.js') }}" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="{{ asset('assets/index/js/bootstrap.min.js') }}" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="{{ asset('assets/index/js/swiper.min.js') }}" type="text/javascript" charset="utf-8"></script>
|
||||
<script src="{{ asset('assets/index/js/plugin.js') }}" type="text/javascript" charset="utf-8"></script>
|
||||
|
||||
<!-- Laytool -->
|
||||
<div class="laytool">
|
||||
|
||||
Reference in New Issue
Block a user