常用js类

常用js类:涵盖日期,弹窗,远程调用,模板使用
 
  
var AjaxRequest = {
	
};

AjaxRequest.request = function(url, params, successback, failback){
	$.ajax({
		url : url,
		data : params,
		cache:false,
		type : 'POST',
		dataType : 'json',
		success : function(data) {
			if (data && data.returnCode == '200') {
				if (successback) {
					successback(data);
				}
				return;
			}
			if (failback) {
				failback(data);
			}
		}
	});
	return true;

};

AjaxRequest.submit = function(formId,url,successback,failback){
	if (!formId) {
		alert('formId不能为空!');
		return false;
	}
	// 提交前默认值清空
	$('#' + formId).find("input[placeholder],textarea[placeholder]").each(function() {
		if ($(this).val() == $(this).attr('placeholder')) {
			$(this).val('');
		}
	});
	var rd = SysUtils.getRandom();
	if(url.indexOf('?')>=0){
		url += '&randomId='+rd;
	}else{
		url += '?randomId='+rd;
	}
	var options = {
		url : url,
		type : 'POST',
		dataType : "json",
		success : function(data) {
			if (data && data.returnCode == '200') {
				if (successback) {
					successback(data);
				}
				return true;
			}
			if (failback) {
				AjaxRequest.refereshFormToken(formId);
				failback(data);
			}
			return false;
		}
	};
	$('#' + formId).ajaxSubmit(options);
	return true;

};

AjaxRequest.getJson = function(url,params,successback,failback){
	$.ajax({
		url : url,
		data : params,
		type : 'GET',
		cache:false,
		dataType : 'json',
		success : function(data) {
			if (successback) {
				successback(data);
			}
		},
		error:function(data){
			if (failback) {
				failback(data);
			}
		}
	});
};

AjaxRequest.getText = function(url,params,successback,failback){
	$.ajax({
		url : url,
		data : params,
		cache:false,
		type : 'GET',
		success : function(data) {
			if (successback) {
				successback(data);
			}
		},
		error:function(data){
			if (failback) {
				failback(data);
			}
		}
	});
};
AjaxRequest.load = function(boxId, url, param, callBack) {
	if ($('#' + boxId).length <= 0) {
		return;
	}
	var rd = SysUtils.getRandom();
	if(url.indexOf('?')>=0){
		url += '&randomId='+rd;
	}else{
		url += '?randomId='+rd;
	}
	$('#' + boxId).load(url, param, function() {
		if (callBack) {
			callBack();
		}
	});
};
/**
 * @param options{
 * 	url: 请求数据的URL
 * 	params: 参数信息
 * 	templateId: 页面存放的模版ID(与templateUrl只能选其一,如果两个都填写优先使用templateId)
 * 	templateUrl:请求模板的url(与templateId只能选其一,如果两个都填写优先使用templateId)
 * 	templateParam:请求模板的参数(与templlateUrl对应)
 * 	targetId:  生成的html需要appendTo目标Id
 * 	dataFilter: 数据过滤fn
 *  successback: 成功回调fn
 *  failback: 失败回调
 * }
 */
AjaxRequest.render = function(options){
	var url = options.url;
	var params = options.params;
	var templateId = options.templateId;
	var templateUrl = options.templateUrl;
	var templateParam = options.templateParam;
	var targetId = options.targetId;
	var dataFilter = options.dataFilter;
	var successback = options.successback || $.noop;
	var failback = options.failback || $.noop;
	if(!url || !targetId || (!templateId && !templateUrl)){
		SysDialog.alertInfo('必传参数为空!');
		return;
	}
	if(templateId){
		AjaxRequest.request(url, params, function(resData){
			var data = dataFilter && dataFilter(resData) || resData;
			var html = template(templateId,data);
			$('#'+targetId).empty().html(html);
			SysEvent.init();
			successback(resData);
		},function(){
			failback(resData);
		});
	}else if(templateUrl){
		AjaxRequest.getText(templateUrl, templateParam, function(resTemplate){
			var render = template.compile(resTemplate);
			AjaxRequest.request(url, params, function(resData){
				var data = dataFilter && dataFilter(resData) || resData;
				$('#'+targetId).empty().html(render(data));
				SysEvent.init();
				successback(resData);
			},function(resData){
				failback(resData);
			});
		}, function(resTemplate){
			failback(resData);
		});
	}
};

/**
 * @param options{
 * 	formId: form表单ID
 * 	url:  表单提交获取数据的URL
 * 	templateId: 页面存放的模版ID(与templateUrl只能选其一,如果两个都填写优先使用templateId)
 * 	templateUrl:请求模板的url(与templateId只能选其一,如果两个都填写优先使用templateId)
 * 	templateParam:请求模板的参数(与templlateUrl对应)
 * 	targetId: 生成的html需要appendTo渲染后的模版ID
 * 	dataFilter: 数据过滤Fn
 *  successback: 成功回调Fn
 *  failback: 失败回调Fn
 * }
 */
AjaxRequest.submitRender = function(options){
	var formId = options.formId;
	var url = options.url;
	var templateId = options.templateId;
	var templateUrl = options.templateUrl;
	var templateParam = options.templateParam;
	var targetId = options.targetId;
	var dataFilter = options.dataFilter;
	var successback = options.successback || $.noop;
	var failback = options.failback || $.noop;
	if(!formId || !url || !targetId || (!templateId && !templateUrl)){
		SysDialog.alertInfo('必传参数为空!');
		return;
	}
	if(templateId){
		AjaxRequest.submit(formId,url, function(resData){
			var data = dataFilter && dataFilter(resData) || resData;
			var html = template(templateId,data);
			SysView.loaded("#"+targetId);
			$('#'+targetId).empty().html(html);
			successback();
		},failback);
	}else if(templateUrl){
		AjaxRequest.getText(templateUrl, templateParam, function(resTemplate){
			var render = template.compile(resTemplate);
			AjaxRequest.submit(formId,url, function(resData){
				var data = dataFilter && dataFilter(resData) || resData;
				$('#'+targetId).empty().html(render(data));
				SysEvent.init();
				successback();
			},failback);
		}, failback);
	}
};

/**
 * 刷新token
 */
AjaxRequest.refereshFormToken = function(formId){
	var tokenDiv = $('#'+formId).find("#sys_form_token");
	if(tokenDiv.length<=0){
		return;
	}
	var formName = tokenDiv.find('input[name="formTokenName"]').val();
	tokenDiv.remove();
	AjaxRequest.getText(BASE_PATH+'/page/com/formToken.jsp', {name:formName}, function(res){
		$('#'+formId).append(res);
	}, function(){
		SysUtils.console('get from token error!')
	});	
};

//////////////////////////ajax 初始化全局共用信息/////////////////////////////
$(function() {
	// 绑定全局的事件
	SysEvent.init();
	SysDialog.setDialog();
	//阻止滚动条滚动事件冒泡
	//$(document).scrollScope();
	//面包屑初始化
	Global.breadCrumbsInit();
	//左侧菜单初始化
	Global.leftMenuInit();
	$(document).ajaxSuccess(function(event, XMLHttpRequest, ajaxOptions) {
		if (ajaxOptions.dataType == 'json' && XMLHttpRequest != null) {
			var rs = JSON.parse(XMLHttpRequest.responseText);
			if (rs.returnType == '1') {
				// 如果returnCode=200,表示操作正常完成
				if (rs.returnCode == '200') {
					rs.returnMsg = rs.returnMsg ? rs.returnMsg : '操作成功!';
					SysDialog.alertSuccess(rs.returnMsg, true);
				} else { // 如果非等于200,代表操作失败。则给出操作失败的原因。如:因为有关系数据不能正常删除等。
					rs.returnMsg = rs.returnMsg ? rs.returnMsg : '操作失败';
					SysDialog.alertError(rs.returnMsg);
				}
			}
		}
	});
	$(document).ajaxError(function(event, jqxhr, settings, exception) {
		SysView.loaded();
		var resStatus = jqxhr.getResponseHeader('status');
		if (resStatus == '103') {
			window.location.href = BASE_PATH;
		} else if (resStatus == '106') {
			// 表单重复提交不做任何处理
		} else {
			var readyState = jqxhr.readyState - 0;
			var status = jqxhr.status;
			var statusText = jqxhr.statusText;
			typeof console != 'undefined' ? console.info('readyState:'+ readyState + ',status:' + status + ',statusText:'+ statusText) : $.noop();
			if (readyState < 3 && readyState > 0) {
				SysDialog.alertError("网络异常!");
			}
			if (readyState == 4) {
				SysDialog.alertError("后台异常!");
			}
		}
	});
});

