var $=require("jquery"),DialogPC=require("./dialogPC.js"),Form=require("./form.js"),Convenient=require("./convenient.js"),initForm=function(){$(function(){"__env"in window&&"token"in window.__env&&$.ajaxSetup({headers:{"X-CSRF-TOKEN":window.__env.token}}),$("form").each(function(n,o){$(o).unbind("submit"),void 0!==$(o).attr("data-ajax-form")?Form.initAjax(o,DialogPC):$(o).is("[data-form-no-loading]")||Form.initCommon(o,DialogPC)})})},initConvenient=function(){Convenient.init(DialogPC)},Base={init:function(){initForm(),initConvenient()},defaultFormCallback:function(n,o){return Form.defaultCallback(n,o,DialogPC)},post:function(n,o,i){$.ajax({type:"post",url:n,dataType:"json",timeout:6e5,data:o,success:function(n){i&&i(n)},error:function(){i&&i({code:-999,msg:"请求出现错误 T_T"})}})},postSuccess:function(n,o,i,e){i=i||Base.defaultFormCallback,e=e||Base.defaultFormCallback,Base.post(n,o,function(n){Base.defaultFormCallback(n,{success:function(n){i(n)},error:function(n){e(n)}})})}};module.exports=Base;