/* |-------------------------------------------------------------------------- | SkyCaiji (蓝天采集器) |-------------------------------------------------------------------------- | Copyright (c) 2018 https://www.skycaiji.com All rights reserved. |-------------------------------------------------------------------------- | 使用协议 https://www.skycaiji.com/licenses |-------------------------------------------------------------------------- */ 'use strict';function MyStoreClass(){} MyStoreClass.prototype={constructor:MyStoreClass,init_rules:function(){var $_o=this;$('table.datatable thead th[data-order]').bind('click',function(){var order=$(this).attr('data-order');if(!order){return!1} var className=$(this).attr('class');var sort='desc';if(className=='sorting_desc'){sort='asc'} window.location.href=ulink('mystore/rule?order='+order+'&sort='+sort);return!1});$('#deleteall').bind('click',function(){var obj=$(this);confirmRight(window.tpl_lang.confirm_delete,function(){ajaxOpen({type:"POST",url:ulink('mystore/ruleOp?op=deleteall'),dataType:"json",data:$('#form_list').serialize(),success:function(data){data.code==1?toastr.success(data.msg):toastr.error(data.msg);window.setTimeout("window.location.reload();",2500)}})})});$('#list_table .delete').bind('click',function(){var obj=$(this);confirmRight(window.tpl_lang.confirm_delete,function(){ajaxOpen({type:"GET",url:obj.attr('url'),dataType:"json",success:function(data){data.code==1?toastr.success(data.msg):toastr.error(data.msg);if(data.code==1){obj.parents('tr').eq(0).remove()}}})})});$('#list_table').on('click','.store-detail',function(){globalOp.openStoreUrl($(this).attr('data-url'))});$('#check_update').bind('click',function(){$_o.check_rules_update()});$('#auto_check').bind('click',function(){var auto=$(this).is(':checked')?1:0;ajaxOpen({type:"GET",url:ulink('mystore/ruleOp?op=auto_check&auto='+auto),dataType:"json",success:function(data){data.code==1?toastr.success(data.msg):toastr.error(data.msg)}})});if($('#auto_check').is(':checked')){$_o.check_rules_update()}},check_rules_update:function(){var ids=new Array();$('#list_table').find('tr[data-rule-id]').each(function(){ids.push($(this).attr('data-rule-id'))});if(ids.length>0){$('.nav-check-update #check_update').html('
正在检测更新');$('.store-detail').find('.new-version').remove();ajaxOpen({type:"get",url:ulink('mystore/ruleOp?op=check_store_update'),dataType:"json",async:!0,data:{ids:ids},success:function(data){if(data.code==1){for(var id in data.data){var storeDetail=$('tr[data-rule-id="'+data.data[id]+'"]').find('.store-detail');storeDetail.append('新')}}},complete:function(){$('.nav-check-update #check_update').html('检测更新')}})}},init_releaseapp:function(){var $_o=this;$('table.datatable thead th[data-order]').bind('click',function(){var order=$(this).attr('data-order');if(!order){return!1} var className=$(this).attr('class');var sort='desc';if(className=='sorting_desc'){sort='asc'} window.location.href=ulink('mystore/releaseApp?order='+order+'&sort='+sort);return!1});$('#deleteall').bind('click',function(){var obj=$(this);confirmRight(window.tpl_lang.confirm_delete,function(){ajaxOpen({type:"POST",url:ulink('mystore/releaseAppOp?op=deleteall'),dataType:"json",data:$('#form_list').serialize(),success:function(data){data.code==1?toastr.success(data.msg):toastr.error(data.msg);window.setTimeout("window.location.reload();",2500)}})})});$('#list_table .delete').bind('click',function(){var obj=$(this);confirmRight(window.tpl_lang.confirm_delete,function(){ajaxOpen({type:"GET",url:obj.attr('url'),dataType:"json",success:function(data){data.code==1?toastr.success(data.msg):toastr.error(data.msg);if(data.code==1){obj.parents('tr').eq(0).remove()}}})})});$('#list_table').on('click','.store-detail',function(){globalOp.openStoreUrl($(this).attr('data-url'))});$('#check_update').bind('click',function(){$_o.check_releaseapp_update()});$('#auto_check').bind('click',function(){var auto=$(this).is(':checked')?1:0;ajaxOpen({type:"GET",url:ulink('mystore/releaseAppOp?op=auto_check&auto='+auto),dataType:"json",success:function(data){data.code==1?toastr.success(data.msg):toastr.error(data.msg)}})});if($('#auto_check').is(':checked')){$_o.check_releaseapp_update()}},check_releaseapp_update:function(){var ids=new Array();$('#list_table').find('tr[data-app-id]').each(function(){ids.push($(this).attr('data-app-id'))});if(ids.length>0){$('.nav-check-update #check_update').html(' 正在检测更新');$('.store-detail').find('.new-version').remove();ajaxOpen({type:"get",url:ulink('mystore/releaseAppOp?op=check_store_update'),dataType:"json",async:!0,data:{ids:ids},success:function(data){if(data.code==1){for(var id in data.data){var storeDetail=$('tr[data-app-id="'+data.data[id]+'"]').find('.store-detail');storeDetail.append('新')}}},complete:function(){$('.nav-check-update #check_update').html('检测更新')}})}},init_funcapp:function(){var $_o=this;$('table.datatable thead th[data-order]').bind('click',function(){var order=$(this).attr('data-order');if(!order){return!1} var className=$(this).attr('class');var sort='desc';if(className=='sorting_desc'){sort='asc'} window.location.href=ulink('mystore/funcApp?order='+order+'&sort='+sort);return!1});$('#deleteall').bind('click',function(){var obj=$(this);confirmRight(window.tpl_lang.confirm_delete,function(){ajaxOpen({type:"POST",url:ulink('mystore/funcAppOp?op=deleteall'),dataType:"json",data:$('#form_list').serialize(),success:function(data){data.code==1?toastr.success(data.msg):toastr.error(data.msg);window.setTimeout("window.location.reload();",2500)}})})});$('#list_table .delete').bind('click',function(){var obj=$(this);var id=$(this).parents('tr[data-app-id]').attr('data-app-id');confirmRight(window.tpl_lang.confirm_delete,function(){ajaxOpen({type:"GET",url:ulink('mystore/funcAppOp?op=delete'),dataType:"json",data:{id:id},success:function(data){data.code==1?toastr.success(data.msg):toastr.error(data.msg);if(data.code==1){obj.parents('tr').eq(0).remove()}}})})});$('#list_table .enable').bind('click',function(){var obj=$(this);var id=$(this).parents('tr[data-app-id]').attr('data-app-id');var enable=$(this).attr('data-val');enable=(enable==1)?0:1;ajaxOpen({type:'GET',url:ulink('mystore/funcAppOp?op=enable'),dataType:'json',data:{id:id,enable:enable},success:function(data){if(data.code){obj.attr('data-val',enable?1:0);obj.text(enable?'已启用':'已禁用');obj.css('color',(enable?'green':'red'))}else{toastr.error(data.msg)}}})});$('#list_table .methods .dropdown-toggle').bind('click',function(){var obj=$(this);var id=$(this).parents('tr[data-app-id]').attr('data-app-id');var box=obj.parents('.methods');box.find('.dropdown-menu').html('