var Global = {
	
};
//左菜单初始化
Global.leftMenuInit = function(){
	leftMenuSelectId = typeof leftMenuSelectId=='undefined'?'':leftMenuSelectId;
	if(!SysUtils.isEmpty(leftMenuSelectId)){
		var topId = leftMenuSelectId.substring(0,2);
		var $leftMenuDiv = $("div.side-inner");
		var $leftMenuSelectUl = $leftMenuDiv.find("#leftMenu_ul_" + topId);
		$leftMenuSelectUl.removeClass("hide").siblings().addClass("hide");
		var $selectedLi= $leftMenuSelectUl.find("#leftMenu_" + leftMenuSelectId);
		$selectedLi.addClass("hover");
		if($selectedLi.prev("li").length == 0) {
			$selectedLi.find('h3').addClass("first-border-top");
		}
		var $containerDiv = $selectedLi.closest("div.listview");
		if($containerDiv && $containerDiv.length > 0){
			$containerDiv.show();
			$containerDiv.closest("li").find("h3>i").removeClass("ep-side-hide").addClass("ep-side-show");
		}
		
		$leftMenuDiv.find("h3>a").each(function(index,element){
			var $this = $(element);
			if($this.attr("has-drop") == "has-drop"){
				$this.unbind("click.left").bind("click.left",function(event){
					var $innerI = $this.find("i");
					if($innerI.hasClass("ep-side-hide")){
						$innerI.removeClass("ep-side-hide").addClass("ep-side-show");
						$this.closest("li").find("div.listview").show();						
					}
					else if($innerI.hasClass("ep-side-show")){
						$innerI.removeClass("ep-side-show").addClass("ep-side-hide");
						$this.closest("li").find("div.listview").hide();
					}
				});
			}
		});		
	}
};

//面包屑初始化
Global.breadCrumbsInit = function(){
	navigationItems = typeof navigationItems=='undefined'?'':navigationItems;
	$containerBreadCrumbs = $("#container_bread_crumbs");
	if($containerBreadCrumbs && $containerBreadCrumbs.length>0 && !SysUtils.isEmpty(navigationItems)){
		navigationArray = $.parseJSON(navigationItems);
		var html = "您当前的位置 : ";
		var innerStr = "";
		for(var i = 0 ; i < navigationArray.length ; i++){
			innerStr = innerStr + "" + navigationArray[i]["name"] + "";
			if(i != navigationArray.length - 1){
				innerStr += " >> ";
			}
		}
		html += innerStr;
		$containerBreadCrumbs.html(html);
	}
};


var SysDialog = {
	TYPE_INFO:'0',
	TYPE_CONFIRM:'1',
	TYPE_SUCC:'2',
	TYPE_ERROR:'3',
	TYPE_WARNING:'4',
	dialogClass:['info','question','scuccess','danger','warning'],
	titles:['提示','确认','成功','错误','警告'],
	bodyClass:['modal-info','modal-question','modal-success','modal-danger','modal-warning'],
	iconClass:['ep-info','ep-question','ep-success','ep-danger','ep-warning'],
	btnText:['关闭','确定','关闭','关闭','关闭']
};

