Skip to content

Commit

Permalink
添加后台友情链接管理功能,增加审核、排序、隐藏功能
Browse files Browse the repository at this point in the history
  • Loading branch information
livisky committed Jan 23, 2017
1 parent 9384bb3 commit 834595e
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 54 deletions.
128 changes: 94 additions & 34 deletions www/static/admin/js/admin/links.js
Original file line number Diff line number Diff line change
@@ -1,56 +1,116 @@
/**
* Created by livi on 16/4/20.
*/
$(function(){

$('.delete').bind('click', function () {
var delId = $(this).attr("del-id");
var delids=[];
delids.push(delId);
var r = confirm("确定删除?");
if (r) {
$(function() {

$("#savetag").click(function() {
var newData = {
id: $("#tid").val(),
domain: $(".domain").val(),
link: $(".link").val(),
logo: $(".logo").val(),
qq: $(".qq").val(),
flag: $("#tagselect").val(),
orders: $(".orders").val(),
__CSRF__: G_csrf
}
$.ajax({
url: '/admin/links/delsome',
data: {delarr:delids,__CSRF__: G_csrf},
url: '/admin/links/save',
data: newData,
type: 'POST',
success: function (json) {
success: function(json) {
if (json.errno === 0) {
alert("删除成功!");
window.location.href = "/admin/links";
}else{
alert("保存成功!");
window.location.href = "/admin/links/list"
} else {
alert(json.errmsg)
}
}
})
} else {
}
})
})

//批量删除
var delsome=function(){
var delids=[];
$.each($('input[type="checkbox"]','tbody'),function(i,item){
if($(item).is(':checked')){
delids.push($(this).val());
}
})
var r = confirm("确定删除?");
if (r) {
// 删除/批量删除接口
$('.delete').bind('click', function() {
var delId = $(this).attr("del-id");
var delids = [];
delids.push(delId);
var r = confirm("确定删除?");
if (r) {
$.ajax({
url: '/admin/links/delsome',
data: { delarr: delids, __CSRF__: G_csrf },
type: 'POST',
success: function(json) {
if (json.errno === 0) {
alert("删除成功!");
window.location.href = "/admin/links";
} else {
alert(json.errmsg)
}
}
})
} else {}
})
// 显示该友情链接
$(".toshow").on('click', function() {
var tid = $(this).attr("tid");
$.ajax({
url: '/admin/links/delsome',
data: {delarr:delids,__CSRF__: G_csrf},
url: '/admin/links/upstatus',
data: { id: tid, flag: 1, __CSRF__: G_csrf },
type: 'POST',
success: function (json) {
success: function(json) {
if (json.errno === 0) {
alert("删除成功!");
alert("更新成功!");
window.location.href = "/admin/links";
}else{
} else {
alert(json.errmsg)
}
}
})
} else {
return false
})
// 隐藏该友情链接
$(".tohide").on('click', function() {
var tid = $(this).attr("tid");
$.ajax({
url: '/admin/links/upstatus',
data: { id: tid, flag: 0, __CSRF__: G_csrf },
type: 'POST',
success: function(json) {
if (json.errno === 0) {
alert("更新成功!");
window.location.href = "/admin/links/list";
} else {
alert(json.errmsg)
}
}
})
})
})

//批量删除
var delsome = function() {
var delids = [];
$.each($('input[type="checkbox"]', 'tbody'), function(i, item) {
if ($(item).is(':checked')) {
delids.push($(this).val());
}
})
var r = confirm("确定删除?");
if (r) {
$.ajax({
url: '/admin/links/delsome',
data: { delarr: delids, __CSRF__: G_csrf },
type: 'POST',
success: function(json) {
if (json.errno === 0) {
alert("删除成功!");
window.location.href = "/admin/links";
} else {
alert(json.errmsg)
}
}
})
} else {
return false
}
}
39 changes: 19 additions & 20 deletions www/static/admin/js/admin/system_base.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
$(function(){
$("#savetag").click(function(){
var newData={
sitename:$(".sitename").val(),
url:$(".url").val(),
keywords:$(".keywords").val(),
description:$(".description").val(),
author:$(".author").val(),
copyright:$(".copyright").val(),
links:$(".links").val(),
theme:$(".theme").val(),
tongji:$(".tongji").val(),
__CSRF__:G_csrf
$(function() {
$("#savetag").click(function() {
var newData = {
sitename: $(".sitename").val(),
url: $(".url").val(),
keywords: $(".keywords").val(),
description: $(".description").val(),
author: $(".author").val(),
copyright: $(".copyright").val(),
theme: $(".theme").val(),
tongji: $(".tongji").val(),
__CSRF__: G_csrf
}
$.ajax({
url:'/admin/system/edit',
data:newData,
type:'POST',
success:function(json){
if(json.errno===0){
url: '/admin/system/edit',
data: newData,
type: 'POST',
success: function(json) {
if (json.errno === 0) {
alert("保存成功!");
window.location.href="/admin/system"
window.location.href = "/admin/system"
}
}
})
})

})
})

0 comments on commit 834595e

Please sign in to comment.