前端的一份配置(备份)
/** CMS内容栏目等配置 **/ (function () { var URL = basePath || getCurrentBasePath(); /** * 配置项主体 */ window.CMS_CONFIG = { //当前URL 根目录 CMS_HOME_URL: URL // CMS栏目配置 ID、时间显示格式、标题限制字数、描述限制字数等 ,category: { //公司动态 companyNews: ['15'], //媒体新闻 mediaNews: ['16'], //招贤纳士 careers:['17'] } }; function getCurrentBasePath() { var curWwwPath=window.document.location.href; var pathName=window.document.location.pathname; return curWwwPath.substring(0,curWwwPath.indexOf(pathName)); } function pagination(containerId,pageObj,searchObj){ var totalCount = pageObj.totalCount; var perPageCount = pageObj.perPageCount?pageObj.perPageCount:10; var callback = pageObj.callback; var currentPage = pageObj.currentPage; $("#"+containerId).pagination(totalCount, { prev_text: " ", next_text: " ", items_per_page: perPageCount, num_display_entries: 6, current_page: currentPage, num_edge_entries: 1, callback: pageselectCallback }); function pageselectCallback(page_id, jq) { $.extend(searchObj,{curpage:page_id + 1,rows:perPageCount}); callback(searchObj,false); } } window.BH = { _URI : { list: function(cid,count){ return URL+ "/cms/arcitleListData?Random=" + Math.random() + "&categoryId=" + cid + "&rows=" + count; }, detail: function (id){ return URL + "/cms/arcitleDetail?id=" + id; } }, _Callback: function(successFn,data,objId) { if(data && data.code == 1) { successFn && successFn.call(this, data.obj || {},objId); } }, _PageInit:function(data,searchObj,callback){ var pageObj = { totalCount:data.obj.total, perPageCount: searchObj.rows, callback: callback, currentPage: searchObj.curpage-1 }; //分页 初始化 pagination("Pagination", pageObj, searchObj); }, _getJSON: function(uri,bindFn,objId){ $.getJSON(uri,function(data){ BH._Callback(bindFn,data,objId); }); }, _AJAX: function(uri,bindFn,objId,searchObj){ var opt = { type:"post", url:uri, data:{ "categoryId": searchObj.cid, "curpage":searchObj.curpage, "rows":searchObj.rows }, dataType:"json", success:function(data){ BH._Callback(bindFn,data,objId); if(searchObj.isPage) { BH._PageInit(data,searchObj,BH._AJAX); } } }; $.ajax(opt); } }; })();