SysDialog.setDialog = function(){
	var backdropZIndex = 0;
	function setModalsAndBackdropsOrder(slf) {
		var modalZIndex = $('.modal.in').length + 1050 + 1;
		backdropZIndex = modalZIndex - 1;
		$(slf).css('z-index', modalZIndex);
		$('.modal-backdrop.in:last').hide();
	}
	$(document).on('show.bs.modal', '.modal', function(event) {
		var modals = $('.modal:visible');
		if(modals.length>1){
			setModalsAndBackdropsOrder(this);
		}
	}).on('shown.bs.modal', '.modal.in', function(event) {
		var modals = $('.modal:visible');
		if(modals.length>1){
			$('.modal-backdrop.in:last').css('z-index', backdropZIndex);
		}
	}).on('hidden.bs.modal', '.modal', function(event) {
		$('.modal-backdrop.in:last').show();
	});
};
SysDialog.alert = function(type,msg,autoClose,confirmCallBack,cancelCallBack){
	var $sysTipDialog = $('#sys_tip_dialog');
	if($sysTipDialog.length<=0){
		var html = '';
		$sysTipDialog = $(html);
		$('body').append($sysTipDialog);
	}
	$sysTipDialog.removeClass(SysDialog.dialogClass.join(' ')).addClass('modal fade '+SysDialog.dialogClass[type]);
	
	$sysTipDialog.find('#title').empty().html(SysDialog.titles[type]);
	
	$sysTipDialog.find('#bodyDiv').removeClass(SysDialog.bodyClass.join(' ')).addClass(SysDialog.bodyClass[type]+' modal-style');
	
	$sysTipDialog.find('#tipIcon').removeClass(SysDialog.iconClass.join(' ')).addClass('ep '+SysDialog.iconClass[type]);
	
	$sysTipDialog.find('#ctxDesc').empty().html(msg?msg:'');
	
	$sysTipDialog.find('#sure').text(SysDialog.btnText[type]);
	
	$sysTipDialog.off('show.bs.modal').on('show.bs.modal',function(){
		if(autoClose){
			$sysTipDialog.find('#header,#bottom').hide();
		}else{
			$sysTipDialog.find('#header,#bottom').show();
		}
	});
	
	$sysTipDialog.find('#bottom button').unbind();
	$sysTipDialog.find('#sure').bind('click',function(){
			$sysTipDialog.modal('hide');
			var tt = setTimeout(function(){
				clearTimeout(tt);
				confirmCallBack&&confirmCallBack();
			},500);
	});
	$sysTipDialog.find('#cancel').hide();
	if(type == SysDialog.TYPE_CONFIRM){
		$sysTipDialog.find('#cancel').show().bind('click',function(){
			$sysTipDialog.modal('hide');
			var tt = setTimeout(function(){
				clearTimeout(tt);
				cancelCallBack&&cancelCallBack();
			},500);
		});
	}
	$sysTipDialog.modal('show');
	if(autoClose){
		setTimeout(function(){
			$sysTipDialog.modal('hide');
		},1200);
	}
};
SysDialog.alertInfo = function(msg,autoClose){
	SysDialog.alert(SysDialog.TYPE_INFO,msg,autoClose);
};
SysDialog.alertError = function(msg){
	SysDialog.alert(SysDialog.TYPE_ERROR,msg);
};
SysDialog.alertSuccess = function(msg,autoClose){
	var close = autoClose!==false?true:autoClose;
	SysDialog.alert(SysDialog.TYPE_SUCC,msg,close);
};
SysDialog.alertWarning = function(msg){
	SysDialog.alert(SysDialog.TYPE_WARNING,msg);
};
SysDialog.alertConfirm = function(msg,yesFunc,noFunc){
	SysDialog.alert(SysDialog.TYPE_CONFIRM,msg,false,yesFunc,noFunc);
};
/**
 * ajax请求后台json通过模板渲染弹出框
 * @param url 请求数据url
 * @param params 参数
 * @param templateId 模板id
 * @param dataFilter 数据过滤函数需要return一个data对象给提供的模板
* function(data,$modal){//data:ajax返回数据;$modal:模态框对象 * 此回调可以绑定事件请参考:http://v3.bootcss.com/javascript/#modals-usage * $modal.on('show.bs.modal',function(){}) * } * @param targetId 弹出框生成的dom位置,默认body */ SysDialog.ajaxOpenWithTemplate = function(url,params,templateId,dataFilter,targetId){ AjaxRequest.getJson(url, parmas, function(resData){ var randDialogId = 'tplDialog_'+SysUtils.getRandom(); var $container = $('
'); var target = targetId ? '#'+targetId : 'body'; $container.appendTo($(target)); var data = resData; if(dataFilter){ data = dataFilter(resData,$container); } var html = template(templateId, data); $container.html(html); //每次隐藏完删除dom $container.on('hidden.bs.modal',function(){ $container.remove(); }); $container.modal('show'); }, function(){ SysDialog.alertError("获取数据异常!"); }); }; /** * 根据模板id和数据打开modal */ SysDialog.openUseTplAndData = function(templateId,data,callback,targetId){ var randDialogId = 'tplAndDataDialog_'+SysUtils.getRandom(); var $container = $('
'); var target = targetId ? '#'+targetId : 'body'; $container.appendTo($(target)); var html = template(templateId, data); $container.html(html); var dialog = $container.find('.modal'); //每次隐藏完删除dom dialog.on('hidden.bs.modal',function(){ $container.remove(); }); dialog.on('shown.bs.modal',function(){ callback && callback(); }); dialog.modal('show'); }; /** * ajax打开对话框 * @param url url * @param params 参数 * @param modalId * @param targetId模态框append的targetDOM * @param showCallback 打开后回调 */ SysDialog.ajaxOpen = function(url,params,targetId,showCallback){ //SysView.loading(null, true); var rnd = 'rnd_dialog_'+SysUtils.getRandom(); var target = targetId ? '#'+targetId : 'body'; var $rndDialog = $('
').appendTo($(target)); AjaxRequest.load(rnd, url, params,function(){ //SysView.loaded(); var $dialog = $rndDialog.find('.modal'); $dialog.on('hidden.bs.modal',function(){ $rndDialog.remove(); }); $dialog.on('show.bs.modal',showCallback); $dialog.modal('show'); }); }; /** * @param options{ * url: 请求数据的URL * params: 参数信息 * templateId: 页面存放的模版ID(与templateUrl只能选其一,如果两个都填写优先使用templateId) * templateUrl:请求模板的url(与templateId只能选其一,如果两个都填写优先使用templateId) * templateParam:请求模板的参数(与templlateUrl对应) * targetId: 生成的html需要appendTo目标Id * dataFilter: 数据过滤fn * openCallback:打开对话框回调 * * } */ SysDialog.renderOpen = function(options){ var rnd = 'rnd_dialog_'+SysUtils.getRandom(); var target = options.targetId ? '#'+options.targetId : 'body'; var $rndDialog = $('
').appendTo($(target)); //重置targetId options.targetId = rnd; //成功回调中打开dialog options.successback = function(){ var $dialog = $rndDialog.find('.modal'); $dialog.on('hidden.bs.modal',function(){ $rndDialog.remove(); }); $dialog.on('show.bs.modal',options.openCallback || $.noop); $dialog.modal('show'); }; AjaxRequest.render(options); }; /** * @param options{ * formId: form表单ID * url: 表单提交获取数据的URL * templateId: 页面存放的模版ID(与templateUrl只能选其一,如果两个都填写优先使用templateId) * templateUrl:请求模板的url(与templateId只能选其一,如果两个都填写优先使用templateId) * templateParam:请求模板的参数(与templlateUrl对应) * targetId: 生成的html需要appendTo渲染后的模版ID * dataFilter: 数据过滤Fn * openCallback:打开对话框回调 * } */ SysDialog.submitRenderOpen = function(options){ var rnd = 'rnd_dialog_'+SysUtils.getRandom(); var target = options.targetId ? '#'+options.targetId : 'body'; var $rndDialog = $('
').appendTo($(target)); //重置targetId options.targetId = rnd; //成功回调中打开dialog options.successback = function(){ var $dialog = $rndDialog.find('.modal'); $dialog.on('hidden.bs.modal',function(){ $rndDialog.remove(); }); $dialog.on('show.bs.modal',options.openCallback || $.noop); $dialog.modal('show'); }; AjaxRequest.submitRender(options); }; var SysView = { pageInfoTemplate : '{{if dataCount>0}}
{{if showSelect}}
显示:
{{else}}{{/if}}{{if showDataCount}}
共{{dataCount}}条
{{/if}}
{{/if}}', pageOmitStr : '...', pagePreStr : '上一页', pageNextStr : '下一页', pageFirstStr : '第一页', pageLastStr : '最后一页', pageOrderNum : 5, pageLimit : 10 }; /** * 系统显示加载中 * * @param jquery 选择符 * @param isLock 是否锁屏 * @loadingStyle 【'success':绿色;'complete':蓝色;'warning':橙黄;'danger':红色;'danger':红色; * 'progress-lg':加粗加大;'progress-sm':小号;'progress-xs':超小号;】 * @param desc 加载的描述字符 * */ SysView.loading = function (selector,isLock,desc,loadingStyle) { selector = selector || 'body'; var $container = $(selector); $container.each(function() { var $loadingDiv = $(selector + ' > #sys_loading'); var $lockingDiv = $(selector + ' > #sys_mask'); $(this).addClass("progess-mask"); if($loadingDiv.length <= 0){ $loadingDiv = $('
'); $(this).append($loadingDiv); }else{ $loadingDiv.show(); } if(isLock){ if($lockingDiv.length <= 0){ $lockingDiv = $('
'); $(this).append($lockingDiv); }else{ $lockingDiv.show(); } } }); }; /** * 系统加载完成 */ SysView.loaded = function (selector) { selector = selector || 'body'; var $container = $(selector); $container.each(function() { $(this).removeClass('progess-mask'); $(selector + ' > #sys_loading').hide(); $(selector + ' > #sys_mask').hide(); }); }; /** * 系统分页组件 * @param options * 说明: * options.pageContainer :类型:String 。详细:容纳分页组件的选择器,为空时返回false。 * options.callback : 类型:Function。详细:回掉函数,切换页面时调用。 * options.dataCount : 类型:Number。详细:返回的数据数量。 * options.pageLimit :类型:Number。详细:当前页的页大小(允许为空,默认值:10,可供选择:5,10,20,50)。 * options.omitStr :类型:String。详细:当页签过多时,省略页签上显示的字符串(允许为空,默认值:'...')。 * options.preStr :类型:String。详细:上一页显示的字符串(允许为空,默认值:'上一页')。 * options.nextStr :类型:String。详细:下一页显示的字符串(允许为空,默认值:'下一页')。 * options.firstStr :类型:String。详细:第一页显示的字符串(允许为空,默认值:'第一页')。 * options.lastStr :类型:String。详细:最后一页显示的字符串(允许为空,默认值:'最后一页')。 * options.orderNum :类型:Number。详细:可供选择的页签(允许为空,默认值:5)。 * options.showDataCount :类型:Boolean。详细:是否显示共多少条。 * options.showSelect :类型:Boolean。详细:是否显示每页多少条。 * 使用示例: * var pageInit = function(){ AjaxRequest.submit("#formId", "***", function(data){ //列表数据展示(使用模板) tabListInit(); var dataCount = data.returnVlaue['dataCount']; SysView.pageInfo({ pageContainer : '#pageInfo', dataCount : dataCount, callback : pageInit }); }, function(data){ alertSomthing(); }); }; */ SysView.pageInfo = function(options){ if(options == undefined || options == null || options['pageContainer'] == undefined || options['pageContainer'] == null){ return false; } var render = template.compile(SysView.pageInfoTemplate); var pageData = {},pageArray = []; var $pageContainer = $(options['pageContainer']); var dataCount = parseInt(options['dataCount'] || 0); var callback = options['callback'] || $.noop(); var showDataCount = (options['showDataCount'] == false)?false:true; var showSelect = (options['showSelect'] == false)?false:true; var curPageElement = $pageContainer.find("#curPage"); var pageLimitElement = $pageContainer.find("#pageLimit"); var curPage = parseInt((curPageElement.length>0)?curPageElement.val(): 1); var pageLimit = parseInt((pageLimitElement.length>0)?pageLimitElement.val():(options['pageLimit'] || SysView.pageLimit)); var omitStr = options['omitStr'] || SysView.pageOmitStr; var preStr = options['preStr'] || SysView.pagePreStr; var nextStr = options['nextStr'] || SysView.pageNextStr; var firstStr = options['firstStr'] || SysView.pageFirstStr; var lastStr = options['lastStr'] || SysView.pageLastStr; var orderNum = (options['orderNum'])?options['orderNum']:SysView.pageOrderNum; var limitArray = [{'pageLimit':10},{'pageLimit':50},{'pageLimit':100}]; for(var i = 0 ; pageLimit >0 && i 1 && x === executePageNum - 1 && curPage !== executePageNum){ pageArray.push({'next': true,'nextStr': nextStr}); pageArray.push({'last': true,'lastStr': lastStr}); } } pageData['pageArray']=pageArray; } //如果页数大于要显示的页数 else{ var halfLength = Math.floor(orderNum/2); var halfPageNum = Math.floor(executePageNum/2); for (var y = 0; y halfLength){ pageArray.push({'pageStr': 1}); pageArray.push({'omit':true,'omitStr':omitStr}); } else{ (curPage === 1)?(pageArray.push({'current': true,'pageStr': 1})):(pageArray.push({'pageStr': 1})); } } //判断是否显示后面的省略页签 else if(y === orderNum-1){ if(executePageNum - curPage > halfLength){ pageArray.push({'omit':true,'omitStr':omitStr}); pageArray.push({'pageStr': executePageNum}); } else{ (curPage === executePageNum)?(pageArray.push({'current': true,'pageStr': executePageNum})):(pageArray.push({'pageStr': executePageNum})); } } //生成中间页签 else{ if(curPage - 1 < halfLength){ (curPage === tempPageNumY)?(pageArray.push({'current': true,'pageStr': tempPageNumY})):(pageArray.push({'pageStr': tempPageNumY})); } else if(executePageNum - curPage <= halfLength){ var tempPageNumK = executePageNum - orderNum +1 + y; (curPage === tempPageNumK)?(pageArray.push({'current': true,'pageStr': tempPageNumK})):(pageArray.push({'pageStr': tempPageNumK})); } else{ var tempPageNumZ= curPage-(halfLength-y); (curPage === tempPageNumZ)?(pageArray.push({'current': true,'pageStr': tempPageNumZ})):(pageArray.push({'pageStr': tempPageNumZ})); } } //判断是否显示最后一页和下一页 if(y === orderNum - 1 && curPage !== executePageNum){ pageArray.push({'next': true,'nextStr': nextStr}); pageArray.push({'last': true,'lastStr': lastStr}); } pageData['pageArray']=pageArray; } } } //回调函数绑定 var callbackBand = function(){ //页签切换 $pageContainer.find("a[name='page']").unbind("click.p").bind("click.p",function(){ var thisElement = $(this); var curPageElement = $pageContainer.find("#curPage"); var lastPageElement = $pageContainer.find("#lastPage"); var curPageNum = parseInt(curPageElement.val()); var lastPageNum = parseInt(lastPageElement.val()); if(thisElement.hasClass("pre")){ curPageElement.val(curPageNum-1); } else if(thisElement.hasClass("next")){ curPageElement.val(curPageNum+1); } else if(thisElement.hasClass("first")){ curPageElement.val(1); } else if(thisElement.hasClass("last")){ curPageElement.val(lastPageNum); } else{ curPageElement.val(parseInt(thisElement.attr("page-num"))); } callback(); }); //页大小切换 $pageContainer.find("#pageLimit").unbind("change.c").bind("change.c",function(){ var curPageElement = $pageContainer.find("#curPage").val(1); callback(); }); }; $pageContainer.find('#sys_page').remove(); //模板生成 $pageContainer.append(render(pageData)); //回调绑定 callbackBand(); }; var SysUtils = {}; /** * 写cookie值 * * @param name * @param value * @param time * 过期时间,单位ms */ SysUtils.setCookie = function(name, value, time) { var period = time; if (!time) { period = 30 * 24 * 60 * 60 * 1000; } var exp = new Date(); exp.setTime(exp.getTime() + period); document.cookie = name + "=" + escape(value) + ";Path=/;expires=" + exp.toGMTString(); }; SysUtils.setSessionCookie = function (name,value){ var isIE=!-[1,];//判断是否是ie核心浏览器 if(isIE){ if(value){ var expire = "; expires=At the end of the Session"; var path=";path=/"; document.cookie = name + "=" + escape(value) + expire+path; } }else{ if(value){ var expire = "; expires=Session"; var path = ";path=/"; document.cookie = name + "=" + escape(value) + expire+path; } } }; /** * 取得cookie值 * * @param name * @returns */ SysUtils.getCookie = function(name) { var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)"); if (arr = document.cookie.match(reg)) { return unescape(arr[2]); } return null; }; /** * 通用工具方法 获取一个object数组中某个字段的数组或者请求参数的字符串 * objArr:[{id:"123",name:""},{id:"456",name:""}] || \/ [123,456] */ SysUtils.getFieldArrFromObjArr = function(objArr, fieldName) { var arr = []; if (objArr && objArr.push) { for (var i = 0; i < objArr.length; i++) { var f = objArr[i][fieldName]; if (f != undefined) { arr.push(f); } } } return arr; }; /** * 把数组转换成提交的参数 */ SysUtils.converArrToParams = function(arr, paramName) { var params = ''; if (!arr || !arr.push) { return params; } paramName = paramName || 'id'; for (var i = 0; i < arr.length; i++) { var f = arr[i]; if (f != undefined) { params += '&' + paramName + '=' + f; } } return params; }; /** * 清空查询条件 注:根据id 清空form所有input内容 排除隐藏文本框 * 添加属性not-clear="not-clear" 便是此input控件不清空(支持 input type='text'; select;) * @return */ SysUtils.formClear = function (formId) { var form = $('#' + formId); if (form.length > 0) { var radioSet = {}; form.find('input[type="text"],textarea').each(function() { var notClear = $(this).attr("not-clear"); if(notClear !== "not-clear"){ var placeholder = $(this).attr('placeholder'); if (placeholder) { $(this).val(placeholder); } else { $(this).val(''); } } }); form.find('select').each(function() { var notClear = $(this).attr("not-clear"); if(notClear !== "not-clear"){ $(this).find('option').removeAttr('selected'); $(this).find('option:eq(0)').attr('selected', 'selected'); } }); form.find('input[type="radio"]').each(function() { var name = $(this).attr('name'); if (name) { radioSet[name] = ''; } else { $(this).removeAttr('checked'); } }); for ( var p in radioSet) { $('input[name="' + p + '"]').removeAttr('checked'); $('input[name="' + p + '"]:eq(0)').attr('checked', 'checked'); } form.find('input[type="checkbox"]').removeAttr('checked'); } }; /** * 全选 */ SysUtils.checkAll = function (self, ckName) { if ($(self).prop('checked') == true) { $('input[name="' + ckName + '"]').prop('checked', true); } else { $('input[name="' + ckName + '"]').prop('checked',false); } $('input[name="' + ckName + '"]').each(function() { $(this).unbind('click.ck').bind('click.ck', function() { var count = $('input[name="' + ckName + '"]').length; var ckCount = $('input[name="' + ckName + '"]:checked').length; if (ckCount < count) { $(self).prop('checked',false); } else { $(self).prop('checked', true); } }); }); }; SysUtils.getCheckedValues = function (ckName) { var ids = []; $('input[name="' + ckName + '"]:checked').each(function() { if ($(this).attr('checked') == 'checked') { ids.push($(this).val()); } }); return ids; }; /** * 下载文件 * * @param name * 下载文件名 测试 * @param path * 文件路径 /test/test2/test.txt 或者: http://xxx/yyy.txt * */ SysUtils.downLoadFile = function (name, path) { var params = 'fileName=' + encodeURIComponent(name); params += '&filePath=' + encodeURIComponent(path); if (!path.startWith('http')) { location.href = BASE_PATH + '/common/download-file?' + params; } else { location.href = BASE_PATH + '/common/download-remote-file?' + params; } }; SysUtils.getRandom = function(){ var random = Math.floor(Math.random() * 10001); var id = (new Date().getTime()*random).toString(); id = id.split('').reverse().join(''); return id; }; /** * 打印日志 */ SysUtils.console = function(val){ if(console){ console.log(val); } } /** * 判断当前对象是否为空 */ SysUtils.isEmpty = function(obj){ if(typeof obj == undefined || obj == null || obj == ""){ return true; } return false; } /** * 通过id来获取城市名称 */ SysUtils.getCityNameFormId = function(id){ if(id){ for(var i = 0 ; i < CITYS.length ; i++){ if(CITYS[i]['id']==id){ return CITYS[i]['name']; } } } return ""; } var SysEvent = {}; SysEvent.init = function() { }; /** * 绑定浮动层的事件 ajax loaded页面需要手动调用 */ SysEvent.bindPopupEvent = function() { $('.popupParentEl').each(function() { $(this).unbind('mouseover.popup').bind('mouseover.popup', function(e) { $(this).find('.popupEl').show(); SysEvent.stopBubble(e); return false; }).unbind('mouseout.popup').bind('mouseout.popup', function(e) { $(this).find('.popupEl').hide(); SysEvent.stopBubble(e); return false; }); }); }; /** * 阻止事件冒泡 * * @param e * js事件对象 */ SysEvent.stopBubble = function (e) { if (e && e.stopPropagation) { e.stopPropagation(); } else { window.event.cancelBubble = true; } }; // 阻止浏览器的默认行为 SysEvent.stopDefault = function (e) { // 阻止默认浏览器动作(W3C) if (e && e.preventDefault) { e.preventDefault(); } // IE中阻止函数器默认动作的方式 else { window.event.returnValue = false; } return false; }; /** ******************************js时间工具**************************************** */ DateUtil = {}; DateUtil.isLeapYear = function(date) { return (0 == date.getYear() % 4 && ((date.getYear() % 100 != 0) || (date.getYear() % 400 == 0))); }; /** * 格式化日期 */ DateUtil.fomatDate = function(date, fmt) { var yyyy = date.getFullYear(); var MM = date.getMonth(); var dd = date.getDate(); var HH = date.getHours(); var mm = date.getMinutes(); var ss = date.getSeconds(); var hh = HH > 12 ? HH - 12 : HH; var dateStr = fmt.replace('yyyy', yyyy).replace('MM',DateUtil.addZero(MM + 1)).replace('dd', DateUtil.addZero(dd)) .replace('HH', DateUtil.addZero(HH)).replace('mm',DateUtil.addZero(mm)).replace('ss', DateUtil.addZero(ss)) .replace('hh', DateUtil.addZero(hh)); return dateStr; }; DateUtil.addZero = function(num) { if (num < 10){ return '0' + num; } return num; }; /** * 将日期字符串转成日期 fmt:yyyy-MM-dd HH:mm:ss 或 yyyy-MM-dd */ DateUtil.parseDate = function(str, fmt) { if (!str) { return null; } var date; var year = 0; var month = 0; var day = 0; var hour = 0; var minute = 0; var second = 0; var tempStrs = str.split(' '); if (tempStrs[0]) { var dateStrs = tempStrs[0].split("-"); year = parseInt(dateStrs[0], 10); month = parseInt(dateStrs[1], 10) - 1; day = parseInt(dateStrs[2], 10); } if (tempStrs[1]) { var timeStrs = tempStrs[1].split(":"); hour = parseInt(timeStrs[0], 10); minute = parseInt(timeStrs[1], 10); second = parseInt(timeStrs[2], 10); } if (fmt == 'yyyy-MM-dd') { date = new Date(year, month, day); return date; } else if (fmt == 'yyyy-MM-dd HH:mm:ss') { date = new Date(year, month, day, hour, minute, second); return date; } return null; }; /** * 获取指定日期最后一天日期 */ DateUtil.getLastDate = function(date) { date = arguments[0] || new Date(); var newDate = new Date(date.getTime()); newDate.setMonth(newDate.getMonth() + 1); newDate.setDate(1); var time = newDate.getTime() - 24 * 60 * 60 * 1000; newDate = new Date(time); return newDate; }; /** * 获取日期差 */ DateUtil.getDateDiff = function(start,end) { return Math.round(Math.abs(start - end )/(1000*60*60*24)); }; /** * 获取指定日期第一天日期 */ DateUtil.getFirstDate = function(date) { date = arguments[0] || new Date(); var newDate = new Date(date.getTime()); newDate.setDate(1); return newDate; }; /** * 获取周的第一天 */ DateUtil.getWeekStartDate = function(date){ date = arguments[0] || new Date(); return new Date(date.getFullYear(), date.getMonth(), date.getDate() - date.getDay()+1); } /** * 获取周的最后一天 */ DateUtil.getWeekEndDate = function(date){ date = arguments[0] || new Date(); return new Date(date.getFullYear(), date.getMonth(), date.getDate() + (6-date.getDay()+1)); } /** * 日期计算 * * @param strInterval * string 可选值 y 年 m月 d日 w星期 ww周 h时 n分 s秒 * @param num * int * @param date * Date 日期对象 * @return Date 返回日期对象 */ DateUtil.dateAdd = function(strInterval, num, date) { date = arguments[2] || new Date(); switch (strInterval) { case 's': return new Date(date.getTime() + (1000 * num)); case 'n': return new Date(date.getTime() + (60000 * num)); case 'h': return new Date(date.getTime() + (3600000 * num)); case 'd': return new Date(date.getTime() + (86400000 * num)); case 'w': return new Date(date.getTime() + ((86400000 * 7) * num)); case 'm': return new Date(date.getFullYear(), (date.getMonth()) + num, date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds()); case 'y': return new Date((date.getFullYear() + num), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds()); } }; /** * @param datetimeopts datetime的选项 * @param userOpts 自定义选项 * userOpts:{ * beginTimeId:开始时间控件id * endTimeId:结束时间控件id * fmt:时间格式 yyyy-MM-dd HH:mm:ss * range:时间相差范围 * rangeUnit:时间相差返回的单位: y 年 m月 d日 w星期 ww周 h时 n分 s秒 * } */ DateUtil.initDate = function(datetimeopts,userOpts){ var beginTimeId = userOpts.beginTimeId; var endTimeId = userOpts.endTimeId; var beginTime = userOpts.beginTime || ''; var endTime = userOpts.endTime || ''; var fmt = userOpts.fmt ||'yyyy-MM-dd'; var diff = userOpts.range; var rangeUnit = userOpts.rangeUnit; if(!beginTimeId || !endTimeId){ return; } var $beginTime = $('#'+beginTimeId); var $endTime = $('#'+endTimeId); if(beginTime){ datetimeopts.initialDate = beginTime; } $beginTime.datetimepicker(datetimeopts).on('changeDate',function(ev){ var btime = new Date(ev.date.valueOf()); var btimeStr = DateUtil.fomatDate(btime, fmt); if(diff && rangeUnit){ var limitEndTime = DateUtil.dateAdd(rangeUnit,diff, btime); var limitEndTimeStr = DateUtil.fomatDate(limitEndTime, fmt); var etimeStr = $endTime.val(); if(etimeStr){ var etime = DateUtil.parseDate(etimeStr, fmt); if(etime.getTime()>limitEndTime.getTime()){ $endTime.val(limitEndTimeStr); } } $endTime.datetimepicker('setEndDate', limitEndTimeStr); } $endTime.datetimepicker('setStartDate', btimeStr); }); if(endTime){ datetimeopts.initialDate = endTime; } $endTime.datetimepicker(datetimeopts).on('changeDate',function(ev){ var etime = new Date(ev.date.valueOf()); var etimeStr = DateUtil.fomatDate(etime, fmt); if(diff && rangeUnit){ var limitStartTime = DateUtil.dateAdd(rangeUnit,0-diff, etime); var limitStartTimeStr = DateUtil.fomatDate(limitStartTime, fmt); var btimeStr = $beginTime.val(); if(btimeStr){ var btime = DateUtil.parseDate(btimeStr, fmt); if(btime.getTime() this.length) { return false; } if (this.substring(this.length - str.length) == str) { return true; } return false; }; String.prototype.startWith = function(str) { if (str == null || str == '' || this.length == 0 || str.length > this.length) { return false; } if (this.substr(0, str.length) == str) { return true; } return false; }; String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g, ''); }; String.prototype.ltrim = function() { return this.replace(/(^\s*)/g, ''); }; String.prototype.rtrim = function() { return this.replace(/(\s*$)/g, ''); }; String.prototype.replaceAll = function(reallyDo, replaceWith, ignoreCase) { if (!RegExp.prototype.isPrototypeOf(reallyDo) && typeof reallyDo == 'string') { return this.replace(new RegExp(reallyDo, (ignoreCase ? "gi" : "g")), replaceWith); } else { return this.replace(reallyDo, replaceWith); } }; String.prototype.getBytesLength = function() { var totalLength = 0; var charCode; for (var i = 0; i < this.length; i++) { charCode = this.charCodeAt(i); if (charCode < 0x007f) { totalLength++; } else if ((0x0080 <= charCode) && (charCode <= 0x07ff)) { totalLength += 2; } else if ((0x0800 <= charCode) && (charCode <= 0xffff)) { totalLength += 3; } else { totalLength += 4; } } return totalLength; }; //============常量定义 var PLATFORMS = {"1":"帜讯","2":"湖北","3":"浙江","4":"江西","5":"上海","6":"江苏","7":"北京","8":"天津","9":"重庆","10":"河北","11":"河南","12":"云南","13":"辽宁","14":"黑龙江","15":"湖南","16":"安徽","17":"山东","18":"新疆","19":"台湾","20":"广西","21":"甘肃","22":"山西","23":"内蒙","24":"陕西","25":"吉林","26":"福建","27":"贵州","28":"广东","29":"四川","30":"青海","31":"西藏","32":"海南","33":"宁夏","34":"香港","35":"统一帜讯","36":"总部","37":"上海电信"}; var POINTS = {"1":"短信","2":"e信","3":"彩信","4":"彩e信","5":"功能","6":"流量","7":"语音"}; var PRODUCTMAP = { PRODUCT_ID_SMS:"1", PRODUCT_ID_EMS:"3", PRODUCT_ID_MMS:"2", PRODUCT_ID_MEMS:"4", PRODUCT_ID_WECHART:"5", PRODUCT_ID_APP:"6" }; var PRODUCTNAMEMAP = { '1':'短信', '2':'彩信', '3':'e信', '4':'彩e信', '5':'微信', '6':'客户端' }; var CITYS = [{"id":"1","platform":"2","name":"十堰","code":"0009"},{"id":"2","platform":"2","name":"襄阳","code":"0005"},{"id":"3","platform":"2","name":"随州","code":"0013"},{"id":"4","platform":"2","name":"孝感","code":"0010"},{"id":"5","platform":"2","name":"武汉","code":"0003"},{"id":"6","platform":"2","name":"黄冈","code":"0008"},{"id":"7","platform":"2","name":"鄂州","code":"0014"},{"id":"8","platform":"2","name":"黄石","code":"0004"},{"id":"9","platform":"2","name":"咸宁","code":"0012"},{"id":"10","platform":"2","name":"江汉","code":"0020"},{"id":"11","platform":"2","name":"荆州","code":"0006"},{"id":"12","platform":"2","name":"宜昌","code":"0007"},{"id":"13","platform":"2","name":"恩施","code":"0016"},{"id":"14","platform":"2","name":"荆门","code":"0011"},{"id":"27","platform":"4","name":"上饶市","code":"4002"},{"id":"403","platform":"4","name":"新余市","code":"0790"},{"id":"404","platform":"4","name":"南昌市","code":"0791"},{"id":"405","platform":"4","name":"九江市","code":"0792"},{"id":"407","platform":"4","name":"抚州市","code":"0794"},{"id":"408","platform":"4","name":"宜春市","code":"0795"},{"id":"409","platform":"4","name":"吉安市","code":"0796"},{"id":"410","platform":"4","name":"赣州市","code":"0797"},{"id":"411","platform":"4","name":"景德镇","code":"0798"},{"id":"412","platform":"4","name":"萍乡市","code":"0799"},{"id":"413","platform":"4","name":"鹰潭市","code":"0701"},{"id":"801","platform":"9","name":"重庆","code":"0801"},{"id":"1701","platform":"17","name":"青岛市","code":"0532"},{"id":"1702","platform":"17","name":"济南市","code":"0531"},{"id":"1703","platform":"17","name":"淄博市","code":"0533"},{"id":"1704","platform":"17","name":"德州市","code":"0534"},{"id":"1705","platform":"17","name":"烟台市","code":"0535"},{"id":"1706","platform":"17","name":"潍坊市","code":"0536"},{"id":"1707","platform":"17","name":"济宁市","code":"0537"},{"id":"1708","platform":"17","name":"泰安市","code":"0538"},{"id":"1709","platform":"17","name":"临沂市","code":"0539"},{"id":"1710","platform":"17","name":"菏泽市","code":"0530"},{"id":"1711","platform":"17","name":"滨州市","code":"0543"},{"id":"1712","platform":"17","name":"东营市","code":"0546"},{"id":"1713","platform":"17","name":"威海市","code":"0631"},{"id":"1714","platform":"17","name":"枣庄市","code":"0632"},{"id":"1715","platform":"17","name":"日照市","code":"0633"},{"id":"1716","platform":"17","name":"莱芜市","code":"0634"},{"id":"1717","platform":"17","name":"聊城市","code":"0635"},{"id":"2601","platform":"26","name":"福州市","code":"0591"},{"id":"2602","platform":"26","name":"厦门市","code":"0592"},{"id":"2603","platform":"26","name":"宁德市","code":"0593"},{"id":"2604","platform":"26","name":"莆田市","code":"0594"},{"id":"2605","platform":"26","name":"泉州市","code":"0595"},{"id":"2606","platform":"26","name":"漳州市","code":"0596"},{"id":"2607","platform":"26","name":"龙岩市","code":"0597"},{"id":"2608","platform":"26","name":"三明市","code":"0598"},{"id":"2609","platform":"26","name":"南平市","code":"0599"},{"id":"2801","platform":"28","name":"广州","code":"020"},{"id":"2802","platform":"28","name":"韶关市","code":"0751"},{"id":"2803","platform":"28","name":"惠州市","code":"0752"},{"id":"2804","platform":"28","name":"梅州市","code":"0753"},{"id":"2805","platform":"28","name":"汕头市","code":"0754"},{"id":"2806","platform":"28","name":"深圳市","code":"0755"},{"id":"2807","platform":"28","name":"珠海市","code":"0756"},{"id":"2808","platform":"28","name":"佛山市","code":"0757"},{"id":"2809","platform":"28","name":"肇庆市","code":"0758"},{"id":"2810","platform":"28","name":"湛江市","code":"0759"},{"id":"2811","platform":"28","name":"中山市","code":"0760"},{"id":"2812","platform":"28","name":"河源市","code":"0762"},{"id":"2813","platform":"28","name":"清远市","code":"0763"},{"id":"2814","platform":"28","name":"顺德市","code":"0765"},{"id":"2815","platform":"28","name":"云浮市","code":"0766"},{"id":"2816","platform":"28","name":"潮州市","code":"0768"},{"id":"2817","platform":"28","name":"东莞市","code":"0769"},{"id":"2818","platform":"28","name":"汕尾市","code":"0660"},{"id":"2819","platform":"28","name":"潮阳市","code":"0661"},{"id":"2820","platform":"28","name":"阳江市","code":"0662"},{"id":"2821","platform":"28","name":"揭阳市","code":"0663"},{"id":"2822","platform":"28","name":"江门市","code":"0750"},{"id":"2823","platform":"28","name":"茂名市","code":"0668"},{"id":"2901","platform":"29","name":"成都","code":"028"},{"id":"2902","platform":"29","name":"绵阳","code":"0816"},{"id":"2903","platform":"29","name":"德阳","code":"0838"},{"id":"2904","platform":"29","name":"宜宾","code":"0831"},{"id":"2905","platform":"29","name":"南充","code":"0817"},{"id":"2906","platform":"29","name":"达州","code":"0818"},{"id":"2907","platform":"29","name":"凉山","code":"0834"},{"id":"2908","platform":"29","name":"乐山","code":"0833"},{"id":"2909","platform":"29","name":"泸州","code":"0830"},{"id":"2910","platform":"29","name":"内江","code":"0832"},{"id":"2911","platform":"29","name":"资阳","code":"028"},{"id":"2912","platform":"29","name":"自贡","code":"0813"},{"id":"2913","platform":"29","name":"眉山","code":"028"},{"id":"2914","platform":"29","name":"广安","code":"0826"},{"id":"2915","platform":"29","name":"攀枝花","code":"0812"},{"id":"2916","platform":"29","name":"遂宁","code":"0825"},{"id":"2917","platform":"29","name":"广元","code":"0839"},{"id":"2918","platform":"29","name":"雅安","code":"0835"},{"id":"2919","platform":"29","name":"巴中","code":"0827"},{"id":"2920","platform":"29","name":"阿坝","code":"0837"},{"id":"2921","platform":"29","name":"甘孜","code":"0836"},{"id":"3201","platform":"32","name":"海口市","code":"0898"},{"id":"3301","platform":"1","name":"其他","code":"0951"},{"id":"20301","platform":"3","name":"杭州","code":"0009"},{"id":"20302","platform":"3","name":"温州","code":"0005"},{"id":"20303","platform":"3","name":"衢州","code":"0013"},{"id":"20304","platform":"3","name":"湖州","code":"0010"},{"id":"20305","platform":"3","name":"嘉兴","code":"0003"},{"id":"20306","platform":"3","name":"台州","code":"0008"},{"id":"20307","platform":"3","name":"丽水","code":"0014"},{"id":"20308","platform":"3","name":"金华","code":"0004"},{"id":"20309","platform":"3","name":"舟山","code":"0012"},{"id":"20310","platform":"3","name":"宁波","code":"0020"},{"id":"20311","platform":"3","name":"绍兴","code":"0006"},{"id":"20315","platform":"3","name":"帜讯","code":"0002"},{"id":"21201","platform":"12","name":"昆明","code":"0871"},{"id":"21202","platform":"12","name":"大理","code":"0872"},{"id":"21203","platform":"12","name":"红河","code":"0873"},{"id":"21204","platform":"12","name":"曲靖","code":"0874"},{"id":"21205","platform":"12","name":"文山","code":"0876"},{"id":"21206","platform":"12","name":"玉溪","code":"0877"},{"id":"21207","platform":"12","name":"普洱","code":"0870"},{"id":"21208","platform":"12","name":"昭通","code":"0879"},{"id":"21209","platform":"12","name":"西双版纳","code":"0691"},{"id":"21210","platform":"12","name":"德宏","code":"0692"},{"id":"21211","platform":"12","name":"临沧","code":"0883"},{"id":"21212","platform":"12","name":"迪庆","code":"0886"},{"id":"21214","platform":"12","name":"丽江","code":"0888"},{"id":"21215","platform":"12","name":"怒江","code":"0889"},{"id":"21216","platform":"12","name":"楚雄","code":"0890"},{"id":"21217","platform":"12","name":"保山","code":"0891"},{"id":"21401","platform":"14","name":"哈尔滨市","code":"0451"},{"id":"21402","platform":"14","name":"齐齐哈尔市","code":"0452"},{"id":"21403","platform":"14","name":"鸡西市","code":"0467"},{"id":"21404","platform":"14","name":"鹤岗市","code":"0468"},{"id":"21405","platform":"14","name":"双鸭山市","code":"0469"},{"id":"21406","platform":"14","name":"大庆市","code":"0459"},{"id":"21407","platform":"14","name":"伊春市","code":"0458"},{"id":"21408","platform":"14","name":"佳木斯市","code":"0454"},{"id":"21409","platform":"14","name":"七台河市","code":"0464"},{"id":"21410","platform":"14","name":"牡丹江市","code":"0453"},{"id":"21411","platform":"14","name":"黑河市","code":"0456"},{"id":"21412","platform":"14","name":"绥化市","code":"0455"},{"id":"21413","platform":"14","name":"大兴安岭地区","code":"0457"},{"id":"22101","platform":"21","name":"兰州","code":"0931"},{"id":"22102","platform":"21","name":"陇南","code":"0939"},{"id":"22103","platform":"21","name":"庆阳","code":"0934"},{"id":"22104","platform":"21","name":"临夏","code":"0930"},{"id":"22105","platform":"21","name":"嘉峪关","code":"0937"},{"id":"22106","platform":"21","name":"甘南","code":"0941"},{"id":"22107","platform":"21","name":"白银","code":"0943"},{"id":"22108","platform":"21","name":"张掖","code":"0936"},{"id":"22109","platform":"21","name":"平凉","code":"0933"},{"id":"22110","platform":"21","name":"酒泉","code":"0937"},{"id":"22111","platform":"21","name":"金昌","code":"0935"},{"id":"22112","platform":"21","name":"定西","code":"0932"},{"id":"22113","platform":"21","name":"天水","code":"0938"},{"id":"22114","platform":"21","name":"武威","code":"0935"},{"id":"22201","platform":"22","name":"太原市","code":"0351"},{"id":"22202","platform":"22","name":"大同市","code":"0352"},{"id":"22203","platform":"22","name":"阳泉市","code":"0353"},{"id":"22204","platform":"22","name":"长治市","code":"0355"},{"id":"22205","platform":"22","name":"晋城市","code":"0356"},{"id":"22206","platform":"22","name":"朔州市","code":"0349"},{"id":"22207","platform":"22","name":"晋中市","code":"0354"},{"id":"22208","platform":"22","name":"运城市","code":"0359"},{"id":"22209","platform":"22","name":"忻州市","code":"0350"},{"id":"22210","platform":"22","name":"临汾市","code":"0357"},{"id":"22211","platform":"22","name":"吕梁市","code":"0358"},{"id":"23001","platform":"30","name":"西宁","code":"0971"},{"id":"23002","platform":"30","name":"海东","code":"0972"},{"id":"23003","platform":"30","name":"格尔木","code":"0979"},{"id":"23004","platform":"30","name":"德令哈","code":"0977"},{"id":"23005","platform":"30","name":"海西州","code":"0979"},{"id":"23006","platform":"30","name":"海南州","code":"0974"},{"id":"23007","platform":"30","name":"海北州","code":"0970"},{"id":"23008","platform":"30","name":"黄南州","code":"0973"},{"id":"23009","platform":"30","name":"果洛州","code":"0975"},{"id":"23010","platform":"30","name":"玉树州","code":"0976"},{"id":"23301","platform":"33","name":"银川","code":"0951"},{"id":"23302","platform":"33","name":"石嘴山","code":""},{"id":"23303","platform":"33","name":"吴忠","code":""},{"id":"23304","platform":"33","name":"中卫","code":""},{"id":"23305","platform":"33","name":"固原","code":""},{"id":"24001","platform":"24","name":"西安市","code":"0291"},{"id":"24002","platform":"24","name":"商洛","code":"0914"},{"id":"24003","platform":"24","name":"铜川","code":"0919"},{"id":"24004","platform":"24","name":"延安","code":"0911"},{"id":"24005","platform":"24","name":"安康","code":"0915"},{"id":"24006","platform":"24","name":"渭南","code":"0913"},{"id":"24007","platform":"24","name":"宝鸡","code":"0919"},{"id":"24009","platform":"24","name":"榆林","code":"0912"},{"id":"24010","platform":"24","name":"咸阳","code":"0292"},{"id":"24011","platform":"24","name":"汉中","code":"0916"},{"id":"30318","platform":"3","name":"帜讯测试用渠道","code":"test01"},{"id":"205001","platform":"5","name":"上海","code":"021"},{"id":"206001","platform":"6","name":"南京市","code":"025"},{"id":"206002","platform":"6","name":"无锡","code":"0510"},{"id":"206003","platform":"6","name":"徐州","code":"0516"},{"id":"206004","platform":"6","name":"常州","code":"0519"},{"id":"206005","platform":"6","name":"苏州","code":"0512"},{"id":"206006","platform":"6","name":"连云港","code":"0513"},{"id":"206007","platform":"6","name":"淮安","code":"0517"},{"id":"206008","platform":"6","name":"盐城","code":"0515"},{"id":"206009","platform":"6","name":"扬州","code":"0514"},{"id":"206010","platform":"6","name":"镇江","code":"0511"},{"id":"206011","platform":"6","name":"泰州","code":"0523"},{"id":"206012","platform":"6","name":"宿迁","code":"0527"},{"id":"206013","platform":"6","name":"南通","code":"0513"},{"id":"210001","platform":"10","name":"石家庄","code":"0311"},{"id":"210002","platform":"10","name":"邯郸市","code":"0310"},{"id":"210003","platform":"10","name":"张家口市","code":"0313"},{"id":"210004","platform":"10","name":"承德市","code":"0314"},{"id":"210005","platform":"10","name":"唐山市","code":"0315"},{"id":"210006","platform":"10","name":"廊坊市","code":"0316"},{"id":"210007","platform":"10","name":"沧州市","code":"0317"},{"id":"210008","platform":"10","name":"衡水市","code":"0318"},{"id":"210009","platform":"10","name":"邢台市","code":"0319"},{"id":"210010","platform":"10","name":"秦皇岛市","code":"0335"},{"id":"210011","platform":"10","name":"保定市","code":"0312"},{"id":"213001","platform":"13","name":"沈阳","code":"024"},{"id":"213002","platform":"13","name":"葫芦岛","code":"0429"},{"id":"213003","platform":"13","name":"朝阳","code":"0421"},{"id":"213004","platform":"13","name":"铁岭","code":"0241"},{"id":"213005","platform":"13","name":"盘锦","code":"0427"},{"id":"213006","platform":"13","name":"辽阳","code":"0419"},{"id":"213007","platform":"13","name":"营口","code":"0417"},{"id":"213008","platform":"13","name":"锦州","code":"0416"},{"id":"213009","platform":"13","name":"丹东","code":"0415"},{"id":"213010","platform":"13","name":"鞍山","code":"0412"},{"id":"213011","platform":"13","name":"抚顺","code":"0242"},{"id":"213012","platform":"13","name":"大连","code":"0411"},{"id":"213013","platform":"13","name":"本溪","code":"0414"},{"id":"213014","platform":"13","name":"阜新","code":"0418"},{"id":"220001","platform":"20","name":"防城港","code":"0770"},{"id":"220002","platform":"20","name":"崇左","code":"0771"},{"id":"220003","platform":"20","name":"南宁","code":"0771"},{"id":"220004","platform":"20","name":"柳州","code":"0772"},{"id":"220005","platform":"20","name":"来宾","code":"0772"},{"id":"220006","platform":"20","name":"桂林","code":"0773"},{"id":"220007","platform":"20","name":"贺州","code":"0774"},{"id":"220008","platform":"20","name":"梧州","code":"0774"},{"id":"220009","platform":"20","name":"贵港","code":"0775"},{"id":"220010","platform":"20","name":"玉林","code":"0775"},{"id":"220011","platform":"20","name":"百色","code":"0776"},{"id":"220012","platform":"20","name":"钦州","code":"0777"},{"id":"220013","platform":"20","name":"河池","code":"0778"},{"id":"220014","platform":"20","name":"北海","code":"0779"},{"id":"236001","platform":"36","name":"联通总部","code":"0000"},{"id":"237001","platform":"37","name":"上海","code":"0000"},{"id":"1013302","platform":"1","name":"宁夏","code":"0951"},{"id":"1013303","platform":"1","name":"上海电信","code":"0951"},{"id":"1013304","platform":"1","name":"湖北","code":"0951"},{"id":"1013305","platform":"1","name":"浙江","code":"0951"},{"id":"1013306","platform":"1","name":"江西","code":"0951"},{"id":"1013307","platform":"1","name":"上海","code":"0951"},{"id":"1013308","platform":"1","name":"江苏","code":"0951"},{"id":"1013309","platform":"1","name":"天津","code":"0951"},{"id":"1013310","platform":"1","name":"重庆","code":"0951"},{"id":"1013311","platform":"1","name":"河北","code":"0951"},{"id":"1013312","platform":"1","name":"云南","code":"0951"},{"id":"1013313","platform":"1","name":"辽宁","code":"0951"},{"id":"1013314","platform":"1","name":"黑龙江","code":"0951"},{"id":"1013315","platform":"1","name":"山东","code":"0951"},{"id":"1013316","platform":"1","name":"广西","code":"0951"},{"id":"1013317","platform":"1","name":"甘肃","code":"0951"},{"id":"1013318","platform":"1","name":"山西","code":"0951"},{"id":"1013319","platform":"1","name":"陕西","code":"0951"},{"id":"1013320","platform":"1","name":"福建","code":"0951"},{"id":"1013321","platform":"1","name":"广东","code":"0951"},{"id":"1013322","platform":"1","name":"四川","code":"0951"},{"id":"1013323","platform":"1","name":"青海","code":"0951"},{"id":"1013324","platform":"1","name":"海南","code":"0951"},{"id":"1013325","platform":"1","name":"总部","code":"0951"},{"id":"1013326","platform":"1","name":"吉林","code":"0951"},{"id":"1013327","platform":"1","name":"湖南","code":"0951"}]; var CITYSMAP = {}; for(var i in CITYS){var c = CITYS[i];var p = c.platform;var cs = CITYSMAP[p];if(!cs){cs = [];CITYSMAP[p]=cs;}cs.push(c);}

你可能感兴趣的:(js)