
_ajaxHandler.getShop();
$("#search").on("click",function () {
_funcHandler.searchShop();
})
$("table").on("click",".delete",function () {
_funcHandler.delShop($(this));
})
var _funcHandler ={
searchShop:function () {
var id = $("#s-id").val();
var title =$("#s-title").val();
var date = {id:id,title:title};
_ajaxHandler.searchShop(date);
},
delShop:function (target) {
console.log($(target))
var id = $(target).attr("datainfo");
var str ="确定要删除" + $(target).closest("tr").find("span.shop").html() + " 的商家分享信息?";
bootbox.confirm({
title:"一旦删除,将无法恢复",
message: str,
buttons: {
confirm: {
label: '确定',
},
cancel: {
label: '取消',
}
},
callback: function (result) {
var date = {cid:id}
if(result == true) {
_ajaxHandler.delShop(date);
$(target).closest("tr").remove();
}
}
})
},
checkShop:function (form) {
if(form.shop_id.value ==''){
$("#shop_id").siblings("span").show();
return false;
}
if($('#preview').attr('src','')){
$(".tips").hide()
$("#preview").siblings("span").show();
return false;
}
if(form.head.value ==''){
$(".tips").hide()
$("#head").siblings("span").show();
return false;
}
if(form.title.value ==''){
$(".tips").hide()
$("#s_title").siblings("span").show();
return false;
}
if(form.brief.value ==''){
$(".tips").hide()
$("#brief").siblings("span").show();
return false;
}
return true;
},
}
var _ajaxHandler ={
getShop : function () {
$.ajax({
url: "/shop/index",
type: "post",
dataType: "json",
success: function(msg) {
}
})
},
searchShop:function (date) {
$.ajax({
url: "/shop/search",
type: "post",
data: date,
dataType: "json",
success: function(msg) {
var type = msg.Type
var cli = $('#searchInfo').find('tr');
if(type==2){
cli.each(function(i) {
$(this).css('display','table-row');
});
}else{
var cid = msg.Description.data[0].id;
cli.each(function(i) {
$(this).css('display','none');
})
cli.each(function(i) {
if($(this).attr('datainfo')==cid){
$(this).css('display','table-row');
}
});
}
}
})
},
delShop:function (date) {
$.ajax({
url: "/shop/delete",
type: "post",
data:date,
dataType: "json",
success: function(msg) {
}
})
},
}