function pySegSort(arr, empty) {
if(!String.prototype.localeCompare)
return null;
var letters = "*ABCDEFGHJKLMNOPQRSTWXYZ".split('');
var zh = "阿八嚓哒妸发旮哈讥咔垃痳拏噢妑七呥扨它穵夕丫帀".split('');
var segs = [];// 存放数据
var py = [];// 存放首字母
var res = {};
var curr;
$.each(letters, function(i) {
curr = {
letter: this,
data: []
};
$.each(arr, function(k, v) {
if((!zh[i - 1] || zh[i - 1].localeCompare(v.cityName) <= 0) && v.cityName.localeCompare(zh[i]) == -1) {
curr.data.push(this);
}
});
if(empty || curr.data.length) {
py.push(this);
segs.push(curr);
curr.data.sort(function(a, b) {
return a.cityName.localeCompare(b.cityName);
});
}
});
res["segs"] = segs;
res["py"] = py;
return res;
}
function pinyin() {
var arr2 = [
{ id: '1', cityName:'北京市' },
{ id: '2', cityName:'上海市' },
{ id: '3', cityName:'天津市' },
{ id: '4', cityName:'重庆市' },
{ id: '5', cityName:"石家庄市"},
{ id: '6', cityName:"唐山市"},
{ id: '7', cityName:"秦皇岛市"},
{ id: '8', cityName:"邯郸市"},
{ id: '9', cityName:"邢台市"},
{ id: '10', cityName:"保定市"},
{ id: '11', cityName:"张家口市"},
{ id: '12', cityName:"承德市"},
{ id: '13', cityName:"沧州市"},
{ id: '14', cityName:"廊坊市"},
{ id: '15', cityName:"衡水市" },
{ id: '16', cityName:"太原市"},
{ id: '17', cityName:"大同市"},
{ id: '18', cityName:"阳泉市"},
{ id: '19', cityName:"长治市"},
{ id: '20', cityName:"晋城市"},
{ id: '21', cityName:"朔州市"},
{ id: '22', cityName:"晋中市"},
{ id: '23', cityName:"运城市"},
{ id: '24', cityName:"忻州市"},
{ id: '25', cityName:"临汾市"},
{ id: '26', cityName:"吕梁市" },
{ id: '27', cityName:"呼和浩特市"},
{ id: '28', cityName:"包头市"},
{ id: '29', cityName:"乌海市"},
{ id: '30', cityName:"赤峰市"},
{ id: '31', cityName:"通辽市"},
{ id: '32', cityName:"鄂尔多斯市"},
{ id: '33', cityName:"呼伦贝尔市"},
{ id: '34', cityName:"巴彦淖尔市"},
{ id: '35', cityName:"乌兰察布市"},
{ id: '36', cityName:"兴安盟"},
{ id: '37', cityName:"锡林郭勒盟"},
{ id: '38', cityName:"阿拉善盟"},
{ id: '39', cityName:"沈阳市"},
{ id: '40', cityName:"大连市"},
{ id: '41', cityName:"鞍山市"},
{ id: '42', cityName:"抚顺市"},
{ id: '43', cityName:"本溪市"},
{ id: '44', cityName:"丹东市"},
{ id: '45', cityName:"锦州市"},
{ id: '46', cityName:"营口市"},
{ id: '47', cityName:"阜新市"},
{ id: '48', cityName:"辽阳市"},
{ id: '49', cityName:"盘锦市"},
{ id: '50', cityName:"铁岭市"},
{ id: '51', cityName:"朝阳市"},
{ id: '52', cityName:"葫芦岛市"},
{ id: '53', cityName: "长春市"},
{ id: '54', cityName:"吉林市"},
{ id: '55', cityName:"四平市"},
{ id: '56', cityName:"辽源市"},
{ id: '57', cityName:"通化市"},
{ id: '58', cityName:"白山市"},
{ id: '59', cityName:"松原市"},
{ id: '60', cityName:"白城市"},
{ id: '61', cityName:"延边自治州"},
{ id: '62', cityName:"哈尔滨市"},
{ id: '63', cityName:"齐齐哈尔市"},
{ id: '64', cityName:"鸡西市"},
{ id: '65', cityName:"鹤岗市"},
{ id: '66', cityName:"双鸭山市"},
{ id: '67', cityName:"大庆市"},
{ id: '68', cityName:"伊春市"},
{ id: '69', cityName:"佳木斯市"},
{ id: '70', cityName:"七台河市"},
{ id: '71', cityName:"牡丹江市"},
{ id: '72', cityName:"黑河市"},
{ id: '73', cityName:"绥化市"},
{ id: '74', cityName:"大兴安岭地区"},
{ id: '75', cityName:"南京市"},
{ id: '76', cityName:"无锡市"},
{ id: '77', cityName:"徐州市"},
{ id: '78', cityName:"常州市"},
{ id: '79', cityName:"苏州市"},
{ id: '80', cityName:"南通市"},
{ id: '81', cityName:"连云港市"},
{ id: '82', cityName:"淮安市"},
{ id: '83', cityName:"盐城市"},
{ id: '84', cityName:"扬州市"},
{ id: '85', cityName:"镇江市"},
{ id: '86', cityName:"泰州市"},
{ id: '87', cityName:"宿迁市" },
{ id: '88', cityName:"杭州市"},
{ id: '89', cityName:"宁波市"},
{ id: '90', cityName:"温州市"},
{ id: '91', cityName:"嘉兴市"},
{ id: '92', cityName:"湖州市"},
{ id: '93', cityName:"绍兴市"},
{ id: '94', cityName:"金华市"},
{ id: '95', cityName:"衡州市"},
{ id: '96', cityName:"舟山市"},
{ id: '97', cityName:"台州市"},
{ id: '98', cityName:"丽水市" },
{ id: '99', cityName:"合肥市"},
{ id: '100', cityName:"芜湖市"},
{ id: '101', cityName:"蚌埠市"},
{ id: '102', cityName:"淮南市"},
{ id: '103', cityName:"马鞍山市"},
{ id: '104', cityName:"淮北市"},
{ id: '105', cityName:"铜陵市"},
{ id: '106', cityName:"安庆市"},
{ id: '107', cityName:"黄山市"},
{ id: '108', cityName:"滁州市"},
{ id: '109', cityName:"阜阳市"},
{ id: '110', cityName:"宿州市"},
{ id: '111', cityName:"巢湖市"},
{ id: '112', cityName:"六安市"},
{ id: '113', cityName:"毫州市"},
{ id: '114', cityName:"池州市"},
{ id: '115', cityName:"宣城市"},
{ id: '116', cityName:"福州市"},
{ id: '117', cityName:"厦门市"},
{ id: '118', cityName:"莆田市"},
{ id: '119', cityName:"三明市"},
{ id: '120', cityName:"泉州市"},
{ id: '121', cityName:"漳州市"},
{ id: '122', cityName:"南平市"},
{ id: '123', cityName:"龙岩市"},
{ id: '124', cityName:"宁德市" },
{ id: '125', cityName:"南昌市"},
{ id: '126', cityName:"景德镇市"},
{ id: '127', cityName:"萍乡市"},
{ id: '128', cityName:"九江市"},
{ id: '129', cityName:"新余市"},
{ id: '130', cityName:"鹰潭市"},
{ id: '131', cityName:"赣州市"},
{ id: '132', cityName:"吉安市"},
{ id: '133', cityName:"宜春市"},
{ id: '134', cityName:"抚州市"},
{ id: '135', cityName:"上饶市" },
{ id: '136', cityName:"济南市"},
{ id: '137', cityName:"青岛市"},
{ id: '138', cityName:"淄博市"},
{ id: '139', cityName:"枣庄市"},
{ id: '140', cityName:"东营市"},
{ id: '141', cityName:"烟台市"},
{ id: '142', cityName:"潍坊市"},
{ id: '143', cityName:"济宁市"},
{ id: '144', cityName:"泰安市"},
{ id: '145', cityName:"威海市"},
{ id: '146', cityName:"日照市"},
{ id: '147', cityName:"莱芜市"},
{ id: '148', cityName:"临沂市"},
{ id: '149', cityName:"德州市"},
{ id: '150', cityName:"聊城市"},
{ id: '151', cityName:"滨州市"},
{ id: '152', cityName:"菏泽市" },
{ id: '153', cityName:"郑州市"},
{ id: '154', cityName:"开封市"},
{ id: '155', cityName:"洛阳市"},
{ id: '156', cityName:"平顶山市"},
{ id: '157', cityName:"安阳市"},
{ id: '158', cityName:"鹤壁市"},
{ id: '159', cityName:"新乡市"},
{ id: '160', cityName:"焦作市"},
{ id: '161', cityName:"灌阳市"},
{ id: '162', cityName:"许昌市"},
{ id: '163', cityName:"漂河市"},
{ id: '164', cityName:"三门峡市"},
{ id: '165', cityName:"南阳市"},
{ id: '166', cityName:"商丘市"},
{ id: '167', cityName:"信阳市"},
{ id: '168', cityName:"周口市"},
{ id: '169', cityName:"驻马店市"},
{ id: '170', cityName:"省直辖县及济源市" },
{ id: '171', cityName:"武汉市"},
{ id: '172', cityName:"黄石市"},
{ id: '173', cityName:"十堰市"},
{ id: '174', cityName:"宜昌市"},
{ id: '175', cityName:"襄樊市"},
{ id: '176', cityName:"鄂州市"},
{ id: '177', cityName:"荆门市"},
{ id: '178', cityName:"孝感市"},
{ id: '179', cityName:"荆州市"},
{ id: '180', cityName:"黄冈市"},
{ id: '181', cityName:"咸宁市"},
{ id: '182', cityName:"随州市"},
{ id: '183', cityName:"恩施自治州"},
{ id: '184', cityName:"省直辖县级市、区" },
{ id: '185', cityName:"长沙市"},
{ id: '186', cityName:"株州市"},
{ id: '187', cityName:"湘潭市"},
{ id: '188', cityName:"衡阳市"},
{ id: '189', cityName:"邵阳市"},
{ id: '190', cityName:"岳阳市"},
{ id: '191', cityName:"常德市"},
{ id: '192', cityName:"张家界市"},
{ id: '193', cityName:"益阳市"},
{ id: '194', cityName:"郴州市"},
{ id: '195', cityName:"永州市"},
{ id: '196', cityName:"怀化市"},
{ id: '197', cityName:"娄底市"},
{ id: '198', cityName:"湘西自治州" },
{ id: '199', cityName:"广州市"},
{ id: '200', cityName:"韶关市"},
{ id: '201', cityName:"深圳市"},
{ id: '202', cityName:"珠海市"},
{ id: '203', cityName:"汕头市"},
{ id: '204', cityName:"佛山市"},
{ id: '205', cityName:"江门市"},
{ id: '206', cityName:"湛江市"},
{ id: '207', cityName:"茂名市"},
{ id: '208', cityName:"肇庆市"},
{ id: '209', cityName:"惠州市"},
{ id: '210', cityName:"梅州市"},
{ id: '211', cityName:"汕尾市"},
{ id: '212', cityName:"河源市"},
{ id: '213', cityName:"阳江市"},
{ id: '214', cityName:"清远市"},
{ id: '215', cityName:"东尧市"},
{ id: '216', cityName:"中山市"},
{ id: '217', cityName:"潮州市"},
{ id: '218', cityName:"揭阳市"},
{ id: '219', cityName:"云浮市" },
{ id: '220', cityName:"南宁市"},
{ id: '221', cityName:"柳州市"},
{ id: '222', cityName:"桂林市"},
{ id: '223', cityName:"梧州市"},
{ id: '224', cityName:"北海市"},
{ id: '225', cityName:"防城港市"},
{ id: '226', cityName:"钦州市"},
{ id: '227', cityName:"贵港市"},
{ id: '228', cityName:"玉林市"},
{ id: '229', cityName:"百色市"},
{ id: '230', cityName:"贺州市"},
{ id: '231', cityName:"河池市"},
{ id: '232', cityName:"来宾市"},
{ id: '233', cityName:"崇左市"},
{ id: '234', cityName:"海口市"},
{ id: '235', cityName:"三亚市"},
{ id: '236', cityName:"省直辖县级市、县等" },
{ id: '237', cityName:"成都市"},
{ id: '238', cityName:"自贡市"},
{ id: '239', cityName:"攀枝花市"},
{ id: '240', cityName:"沪州市"},
{ id: '241', cityName:"德阳市"},
{ id: '242', cityName:"绵阳市"},
{ id: '243', cityName:"广元市"},
{ id: '244', cityName:"遂宁市"},
{ id: '245', cityName:"内江市"},
{ id: '246', cityName:"乐山市"},
{ id: '247', cityName:"南充市"},
{ id: '248', cityName:"眉山市"},
{ id: '249', cityName:"宜宾市"},
{ id: '250', cityName:"广安市"},
{ id: '251', cityName:"达州市"},
{ id: '252', cityName:"雅安市"},
{ id: '253', cityName:"巴中市"},
{ id: '254', cityName:"资阳市"},
{ id: '255', cityName:"阿坝自治州"},
{ id: '256', cityName:"甘孜自治州"},
{ id: '257', cityName:"凉山自治州" },
{ id: '258', cityName:"贵阳市"},
{ id: '259', cityName:"六盘水市"},
{ id: '260', cityName:"遵义市"},
{ id: '261', cityName:"安顺市"},
{ id: '262', cityName:"铜仁地区"},
{ id: '263', cityName:"黔西南自治州"},
{ id: '264', cityName:"毕节地区"},
{ id: '265', cityName:"黔东南自治州"},
{ id: '266', cityName:"黔南自治州" },
{ id: '267', cityName:"昆明市"},
{ id: '268', cityName:"曲靖市"},
{ id: '269', cityName:"玉溪市"},
{ id: '270', cityName:"保山市"},
{ id: '271', cityName:"昭通市"},
{ id: '272', cityName:"丽江市"},
{ id: '273', cityName:"普洱市"},
{ id: '274', cityName:"临沧市"},
{ id: '275', cityName:"楚雄自治州"},
{ id: '276', cityName:"红河自治州"},
{ id: '277', cityName:"文山自治州"},
{ id: '278', cityName:"西双版纳自治州"},
{ id: '279', cityName:"大理自治州"},
{ id: '280', cityName:"德宏自治州"},
{ id: '281', cityName:"怒江自治州"},
{ id: '282', cityName:"迪庆自治州"},
{ id: '283', cityName:"拉萨市"},
{ id: '284', cityName:"昌都地区"},
{ id: '285', cityName:"山南地区"},
{ id: '286', cityName:"日喀则地区"},
{ id: '287', cityName:"那曲地区"},
{ id: '288', cityName:"阿里地区"},
{ id: '289', cityName:"林芝地区" },
{ id: '290', cityName:"西安市"},
{ id: '291', cityName:"铜川市"},
{ id: '292', cityName:"宝鸡市"},
{ id: '293', cityName: "咸阳市"},
{ id: '294', cityName: "渭南市"},
{ id: '295', cityName: "延安市"},
{ id: '296', cityName: "汉中市"},
{ id: '297', cityName: "榆林市"},
{ id: '298', cityName: "安康市"},
{ id: '299', cityName: "商洛市" },
{ id: '300', cityName:"兰州市"},
{ id: '301', cityName: "嘉峪关市"},
{ id: '302', cityName: "金昌市"},
{ id: '303', cityName: "白银市"},
{ id: '304', cityName: "天水市"},
{ id: '305', cityName: "武威市"},
{ id: '306', cityName: "张掖市"},
{ id: '307', cityName: "平凉市"},
{ id: '308', cityName: "酒泉市"},
{ id: '309', cityName: "庆阳市"},
{ id: '310', cityName: "定西市"},
{ id: '311', cityName: "陇南市"},
{ id: '312', cityName: "临夏自治州"},
{ id: '313', cityName:"甘南自治州" },
{ id: '314', cityName:"西宁市"},
{ id: '315', cityName:"海东地区"},
{ id: '316', cityName:"海北自治州"},
{ id: '317', cityName:"黄南自治州"},
{ id: '318', cityName:"海南自治州"},
{ id: '319', cityName:"果洛自治州"},
{ id: '320', cityName:"玉树自治州"},
{ id: '321', cityName:"海西自治州"},
{ id: '322', cityName:"银川市"},
{ id: '323', cityName:"石嘴山市"},
{ id: '324', cityName:"吴忠市"},
{ id: '325', cityName:"固原市"},
{ id: '326', cityName:"中卫市" },
{ id: '327', cityName:"乌鲁木齐市"},
{ id: '328', cityName:"克拉玛依市"},
{ id: '329', cityName:"吐鲁番地区"},
{ id: '330', cityName:"哈密地区"},
{ id: '331', cityName:"昌吉自治州"},
{ id: '332', cityName:"博尔塔拉自治州"},
{ id: '333', cityName:"巴音郭楞自治州"},
{ id: '334', cityName:"阿克苏地区"},
{ id: '335', cityName:"克孜勒苏柯尔克孜自治州"},
{ id: '336', cityName:"咯什地区"},
{ id: '337', cityName:"和田地区"},
{ id: '338', cityName:"伊犁自治州"},
{ id: '339', cityName:"塔城地区"},
{ id: '340', cityName:"阿勒泰地区"},
{ id: '341', cityName:"自治区直辖县级市" },
{ id: '342', cityName:'台湾' },
{ id: '343', cityName:'香港' },
{ id: '344', cityName:'澳门' }
];
var str = pySegSort(arr2).segs;
var cityAll = JSON.stringify(str);
var htmlText= '';
for(var i=0;i' + str[i].letter + '