UNPKG

96.6 kBJavaScriptView Raw
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@babel/runtime/core-js/object/assign'), require('mockjs'), require('@babel/runtime/core-js/object/keys'), require('moment'), require('@babel/runtime/helpers/objectSpread')) :
3 typeof define === 'function' && define.amd ? define(['@babel/runtime/core-js/object/assign', 'mockjs', '@babel/runtime/core-js/object/keys', 'moment', '@babel/runtime/helpers/objectSpread'], factory) :
4 (global.mock = factory(global._Object$assign,global.mockjs,global._Object$keys,global.moment,global._objectSpread));
5}(this, (function (_Object$assign,mockjs,_Object$keys,moment,_objectSpread) { 'use strict';
6
7 _Object$assign = _Object$assign && _Object$assign.hasOwnProperty('default') ? _Object$assign['default'] : _Object$assign;
8 mockjs = mockjs && mockjs.hasOwnProperty('default') ? mockjs['default'] : mockjs;
9 _Object$keys = _Object$keys && _Object$keys.hasOwnProperty('default') ? _Object$keys['default'] : _Object$keys;
10 moment = moment && moment.hasOwnProperty('default') ? moment['default'] : moment;
11 _objectSpread = _objectSpread && _objectSpread.hasOwnProperty('default') ? _objectSpread['default'] : _objectSpread;
12
13 var titles = ['Alipay', 'Angular', 'Ant Design', 'Ant Design Pro', 'Bootstrap', 'React', 'Vue', 'Webpack'];
14 var avatars = ['https://gw.alipayobjects.com/zos/rmsportal/WdGqmHpayyMjiEhcKoVE.png', // Alipay
15 'https://gw.alipayobjects.com/zos/rmsportal/zOsKZmFRdUtvpqCImOVY.png', // Angular
16 'https://gw.alipayobjects.com/zos/rmsportal/dURIMkkrRFpPgTuzkwnB.png', // Ant Design
17 'https://gw.alipayobjects.com/zos/rmsportal/sfjbOqnsXXJgNCjCzDBL.png', // Ant Design Pro
18 'https://gw.alipayobjects.com/zos/rmsportal/siCrBXXhmvTQGWPNLBow.png', // Bootstrap
19 'https://gw.alipayobjects.com/zos/rmsportal/kZzEzemZyKLKFsojXItE.png', // React
20 'https://gw.alipayobjects.com/zos/rmsportal/ComBAopevLwENQdKWiIn.png', // Vue
21 'https://gw.alipayobjects.com/zos/rmsportal/nxkuOJlFJuAUhzlMTCEe.png'];
22 var avatars2 = ['https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png', 'https://gw.alipayobjects.com/zos/rmsportal/cnrhVkzwxjPwAaCfPbdc.png', 'https://gw.alipayobjects.com/zos/rmsportal/gaOngJwsRYRaVAuXXcmB.png', 'https://gw.alipayobjects.com/zos/rmsportal/ubnKSIfAJTxIgXOKlciN.png', 'https://gw.alipayobjects.com/zos/rmsportal/WhxKECPNujWoWEFNdnJE.png', 'https://gw.alipayobjects.com/zos/rmsportal/jZUIxmJycoymBprLOUbT.png', 'https://gw.alipayobjects.com/zos/rmsportal/psOgztMplJMGpVEqfcgF.png', 'https://gw.alipayobjects.com/zos/rmsportal/ZpBqSxLxVEXfcUNoPKrz.png', 'https://gw.alipayobjects.com/zos/rmsportal/laiEnJdGHVOhJrUShBaJ.png', 'https://gw.alipayobjects.com/zos/rmsportal/UrQsqscbKEpNuJcvBZBu.png'];
23 var covers = ['https://gw.alipayobjects.com/zos/rmsportal/uMfMFlvUuceEyPpotzlq.png', 'https://gw.alipayobjects.com/zos/rmsportal/iZBVOIhGJiAnhplqjvZW.png', 'https://gw.alipayobjects.com/zos/rmsportal/iXjVmWVHbCJAyqvDxdtx.png', 'https://gw.alipayobjects.com/zos/rmsportal/gLaIAoVWTtLbBWZNYEMg.png'];
24 var desc = ['那是一种内在的东西, 他们到达不了,也无法触及的', '希望是一个好东西,也许是最好的,好东西是不会消亡的', '生命就像一盒巧克力,结果往往出人意料', '城镇中有那么多的酒馆,她却偏偏走进了我的酒馆', '那时候我只会想自己想要什么,从不想自己拥有什么'];
25 var user = ['付小小', '曲丽丽', '林东东', '周星星', '吴加好', '朱偏右', '鱼酱', '乐哥', '谭小仪', '仲尼'];
26
27 function fakeList(count) {
28 var list = [];
29
30 for (var i = 0; i < count; i += 1) {
31 list.push({
32 id: "fake-list-".concat(i),
33 owner: user[i % 10],
34 title: titles[i % 8],
35 avatar: avatars[i % 8],
36 cover: parseInt(i / 4, 10) % 2 === 0 ? covers[i % 4] : covers[3 - i % 4],
37 status: ['active', 'exception', 'normal'][i % 3],
38 percent: Math.ceil(Math.random() * 50) + 50,
39 logo: avatars[i % 8],
40 href: 'https://ant.design',
41 updatedAt: new Date(new Date().getTime() - 1000 * 60 * 60 * 2 * i),
42 createdAt: new Date(new Date().getTime() - 1000 * 60 * 60 * 2 * i),
43 subDescription: desc[i % 5],
44 description: '在中台产品的研发过程中,会出现不同的设计规范和实现方式,但其中往往存在很多类似的页面和组件,这些类似的组件会被抽离成一套标准规范。',
45 activeUser: Math.ceil(Math.random() * 100000) + 100000,
46 newUser: Math.ceil(Math.random() * 1000) + 1000,
47 star: Math.ceil(Math.random() * 100) + 100,
48 like: Math.ceil(Math.random() * 100) + 100,
49 message: Math.ceil(Math.random() * 10) + 10,
50 content: '段落示意:蚂蚁金服设计平台 ant.design,用最小的工作量,无缝接入蚂蚁金服生态,提供跨越设计与开发的体验解决方案。蚂蚁金服设计平台 ant.design,用最小的工作量,无缝接入蚂蚁金服生态,提供跨越设计与开发的体验解决方案。',
51 members: [{
52 avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ZiESqWwCXBRQoaPONSJe.png',
53 name: '曲丽丽',
54 id: 'member1'
55 }, {
56 avatar: 'https://gw.alipayobjects.com/zos/rmsportal/tBOxZPlITHqwlGjsJWaF.png',
57 name: '王昭君',
58 id: 'member2'
59 }, {
60 avatar: 'https://gw.alipayobjects.com/zos/rmsportal/sBxjgqiuHMGRkIjqlQCd.png',
61 name: '董娜娜',
62 id: 'member3'
63 }]
64 });
65 }
66
67 return list;
68 }
69
70 var sourceData;
71
72 function getFakeList(req, res) {
73 var params = req.query;
74 var count = params.count * 1 || 20;
75 var result = fakeList(count);
76 sourceData = result;
77
78 if (res && res.json) {
79 res.json(result);
80 } else {
81 return result;
82 }
83 }
84
85 function postFakeList(req, res) {
86 var body = req.body; // const params = getUrlParams(url);
87
88 var method = body.method,
89 id = body.id; // const count = (params.count * 1) || 20;
90
91 var result = sourceData;
92
93 switch (method) {
94 case 'delete':
95 result = result.filter(function (item) {
96 return item.id !== id;
97 });
98 break;
99
100 case 'update':
101 result.forEach(function (item, i) {
102 if (item.id === id) {
103 result[i] = _Object$assign(item, body);
104 }
105 });
106 break;
107
108 case 'post':
109 result.unshift({
110 body: body,
111 id: "fake-list-".concat(result.length),
112 createdAt: new Date().getTime()
113 });
114 break;
115
116 default:
117 break;
118 }
119
120 if (res && res.json) {
121 res.json(result);
122 } else {
123 return result;
124 }
125 }
126
127 var getNotice = [{
128 id: 'xxx1',
129 title: titles[0],
130 logo: avatars[0],
131 description: '那是一种内在的东西,他们到达不了,也无法触及的',
132 updatedAt: new Date(),
133 member: '科学搬砖组',
134 href: '',
135 memberLink: ''
136 }, {
137 id: 'xxx2',
138 title: titles[1],
139 logo: avatars[1],
140 description: '希望是一个好东西,也许是最好的,好东西是不会消亡的',
141 updatedAt: new Date('2017-07-24'),
142 member: '全组都是吴彦祖',
143 href: '',
144 memberLink: ''
145 }, {
146 id: 'xxx3',
147 title: titles[2],
148 logo: avatars[2],
149 description: '城镇中有那么多的酒馆,她却偏偏走进了我的酒馆',
150 updatedAt: new Date(),
151 member: '中二少女团',
152 href: '',
153 memberLink: ''
154 }, {
155 id: 'xxx4',
156 title: titles[3],
157 logo: avatars[3],
158 description: '那时候我只会想自己想要什么,从不想自己拥有什么',
159 updatedAt: new Date('2017-07-23'),
160 member: '程序员日常',
161 href: '',
162 memberLink: ''
163 }, {
164 id: 'xxx5',
165 title: titles[4],
166 logo: avatars[4],
167 description: '凛冬将至',
168 updatedAt: new Date('2017-07-23'),
169 member: '高逼格设计天团',
170 href: '',
171 memberLink: ''
172 }, {
173 id: 'xxx6',
174 title: titles[5],
175 logo: avatars[5],
176 description: '生命就像一盒巧克力,结果往往出人意料',
177 updatedAt: new Date('2017-07-23'),
178 member: '骗你来学计算机',
179 href: '',
180 memberLink: ''
181 }];
182 var getActivities = [{
183 id: 'trend-1',
184 updatedAt: new Date(),
185 user: {
186 name: '曲丽丽',
187 avatar: avatars2[0]
188 },
189 group: {
190 name: '高逼格设计天团',
191 link: 'http://github.com/'
192 },
193 project: {
194 name: '六月迭代',
195 link: 'http://github.com/'
196 },
197 template: '在 @{group} 新建项目 @{project}'
198 }, {
199 id: 'trend-2',
200 updatedAt: new Date(),
201 user: {
202 name: '付小小',
203 avatar: avatars2[1]
204 },
205 group: {
206 name: '高逼格设计天团',
207 link: 'http://github.com/'
208 },
209 project: {
210 name: '六月迭代',
211 link: 'http://github.com/'
212 },
213 template: '在 @{group} 新建项目 @{project}'
214 }, {
215 id: 'trend-3',
216 updatedAt: new Date(),
217 user: {
218 name: '林东东',
219 avatar: avatars2[2]
220 },
221 group: {
222 name: '中二少女团',
223 link: 'http://github.com/'
224 },
225 project: {
226 name: '六月迭代',
227 link: 'http://github.com/'
228 },
229 template: '在 @{group} 新建项目 @{project}'
230 }, {
231 id: 'trend-4',
232 updatedAt: new Date(),
233 user: {
234 name: '周星星',
235 avatar: avatars2[4]
236 },
237 project: {
238 name: '5 月日常迭代',
239 link: 'http://github.com/'
240 },
241 template: '将 @{project} 更新至已发布状态'
242 }, {
243 id: 'trend-5',
244 updatedAt: new Date(),
245 user: {
246 name: '朱偏右',
247 avatar: avatars2[3]
248 },
249 project: {
250 name: '工程效能',
251 link: 'http://github.com/'
252 },
253 comment: {
254 name: '留言',
255 link: 'http://github.com/'
256 },
257 template: '在 @{project} 发布了 @{comment}'
258 }, {
259 id: 'trend-6',
260 updatedAt: new Date(),
261 user: {
262 name: '乐哥',
263 avatar: avatars2[5]
264 },
265 group: {
266 name: '程序员日常',
267 link: 'http://github.com/'
268 },
269 project: {
270 name: '品牌迭代',
271 link: 'http://github.com/'
272 },
273 template: '在 @{group} 新建项目 @{project}'
274 }];
275
276 function getFakeCaptcha(req, res) {
277 if (res && res.json) {
278 res.json('captcha-xxx');
279 } else {
280 return 'captcha-xxx';
281 }
282 }
283
284 var api = {
285 'GET /api/project/notice': getNotice,
286 'GET /api/activities': getActivities,
287 'POST /api/forms': function POSTApiForms(req, res) {
288 res.send({
289 message: 'Ok'
290 });
291 },
292 'GET /api/tags': mockjs.mock({
293 'list|100': [{
294 name: '@city',
295 'value|1-100': 150,
296 'type|0-2': 1
297 }]
298 }),
299 'GET /api/fake_list': getFakeList,
300 'POST /api/fake_list': postFakeList,
301 'GET /api/captcha': getFakeCaptcha
302 };
303
304 var visitData = [];
305 var beginDay = new Date().getTime();
306 var fakeY = [7, 5, 4, 2, 4, 7, 5, 6, 5, 9, 6, 3, 1, 5, 3, 6, 5];
307
308 for (var i = 0; i < fakeY.length; i += 1) {
309 visitData.push({
310 x: moment(new Date(beginDay + 1000 * 60 * 60 * 24 * i)).format('YYYY-MM-DD'),
311 y: fakeY[i]
312 });
313 }
314
315 var visitData2 = [];
316 var fakeY2 = [1, 6, 4, 8, 3, 7, 2];
317
318 for (var _i = 0; _i < fakeY2.length; _i += 1) {
319 visitData2.push({
320 x: moment(new Date(beginDay + 1000 * 60 * 60 * 24 * _i)).format('YYYY-MM-DD'),
321 y: fakeY2[_i]
322 });
323 }
324
325 var salesData = [];
326
327 for (var _i2 = 0; _i2 < 12; _i2 += 1) {
328 salesData.push({
329 x: "".concat(_i2 + 1, "\u6708"),
330 y: Math.floor(Math.random() * 1000) + 200
331 });
332 }
333
334 var searchData = [];
335
336 for (var _i3 = 0; _i3 < 50; _i3 += 1) {
337 searchData.push({
338 index: _i3 + 1,
339 keyword: "\u641C\u7D22\u5173\u952E\u8BCD-".concat(_i3),
340 count: Math.floor(Math.random() * 1000),
341 range: Math.floor(Math.random() * 100),
342 status: Math.floor(Math.random() * 10 % 2)
343 });
344 }
345
346 var salesTypeData = [{
347 x: 'House appliances',
348 y: 4544
349 }, {
350 x: 'Drink & wine',
351 y: 3321
352 }, {
353 x: 'Health & care',
354 y: 3113
355 }, {
356 x: 'Clothing & bags',
357 y: 2341
358 }, {
359 x: 'Mother-baby',
360 y: 1231
361 }, {
362 x: 'Other',
363 y: 1231
364 }];
365 var salesTypeDataOnline = [{
366 x: 'House appliances',
367 y: 244
368 }, {
369 x: 'Drink & wine',
370 y: 321
371 }, {
372 x: 'Health & care',
373 y: 311
374 }, {
375 x: 'Clothing & bags',
376 y: 41
377 }, {
378 x: 'Mother-baby',
379 y: 121
380 }, {
381 x: 'Other',
382 y: 111
383 }];
384 var salesTypeDataOffline = [{
385 x: 'House appliances',
386 y: 99
387 }, {
388 x: 'Drink & wine',
389 y: 188
390 }, {
391 x: 'Health & care',
392 y: 344
393 }, {
394 x: 'Clothing & bags',
395 y: 255
396 }, {
397 x: 'Other',
398 y: 65
399 }];
400 var offlineData = [];
401
402 for (var _i4 = 0; _i4 < 10; _i4 += 1) {
403 offlineData.push({
404 name: "Stores ".concat(_i4),
405 cvr: Math.ceil(Math.random() * 9) / 10
406 });
407 }
408
409 var offlineChartData = [];
410
411 for (var _i5 = 0; _i5 < 20; _i5 += 1) {
412 offlineChartData.push({
413 x: new Date().getTime() + 1000 * 60 * 30 * _i5,
414 y1: Math.floor(Math.random() * 100) + 10,
415 y2: Math.floor(Math.random() * 100) + 10
416 });
417 }
418
419 var radarOriginData = [{
420 name: '个人',
421 ref: 10,
422 koubei: 8,
423 output: 4,
424 contribute: 5,
425 hot: 7
426 }, {
427 name: '团队',
428 ref: 3,
429 koubei: 9,
430 output: 6,
431 contribute: 3,
432 hot: 1
433 }, {
434 name: '部门',
435 ref: 4,
436 koubei: 1,
437 output: 6,
438 contribute: 5,
439 hot: 7
440 }]; //
441
442 var radarData = [];
443 var radarTitleMap = {
444 ref: '引用',
445 koubei: '口碑',
446 output: '产量',
447 contribute: '贡献',
448 hot: '热度'
449 };
450 radarOriginData.forEach(function (item) {
451 _Object$keys(item).forEach(function (key) {
452 if (key !== 'name') {
453 radarData.push({
454 name: item.name,
455 label: radarTitleMap[key],
456 value: item[key]
457 });
458 }
459 });
460 });
461 var getFakeChartData = {
462 visitData: visitData,
463 visitData2: visitData2,
464 salesData: salesData,
465 searchData: searchData,
466 offlineData: offlineData,
467 offlineChartData: offlineChartData,
468 salesTypeData: salesTypeData,
469 salesTypeDataOnline: salesTypeDataOnline,
470 salesTypeDataOffline: salesTypeDataOffline,
471 radarData: radarData
472 };
473 var chart = {
474 'GET /api/fake_chart_data': getFakeChartData
475 };
476
477 var city = {
478 "110000": [{
479 province: "北京市",
480 name: "市辖区",
481 id: "110100"
482 }],
483 "120000": [{
484 province: "天津市",
485 name: "市辖区",
486 id: "120100"
487 }],
488 "130000": [{
489 province: "河北省",
490 name: "石家庄市",
491 id: "130100"
492 }, {
493 province: "河北省",
494 name: "唐山市",
495 id: "130200"
496 }, {
497 province: "河北省",
498 name: "秦皇岛市",
499 id: "130300"
500 }, {
501 province: "河北省",
502 name: "邯郸市",
503 id: "130400"
504 }, {
505 province: "河北省",
506 name: "邢台市",
507 id: "130500"
508 }, {
509 province: "河北省",
510 name: "保定市",
511 id: "130600"
512 }, {
513 province: "河北省",
514 name: "张家口市",
515 id: "130700"
516 }, {
517 province: "河北省",
518 name: "承德市",
519 id: "130800"
520 }, {
521 province: "河北省",
522 name: "沧州市",
523 id: "130900"
524 }, {
525 province: "河北省",
526 name: "廊坊市",
527 id: "131000"
528 }, {
529 province: "河北省",
530 name: "衡水市",
531 id: "131100"
532 }, {
533 province: "河北省",
534 name: "省直辖县级行政区划",
535 id: "139000"
536 }],
537 "140000": [{
538 province: "山西省",
539 name: "太原市",
540 id: "140100"
541 }, {
542 province: "山西省",
543 name: "大同市",
544 id: "140200"
545 }, {
546 province: "山西省",
547 name: "阳泉市",
548 id: "140300"
549 }, {
550 province: "山西省",
551 name: "长治市",
552 id: "140400"
553 }, {
554 province: "山西省",
555 name: "晋城市",
556 id: "140500"
557 }, {
558 province: "山西省",
559 name: "朔州市",
560 id: "140600"
561 }, {
562 province: "山西省",
563 name: "晋中市",
564 id: "140700"
565 }, {
566 province: "山西省",
567 name: "运城市",
568 id: "140800"
569 }, {
570 province: "山西省",
571 name: "忻州市",
572 id: "140900"
573 }, {
574 province: "山西省",
575 name: "临汾市",
576 id: "141000"
577 }, {
578 province: "山西省",
579 name: "吕梁市",
580 id: "141100"
581 }],
582 "150000": [{
583 province: "内蒙古自治区",
584 name: "呼和浩特市",
585 id: "150100"
586 }, {
587 province: "内蒙古自治区",
588 name: "包头市",
589 id: "150200"
590 }, {
591 province: "内蒙古自治区",
592 name: "乌海市",
593 id: "150300"
594 }, {
595 province: "内蒙古自治区",
596 name: "赤峰市",
597 id: "150400"
598 }, {
599 province: "内蒙古自治区",
600 name: "通辽市",
601 id: "150500"
602 }, {
603 province: "内蒙古自治区",
604 name: "鄂尔多斯市",
605 id: "150600"
606 }, {
607 province: "内蒙古自治区",
608 name: "呼伦贝尔市",
609 id: "150700"
610 }, {
611 province: "内蒙古自治区",
612 name: "巴彦淖尔市",
613 id: "150800"
614 }, {
615 province: "内蒙古自治区",
616 name: "乌兰察布市",
617 id: "150900"
618 }, {
619 province: "内蒙古自治区",
620 name: "兴安盟",
621 id: "152200"
622 }, {
623 province: "内蒙古自治区",
624 name: "锡林郭勒盟",
625 id: "152500"
626 }, {
627 province: "内蒙古自治区",
628 name: "阿拉善盟",
629 id: "152900"
630 }],
631 "210000": [{
632 province: "辽宁省",
633 name: "沈阳市",
634 id: "210100"
635 }, {
636 province: "辽宁省",
637 name: "大连市",
638 id: "210200"
639 }, {
640 province: "辽宁省",
641 name: "鞍山市",
642 id: "210300"
643 }, {
644 province: "辽宁省",
645 name: "抚顺市",
646 id: "210400"
647 }, {
648 province: "辽宁省",
649 name: "本溪市",
650 id: "210500"
651 }, {
652 province: "辽宁省",
653 name: "丹东市",
654 id: "210600"
655 }, {
656 province: "辽宁省",
657 name: "锦州市",
658 id: "210700"
659 }, {
660 province: "辽宁省",
661 name: "营口市",
662 id: "210800"
663 }, {
664 province: "辽宁省",
665 name: "阜新市",
666 id: "210900"
667 }, {
668 province: "辽宁省",
669 name: "辽阳市",
670 id: "211000"
671 }, {
672 province: "辽宁省",
673 name: "盘锦市",
674 id: "211100"
675 }, {
676 province: "辽宁省",
677 name: "铁岭市",
678 id: "211200"
679 }, {
680 province: "辽宁省",
681 name: "朝阳市",
682 id: "211300"
683 }, {
684 province: "辽宁省",
685 name: "葫芦岛市",
686 id: "211400"
687 }],
688 "220000": [{
689 province: "吉林省",
690 name: "长春市",
691 id: "220100"
692 }, {
693 province: "吉林省",
694 name: "吉林市",
695 id: "220200"
696 }, {
697 province: "吉林省",
698 name: "四平市",
699 id: "220300"
700 }, {
701 province: "吉林省",
702 name: "辽源市",
703 id: "220400"
704 }, {
705 province: "吉林省",
706 name: "通化市",
707 id: "220500"
708 }, {
709 province: "吉林省",
710 name: "白山市",
711 id: "220600"
712 }, {
713 province: "吉林省",
714 name: "松原市",
715 id: "220700"
716 }, {
717 province: "吉林省",
718 name: "白城市",
719 id: "220800"
720 }, {
721 province: "吉林省",
722 name: "延边朝鲜族自治州",
723 id: "222400"
724 }],
725 "230000": [{
726 province: "黑龙江省",
727 name: "哈尔滨市",
728 id: "230100"
729 }, {
730 province: "黑龙江省",
731 name: "齐齐哈尔市",
732 id: "230200"
733 }, {
734 province: "黑龙江省",
735 name: "鸡西市",
736 id: "230300"
737 }, {
738 province: "黑龙江省",
739 name: "鹤岗市",
740 id: "230400"
741 }, {
742 province: "黑龙江省",
743 name: "双鸭山市",
744 id: "230500"
745 }, {
746 province: "黑龙江省",
747 name: "大庆市",
748 id: "230600"
749 }, {
750 province: "黑龙江省",
751 name: "伊春市",
752 id: "230700"
753 }, {
754 province: "黑龙江省",
755 name: "佳木斯市",
756 id: "230800"
757 }, {
758 province: "黑龙江省",
759 name: "七台河市",
760 id: "230900"
761 }, {
762 province: "黑龙江省",
763 name: "牡丹江市",
764 id: "231000"
765 }, {
766 province: "黑龙江省",
767 name: "黑河市",
768 id: "231100"
769 }, {
770 province: "黑龙江省",
771 name: "绥化市",
772 id: "231200"
773 }, {
774 province: "黑龙江省",
775 name: "大兴安岭地区",
776 id: "232700"
777 }],
778 "310000": [{
779 province: "上海市",
780 name: "市辖区",
781 id: "310100"
782 }],
783 "320000": [{
784 province: "江苏省",
785 name: "南京市",
786 id: "320100"
787 }, {
788 province: "江苏省",
789 name: "无锡市",
790 id: "320200"
791 }, {
792 province: "江苏省",
793 name: "徐州市",
794 id: "320300"
795 }, {
796 province: "江苏省",
797 name: "常州市",
798 id: "320400"
799 }, {
800 province: "江苏省",
801 name: "苏州市",
802 id: "320500"
803 }, {
804 province: "江苏省",
805 name: "南通市",
806 id: "320600"
807 }, {
808 province: "江苏省",
809 name: "连云港市",
810 id: "320700"
811 }, {
812 province: "江苏省",
813 name: "淮安市",
814 id: "320800"
815 }, {
816 province: "江苏省",
817 name: "盐城市",
818 id: "320900"
819 }, {
820 province: "江苏省",
821 name: "扬州市",
822 id: "321000"
823 }, {
824 province: "江苏省",
825 name: "镇江市",
826 id: "321100"
827 }, {
828 province: "江苏省",
829 name: "泰州市",
830 id: "321200"
831 }, {
832 province: "江苏省",
833 name: "宿迁市",
834 id: "321300"
835 }],
836 "330000": [{
837 province: "浙江省",
838 name: "杭州市",
839 id: "330100"
840 }, {
841 province: "浙江省",
842 name: "宁波市",
843 id: "330200"
844 }, {
845 province: "浙江省",
846 name: "温州市",
847 id: "330300"
848 }, {
849 province: "浙江省",
850 name: "嘉兴市",
851 id: "330400"
852 }, {
853 province: "浙江省",
854 name: "湖州市",
855 id: "330500"
856 }, {
857 province: "浙江省",
858 name: "绍兴市",
859 id: "330600"
860 }, {
861 province: "浙江省",
862 name: "金华市",
863 id: "330700"
864 }, {
865 province: "浙江省",
866 name: "衢州市",
867 id: "330800"
868 }, {
869 province: "浙江省",
870 name: "舟山市",
871 id: "330900"
872 }, {
873 province: "浙江省",
874 name: "台州市",
875 id: "331000"
876 }, {
877 province: "浙江省",
878 name: "丽水市",
879 id: "331100"
880 }],
881 "340000": [{
882 province: "安徽省",
883 name: "合肥市",
884 id: "340100"
885 }, {
886 province: "安徽省",
887 name: "芜湖市",
888 id: "340200"
889 }, {
890 province: "安徽省",
891 name: "蚌埠市",
892 id: "340300"
893 }, {
894 province: "安徽省",
895 name: "淮南市",
896 id: "340400"
897 }, {
898 province: "安徽省",
899 name: "马鞍山市",
900 id: "340500"
901 }, {
902 province: "安徽省",
903 name: "淮北市",
904 id: "340600"
905 }, {
906 province: "安徽省",
907 name: "铜陵市",
908 id: "340700"
909 }, {
910 province: "安徽省",
911 name: "安庆市",
912 id: "340800"
913 }, {
914 province: "安徽省",
915 name: "黄山市",
916 id: "341000"
917 }, {
918 province: "安徽省",
919 name: "滁州市",
920 id: "341100"
921 }, {
922 province: "安徽省",
923 name: "阜阳市",
924 id: "341200"
925 }, {
926 province: "安徽省",
927 name: "宿州市",
928 id: "341300"
929 }, {
930 province: "安徽省",
931 name: "六安市",
932 id: "341500"
933 }, {
934 province: "安徽省",
935 name: "亳州市",
936 id: "341600"
937 }, {
938 province: "安徽省",
939 name: "池州市",
940 id: "341700"
941 }, {
942 province: "安徽省",
943 name: "宣城市",
944 id: "341800"
945 }],
946 "350000": [{
947 province: "福建省",
948 name: "福州市",
949 id: "350100"
950 }, {
951 province: "福建省",
952 name: "厦门市",
953 id: "350200"
954 }, {
955 province: "福建省",
956 name: "莆田市",
957 id: "350300"
958 }, {
959 province: "福建省",
960 name: "三明市",
961 id: "350400"
962 }, {
963 province: "福建省",
964 name: "泉州市",
965 id: "350500"
966 }, {
967 province: "福建省",
968 name: "漳州市",
969 id: "350600"
970 }, {
971 province: "福建省",
972 name: "南平市",
973 id: "350700"
974 }, {
975 province: "福建省",
976 name: "龙岩市",
977 id: "350800"
978 }, {
979 province: "福建省",
980 name: "宁德市",
981 id: "350900"
982 }],
983 "360000": [{
984 province: "江西省",
985 name: "南昌市",
986 id: "360100"
987 }, {
988 province: "江西省",
989 name: "景德镇市",
990 id: "360200"
991 }, {
992 province: "江西省",
993 name: "萍乡市",
994 id: "360300"
995 }, {
996 province: "江西省",
997 name: "九江市",
998 id: "360400"
999 }, {
1000 province: "江西省",
1001 name: "新余市",
1002 id: "360500"
1003 }, {
1004 province: "江西省",
1005 name: "鹰潭市",
1006 id: "360600"
1007 }, {
1008 province: "江西省",
1009 name: "赣州市",
1010 id: "360700"
1011 }, {
1012 province: "江西省",
1013 name: "吉安市",
1014 id: "360800"
1015 }, {
1016 province: "江西省",
1017 name: "宜春市",
1018 id: "360900"
1019 }, {
1020 province: "江西省",
1021 name: "抚州市",
1022 id: "361000"
1023 }, {
1024 province: "江西省",
1025 name: "上饶市",
1026 id: "361100"
1027 }],
1028 "370000": [{
1029 province: "山东省",
1030 name: "济南市",
1031 id: "370100"
1032 }, {
1033 province: "山东省",
1034 name: "青岛市",
1035 id: "370200"
1036 }, {
1037 province: "山东省",
1038 name: "淄博市",
1039 id: "370300"
1040 }, {
1041 province: "山东省",
1042 name: "枣庄市",
1043 id: "370400"
1044 }, {
1045 province: "山东省",
1046 name: "东营市",
1047 id: "370500"
1048 }, {
1049 province: "山东省",
1050 name: "烟台市",
1051 id: "370600"
1052 }, {
1053 province: "山东省",
1054 name: "潍坊市",
1055 id: "370700"
1056 }, {
1057 province: "山东省",
1058 name: "济宁市",
1059 id: "370800"
1060 }, {
1061 province: "山东省",
1062 name: "泰安市",
1063 id: "370900"
1064 }, {
1065 province: "山东省",
1066 name: "威海市",
1067 id: "371000"
1068 }, {
1069 province: "山东省",
1070 name: "日照市",
1071 id: "371100"
1072 }, {
1073 province: "山东省",
1074 name: "莱芜市",
1075 id: "371200"
1076 }, {
1077 province: "山东省",
1078 name: "临沂市",
1079 id: "371300"
1080 }, {
1081 province: "山东省",
1082 name: "德州市",
1083 id: "371400"
1084 }, {
1085 province: "山东省",
1086 name: "聊城市",
1087 id: "371500"
1088 }, {
1089 province: "山东省",
1090 name: "滨州市",
1091 id: "371600"
1092 }, {
1093 province: "山东省",
1094 name: "菏泽市",
1095 id: "371700"
1096 }],
1097 "410000": [{
1098 province: "河南省",
1099 name: "郑州市",
1100 id: "410100"
1101 }, {
1102 province: "河南省",
1103 name: "开封市",
1104 id: "410200"
1105 }, {
1106 province: "河南省",
1107 name: "洛阳市",
1108 id: "410300"
1109 }, {
1110 province: "河南省",
1111 name: "平顶山市",
1112 id: "410400"
1113 }, {
1114 province: "河南省",
1115 name: "安阳市",
1116 id: "410500"
1117 }, {
1118 province: "河南省",
1119 name: "鹤壁市",
1120 id: "410600"
1121 }, {
1122 province: "河南省",
1123 name: "新乡市",
1124 id: "410700"
1125 }, {
1126 province: "河南省",
1127 name: "焦作市",
1128 id: "410800"
1129 }, {
1130 province: "河南省",
1131 name: "濮阳市",
1132 id: "410900"
1133 }, {
1134 province: "河南省",
1135 name: "许昌市",
1136 id: "411000"
1137 }, {
1138 province: "河南省",
1139 name: "漯河市",
1140 id: "411100"
1141 }, {
1142 province: "河南省",
1143 name: "三门峡市",
1144 id: "411200"
1145 }, {
1146 province: "河南省",
1147 name: "南阳市",
1148 id: "411300"
1149 }, {
1150 province: "河南省",
1151 name: "商丘市",
1152 id: "411400"
1153 }, {
1154 province: "河南省",
1155 name: "信阳市",
1156 id: "411500"
1157 }, {
1158 province: "河南省",
1159 name: "周口市",
1160 id: "411600"
1161 }, {
1162 province: "河南省",
1163 name: "驻马店市",
1164 id: "411700"
1165 }, {
1166 province: "河南省",
1167 name: "省直辖县级行政区划",
1168 id: "419000"
1169 }],
1170 "420000": [{
1171 province: "湖北省",
1172 name: "武汉市",
1173 id: "420100"
1174 }, {
1175 province: "湖北省",
1176 name: "黄石市",
1177 id: "420200"
1178 }, {
1179 province: "湖北省",
1180 name: "十堰市",
1181 id: "420300"
1182 }, {
1183 province: "湖北省",
1184 name: "宜昌市",
1185 id: "420500"
1186 }, {
1187 province: "湖北省",
1188 name: "襄阳市",
1189 id: "420600"
1190 }, {
1191 province: "湖北省",
1192 name: "鄂州市",
1193 id: "420700"
1194 }, {
1195 province: "湖北省",
1196 name: "荆门市",
1197 id: "420800"
1198 }, {
1199 province: "湖北省",
1200 name: "孝感市",
1201 id: "420900"
1202 }, {
1203 province: "湖北省",
1204 name: "荆州市",
1205 id: "421000"
1206 }, {
1207 province: "湖北省",
1208 name: "黄冈市",
1209 id: "421100"
1210 }, {
1211 province: "湖北省",
1212 name: "咸宁市",
1213 id: "421200"
1214 }, {
1215 province: "湖北省",
1216 name: "随州市",
1217 id: "421300"
1218 }, {
1219 province: "湖北省",
1220 name: "恩施土家族苗族自治州",
1221 id: "422800"
1222 }, {
1223 province: "湖北省",
1224 name: "省直辖县级行政区划",
1225 id: "429000"
1226 }],
1227 "430000": [{
1228 province: "湖南省",
1229 name: "长沙市",
1230 id: "430100"
1231 }, {
1232 province: "湖南省",
1233 name: "株洲市",
1234 id: "430200"
1235 }, {
1236 province: "湖南省",
1237 name: "湘潭市",
1238 id: "430300"
1239 }, {
1240 province: "湖南省",
1241 name: "衡阳市",
1242 id: "430400"
1243 }, {
1244 province: "湖南省",
1245 name: "邵阳市",
1246 id: "430500"
1247 }, {
1248 province: "湖南省",
1249 name: "岳阳市",
1250 id: "430600"
1251 }, {
1252 province: "湖南省",
1253 name: "常德市",
1254 id: "430700"
1255 }, {
1256 province: "湖南省",
1257 name: "张家界市",
1258 id: "430800"
1259 }, {
1260 province: "湖南省",
1261 name: "益阳市",
1262 id: "430900"
1263 }, {
1264 province: "湖南省",
1265 name: "郴州市",
1266 id: "431000"
1267 }, {
1268 province: "湖南省",
1269 name: "永州市",
1270 id: "431100"
1271 }, {
1272 province: "湖南省",
1273 name: "怀化市",
1274 id: "431200"
1275 }, {
1276 province: "湖南省",
1277 name: "娄底市",
1278 id: "431300"
1279 }, {
1280 province: "湖南省",
1281 name: "湘西土家族苗族自治州",
1282 id: "433100"
1283 }],
1284 "440000": [{
1285 province: "广东省",
1286 name: "广州市",
1287 id: "440100"
1288 }, {
1289 province: "广东省",
1290 name: "韶关市",
1291 id: "440200"
1292 }, {
1293 province: "广东省",
1294 name: "深圳市",
1295 id: "440300"
1296 }, {
1297 province: "广东省",
1298 name: "珠海市",
1299 id: "440400"
1300 }, {
1301 province: "广东省",
1302 name: "汕头市",
1303 id: "440500"
1304 }, {
1305 province: "广东省",
1306 name: "佛山市",
1307 id: "440600"
1308 }, {
1309 province: "广东省",
1310 name: "江门市",
1311 id: "440700"
1312 }, {
1313 province: "广东省",
1314 name: "湛江市",
1315 id: "440800"
1316 }, {
1317 province: "广东省",
1318 name: "茂名市",
1319 id: "440900"
1320 }, {
1321 province: "广东省",
1322 name: "肇庆市",
1323 id: "441200"
1324 }, {
1325 province: "广东省",
1326 name: "惠州市",
1327 id: "441300"
1328 }, {
1329 province: "广东省",
1330 name: "梅州市",
1331 id: "441400"
1332 }, {
1333 province: "广东省",
1334 name: "汕尾市",
1335 id: "441500"
1336 }, {
1337 province: "广东省",
1338 name: "河源市",
1339 id: "441600"
1340 }, {
1341 province: "广东省",
1342 name: "阳江市",
1343 id: "441700"
1344 }, {
1345 province: "广东省",
1346 name: "清远市",
1347 id: "441800"
1348 }, {
1349 province: "广东省",
1350 name: "东莞市",
1351 id: "441900"
1352 }, {
1353 province: "广东省",
1354 name: "中山市",
1355 id: "442000"
1356 }, {
1357 province: "广东省",
1358 name: "潮州市",
1359 id: "445100"
1360 }, {
1361 province: "广东省",
1362 name: "揭阳市",
1363 id: "445200"
1364 }, {
1365 province: "广东省",
1366 name: "云浮市",
1367 id: "445300"
1368 }],
1369 "450000": [{
1370 province: "广西壮族自治区",
1371 name: "南宁市",
1372 id: "450100"
1373 }, {
1374 province: "广西壮族自治区",
1375 name: "柳州市",
1376 id: "450200"
1377 }, {
1378 province: "广西壮族自治区",
1379 name: "桂林市",
1380 id: "450300"
1381 }, {
1382 province: "广西壮族自治区",
1383 name: "梧州市",
1384 id: "450400"
1385 }, {
1386 province: "广西壮族自治区",
1387 name: "北海市",
1388 id: "450500"
1389 }, {
1390 province: "广西壮族自治区",
1391 name: "防城港市",
1392 id: "450600"
1393 }, {
1394 province: "广西壮族自治区",
1395 name: "钦州市",
1396 id: "450700"
1397 }, {
1398 province: "广西壮族自治区",
1399 name: "贵港市",
1400 id: "450800"
1401 }, {
1402 province: "广西壮族自治区",
1403 name: "玉林市",
1404 id: "450900"
1405 }, {
1406 province: "广西壮族自治区",
1407 name: "百色市",
1408 id: "451000"
1409 }, {
1410 province: "广西壮族自治区",
1411 name: "贺州市",
1412 id: "451100"
1413 }, {
1414 province: "广西壮族自治区",
1415 name: "河池市",
1416 id: "451200"
1417 }, {
1418 province: "广西壮族自治区",
1419 name: "来宾市",
1420 id: "451300"
1421 }, {
1422 province: "广西壮族自治区",
1423 name: "崇左市",
1424 id: "451400"
1425 }],
1426 "460000": [{
1427 province: "海南省",
1428 name: "海口市",
1429 id: "460100"
1430 }, {
1431 province: "海南省",
1432 name: "三亚市",
1433 id: "460200"
1434 }, {
1435 province: "海南省",
1436 name: "三沙市",
1437 id: "460300"
1438 }, {
1439 province: "海南省",
1440 name: "儋州市",
1441 id: "460400"
1442 }, {
1443 province: "海南省",
1444 name: "省直辖县级行政区划",
1445 id: "469000"
1446 }],
1447 "500000": [{
1448 province: "重庆市",
1449 name: "市辖区",
1450 id: "500100"
1451 }, {
1452 province: "重庆市",
1453 name: "县",
1454 id: "500200"
1455 }],
1456 "510000": [{
1457 province: "四川省",
1458 name: "成都市",
1459 id: "510100"
1460 }, {
1461 province: "四川省",
1462 name: "自贡市",
1463 id: "510300"
1464 }, {
1465 province: "四川省",
1466 name: "攀枝花市",
1467 id: "510400"
1468 }, {
1469 province: "四川省",
1470 name: "泸州市",
1471 id: "510500"
1472 }, {
1473 province: "四川省",
1474 name: "德阳市",
1475 id: "510600"
1476 }, {
1477 province: "四川省",
1478 name: "绵阳市",
1479 id: "510700"
1480 }, {
1481 province: "四川省",
1482 name: "广元市",
1483 id: "510800"
1484 }, {
1485 province: "四川省",
1486 name: "遂宁市",
1487 id: "510900"
1488 }, {
1489 province: "四川省",
1490 name: "内江市",
1491 id: "511000"
1492 }, {
1493 province: "四川省",
1494 name: "乐山市",
1495 id: "511100"
1496 }, {
1497 province: "四川省",
1498 name: "南充市",
1499 id: "511300"
1500 }, {
1501 province: "四川省",
1502 name: "眉山市",
1503 id: "511400"
1504 }, {
1505 province: "四川省",
1506 name: "宜宾市",
1507 id: "511500"
1508 }, {
1509 province: "四川省",
1510 name: "广安市",
1511 id: "511600"
1512 }, {
1513 province: "四川省",
1514 name: "达州市",
1515 id: "511700"
1516 }, {
1517 province: "四川省",
1518 name: "雅安市",
1519 id: "511800"
1520 }, {
1521 province: "四川省",
1522 name: "巴中市",
1523 id: "511900"
1524 }, {
1525 province: "四川省",
1526 name: "资阳市",
1527 id: "512000"
1528 }, {
1529 province: "四川省",
1530 name: "阿坝藏族羌族自治州",
1531 id: "513200"
1532 }, {
1533 province: "四川省",
1534 name: "甘孜藏族自治州",
1535 id: "513300"
1536 }, {
1537 province: "四川省",
1538 name: "凉山彝族自治州",
1539 id: "513400"
1540 }],
1541 "520000": [{
1542 province: "贵州省",
1543 name: "贵阳市",
1544 id: "520100"
1545 }, {
1546 province: "贵州省",
1547 name: "六盘水市",
1548 id: "520200"
1549 }, {
1550 province: "贵州省",
1551 name: "遵义市",
1552 id: "520300"
1553 }, {
1554 province: "贵州省",
1555 name: "安顺市",
1556 id: "520400"
1557 }, {
1558 province: "贵州省",
1559 name: "毕节市",
1560 id: "520500"
1561 }, {
1562 province: "贵州省",
1563 name: "铜仁市",
1564 id: "520600"
1565 }, {
1566 province: "贵州省",
1567 name: "黔西南布依族苗族自治州",
1568 id: "522300"
1569 }, {
1570 province: "贵州省",
1571 name: "黔东南苗族侗族自治州",
1572 id: "522600"
1573 }, {
1574 province: "贵州省",
1575 name: "黔南布依族苗族自治州",
1576 id: "522700"
1577 }],
1578 "530000": [{
1579 province: "云南省",
1580 name: "昆明市",
1581 id: "530100"
1582 }, {
1583 province: "云南省",
1584 name: "曲靖市",
1585 id: "530300"
1586 }, {
1587 province: "云南省",
1588 name: "玉溪市",
1589 id: "530400"
1590 }, {
1591 province: "云南省",
1592 name: "保山市",
1593 id: "530500"
1594 }, {
1595 province: "云南省",
1596 name: "昭通市",
1597 id: "530600"
1598 }, {
1599 province: "云南省",
1600 name: "丽江市",
1601 id: "530700"
1602 }, {
1603 province: "云南省",
1604 name: "普洱市",
1605 id: "530800"
1606 }, {
1607 province: "云南省",
1608 name: "临沧市",
1609 id: "530900"
1610 }, {
1611 province: "云南省",
1612 name: "楚雄彝族自治州",
1613 id: "532300"
1614 }, {
1615 province: "云南省",
1616 name: "红河哈尼族彝族自治州",
1617 id: "532500"
1618 }, {
1619 province: "云南省",
1620 name: "文山壮族苗族自治州",
1621 id: "532600"
1622 }, {
1623 province: "云南省",
1624 name: "西双版纳傣族自治州",
1625 id: "532800"
1626 }, {
1627 province: "云南省",
1628 name: "大理白族自治州",
1629 id: "532900"
1630 }, {
1631 province: "云南省",
1632 name: "德宏傣族景颇族自治州",
1633 id: "533100"
1634 }, {
1635 province: "云南省",
1636 name: "怒江傈僳族自治州",
1637 id: "533300"
1638 }, {
1639 province: "云南省",
1640 name: "迪庆藏族自治州",
1641 id: "533400"
1642 }],
1643 "540000": [{
1644 province: "西藏自治区",
1645 name: "拉萨市",
1646 id: "540100"
1647 }, {
1648 province: "西藏自治区",
1649 name: "日喀则市",
1650 id: "540200"
1651 }, {
1652 province: "西藏自治区",
1653 name: "昌都市",
1654 id: "540300"
1655 }, {
1656 province: "西藏自治区",
1657 name: "林芝市",
1658 id: "540400"
1659 }, {
1660 province: "西藏自治区",
1661 name: "山南市",
1662 id: "540500"
1663 }, {
1664 province: "西藏自治区",
1665 name: "那曲地区",
1666 id: "542400"
1667 }, {
1668 province: "西藏自治区",
1669 name: "阿里地区",
1670 id: "542500"
1671 }],
1672 "610000": [{
1673 province: "陕西省",
1674 name: "西安市",
1675 id: "610100"
1676 }, {
1677 province: "陕西省",
1678 name: "铜川市",
1679 id: "610200"
1680 }, {
1681 province: "陕西省",
1682 name: "宝鸡市",
1683 id: "610300"
1684 }, {
1685 province: "陕西省",
1686 name: "咸阳市",
1687 id: "610400"
1688 }, {
1689 province: "陕西省",
1690 name: "渭南市",
1691 id: "610500"
1692 }, {
1693 province: "陕西省",
1694 name: "延安市",
1695 id: "610600"
1696 }, {
1697 province: "陕西省",
1698 name: "汉中市",
1699 id: "610700"
1700 }, {
1701 province: "陕西省",
1702 name: "榆林市",
1703 id: "610800"
1704 }, {
1705 province: "陕西省",
1706 name: "安康市",
1707 id: "610900"
1708 }, {
1709 province: "陕西省",
1710 name: "商洛市",
1711 id: "611000"
1712 }],
1713 "620000": [{
1714 province: "甘肃省",
1715 name: "兰州市",
1716 id: "620100"
1717 }, {
1718 province: "甘肃省",
1719 name: "嘉峪关市",
1720 id: "620200"
1721 }, {
1722 province: "甘肃省",
1723 name: "金昌市",
1724 id: "620300"
1725 }, {
1726 province: "甘肃省",
1727 name: "白银市",
1728 id: "620400"
1729 }, {
1730 province: "甘肃省",
1731 name: "天水市",
1732 id: "620500"
1733 }, {
1734 province: "甘肃省",
1735 name: "武威市",
1736 id: "620600"
1737 }, {
1738 province: "甘肃省",
1739 name: "张掖市",
1740 id: "620700"
1741 }, {
1742 province: "甘肃省",
1743 name: "平凉市",
1744 id: "620800"
1745 }, {
1746 province: "甘肃省",
1747 name: "酒泉市",
1748 id: "620900"
1749 }, {
1750 province: "甘肃省",
1751 name: "庆阳市",
1752 id: "621000"
1753 }, {
1754 province: "甘肃省",
1755 name: "定西市",
1756 id: "621100"
1757 }, {
1758 province: "甘肃省",
1759 name: "陇南市",
1760 id: "621200"
1761 }, {
1762 province: "甘肃省",
1763 name: "临夏回族自治州",
1764 id: "622900"
1765 }, {
1766 province: "甘肃省",
1767 name: "甘南藏族自治州",
1768 id: "623000"
1769 }],
1770 "630000": [{
1771 province: "青海省",
1772 name: "西宁市",
1773 id: "630100"
1774 }, {
1775 province: "青海省",
1776 name: "海东市",
1777 id: "630200"
1778 }, {
1779 province: "青海省",
1780 name: "海北藏族自治州",
1781 id: "632200"
1782 }, {
1783 province: "青海省",
1784 name: "黄南藏族自治州",
1785 id: "632300"
1786 }, {
1787 province: "青海省",
1788 name: "海南藏族自治州",
1789 id: "632500"
1790 }, {
1791 province: "青海省",
1792 name: "果洛藏族自治州",
1793 id: "632600"
1794 }, {
1795 province: "青海省",
1796 name: "玉树藏族自治州",
1797 id: "632700"
1798 }, {
1799 province: "青海省",
1800 name: "海西蒙古族藏族自治州",
1801 id: "632800"
1802 }],
1803 "640000": [{
1804 province: "宁夏回族自治区",
1805 name: "银川市",
1806 id: "640100"
1807 }, {
1808 province: "宁夏回族自治区",
1809 name: "石嘴山市",
1810 id: "640200"
1811 }, {
1812 province: "宁夏回族自治区",
1813 name: "吴忠市",
1814 id: "640300"
1815 }, {
1816 province: "宁夏回族自治区",
1817 name: "固原市",
1818 id: "640400"
1819 }, {
1820 province: "宁夏回族自治区",
1821 name: "中卫市",
1822 id: "640500"
1823 }],
1824 "650000": [{
1825 province: "新疆维吾尔自治区",
1826 name: "乌鲁木齐市",
1827 id: "650100"
1828 }, {
1829 province: "新疆维吾尔自治区",
1830 name: "克拉玛依市",
1831 id: "650200"
1832 }, {
1833 province: "新疆维吾尔自治区",
1834 name: "吐鲁番市",
1835 id: "650400"
1836 }, {
1837 province: "新疆维吾尔自治区",
1838 name: "哈密市",
1839 id: "650500"
1840 }, {
1841 province: "新疆维吾尔自治区",
1842 name: "昌吉回族自治州",
1843 id: "652300"
1844 }, {
1845 province: "新疆维吾尔自治区",
1846 name: "博尔塔拉蒙古自治州",
1847 id: "652700"
1848 }, {
1849 province: "新疆维吾尔自治区",
1850 name: "巴音郭楞蒙古自治州",
1851 id: "652800"
1852 }, {
1853 province: "新疆维吾尔自治区",
1854 name: "阿克苏地区",
1855 id: "652900"
1856 }, {
1857 province: "新疆维吾尔自治区",
1858 name: "克孜勒苏柯尔克孜自治州",
1859 id: "653000"
1860 }, {
1861 province: "新疆维吾尔自治区",
1862 name: "喀什地区",
1863 id: "653100"
1864 }, {
1865 province: "新疆维吾尔自治区",
1866 name: "和田地区",
1867 id: "653200"
1868 }, {
1869 province: "新疆维吾尔自治区",
1870 name: "伊犁哈萨克自治州",
1871 id: "654000"
1872 }, {
1873 province: "新疆维吾尔自治区",
1874 name: "塔城地区",
1875 id: "654200"
1876 }, {
1877 province: "新疆维吾尔自治区",
1878 name: "阿勒泰地区",
1879 id: "654300"
1880 }, {
1881 province: "新疆维吾尔自治区",
1882 name: "自治区直辖县级行政区划",
1883 id: "659000"
1884 }]
1885 };
1886
1887 var province = [{
1888 "name": "北京市",
1889 "id": "110000"
1890 }, {
1891 "name": "天津市",
1892 "id": "120000"
1893 }, {
1894 "name": "河北省",
1895 "id": "130000"
1896 }, {
1897 "name": "山西省",
1898 "id": "140000"
1899 }, {
1900 "name": "内蒙古自治区",
1901 "id": "150000"
1902 }, {
1903 "name": "辽宁省",
1904 "id": "210000"
1905 }, {
1906 "name": "吉林省",
1907 "id": "220000"
1908 }, {
1909 "name": "黑龙江省",
1910 "id": "230000"
1911 }, {
1912 "name": "上海市",
1913 "id": "310000"
1914 }, {
1915 "name": "江苏省",
1916 "id": "320000"
1917 }, {
1918 "name": "浙江省",
1919 "id": "330000"
1920 }, {
1921 "name": "安徽省",
1922 "id": "340000"
1923 }, {
1924 "name": "福建省",
1925 "id": "350000"
1926 }, {
1927 "name": "江西省",
1928 "id": "360000"
1929 }, {
1930 "name": "山东省",
1931 "id": "370000"
1932 }, {
1933 "name": "河南省",
1934 "id": "410000"
1935 }, {
1936 "name": "湖北省",
1937 "id": "420000"
1938 }, {
1939 "name": "湖南省",
1940 "id": "430000"
1941 }, {
1942 "name": "广东省",
1943 "id": "440000"
1944 }, {
1945 "name": "广西壮族自治区",
1946 "id": "450000"
1947 }, {
1948 "name": "海南省",
1949 "id": "460000"
1950 }, {
1951 "name": "重庆市",
1952 "id": "500000"
1953 }, {
1954 "name": "四川省",
1955 "id": "510000"
1956 }, {
1957 "name": "贵州省",
1958 "id": "520000"
1959 }, {
1960 "name": "云南省",
1961 "id": "530000"
1962 }, {
1963 "name": "西藏自治区",
1964 "id": "540000"
1965 }, {
1966 "name": "陕西省",
1967 "id": "610000"
1968 }, {
1969 "name": "甘肃省",
1970 "id": "620000"
1971 }, {
1972 "name": "青海省",
1973 "id": "630000"
1974 }, {
1975 "name": "宁夏回族自治区",
1976 "id": "640000"
1977 }, {
1978 "name": "新疆维吾尔自治区",
1979 "id": "650000"
1980 }, {
1981 "name": "台湾省",
1982 "id": "710000"
1983 }, {
1984 "name": "香港特别行政区",
1985 "id": "810000"
1986 }, {
1987 "name": "澳门特别行政区",
1988 "id": "820000"
1989 }];
1990
1991 function getProvince(req, res) {
1992 res.json(province);
1993 }
1994
1995 function getCity(req, res) {
1996 res.json(city[req.params.province]);
1997 }
1998
1999 var geographic = {
2000 'GET /api/geographic/province': getProvince,
2001 'GET /api/geographic/city/:province': getCity
2002 };
2003
2004 var getNotices = function getNotices(req, res) {
2005 res.json([{
2006 id: '000000001',
2007 avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png',
2008 title: '你收到了 14 份新周报',
2009 datetime: '2017-08-09',
2010 type: '通知'
2011 }, {
2012 id: '000000002',
2013 avatar: 'https://gw.alipayobjects.com/zos/rmsportal/OKJXDXrmkNshAMvwtvhu.png',
2014 title: '你推荐的 曲妮妮 已通过第三轮面试',
2015 datetime: '2017-08-08',
2016 type: '通知'
2017 }, {
2018 id: '000000003',
2019 avatar: 'https://gw.alipayobjects.com/zos/rmsportal/kISTdvpyTAhtGxpovNWd.png',
2020 title: '这种模板可以区分多种通知类型',
2021 datetime: '2017-08-07',
2022 read: true,
2023 type: '通知'
2024 }, {
2025 id: '000000004',
2026 avatar: 'https://gw.alipayobjects.com/zos/rmsportal/GvqBnKhFgObvnSGkDsje.png',
2027 title: '左侧图标用于区分不同的类型',
2028 datetime: '2017-08-07',
2029 type: '通知'
2030 }, {
2031 id: '000000005',
2032 avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ThXAXghbEsBCCSDihZxY.png',
2033 title: '内容不要超过两行字,超出时自动截断',
2034 datetime: '2017-08-07',
2035 type: '通知'
2036 }, {
2037 id: '000000006',
2038 avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg',
2039 title: '曲丽丽 评论了你',
2040 description: '描述信息描述信息描述信息',
2041 datetime: '2017-08-07',
2042 type: '消息'
2043 }, {
2044 id: '000000007',
2045 avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg',
2046 title: '朱偏右 回复了你',
2047 description: '这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像',
2048 datetime: '2017-08-07',
2049 type: '消息'
2050 }, {
2051 id: '000000008',
2052 avatar: 'https://gw.alipayobjects.com/zos/rmsportal/fcHMVNCjPOsbUGdEduuv.jpeg',
2053 title: '标题',
2054 description: '这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像',
2055 datetime: '2017-08-07',
2056 type: '消息'
2057 }, {
2058 id: '000000009',
2059 title: '任务名称',
2060 description: '任务需要在 2017-01-12 20:00 前启动',
2061 extra: '未开始',
2062 status: 'todo',
2063 type: '待办'
2064 }, {
2065 id: '000000010',
2066 title: '第三方紧急代码变更',
2067 description: '冠霖提交于 2017-01-06,需在 2017-01-07 前完成代码变更任务',
2068 extra: '马上到期',
2069 status: 'urgent',
2070 type: '待办'
2071 }, {
2072 id: '000000011',
2073 title: '信息安全考试',
2074 description: '指派竹尔于 2017-01-09 前完成更新并发布',
2075 extra: '已耗时 8 天',
2076 status: 'doing',
2077 type: '待办'
2078 }, {
2079 id: '000000012',
2080 title: 'ABCD 版本发布',
2081 description: '冠霖提交于 2017-01-06,需在 2017-01-07 前完成代码变更任务',
2082 extra: '进行中',
2083 status: 'processing',
2084 type: '待办'
2085 }]);
2086 };
2087
2088 var notices = {
2089 'GET /api/notices': getNotices
2090 };
2091
2092 var basicGoods = [{
2093 id: '1234561',
2094 name: '矿泉水 550ml',
2095 barcode: '12421432143214321',
2096 price: '2.00',
2097 num: '1',
2098 amount: '2.00'
2099 }, {
2100 id: '1234562',
2101 name: '凉茶 300ml',
2102 barcode: '12421432143214322',
2103 price: '3.00',
2104 num: '2',
2105 amount: '6.00'
2106 }, {
2107 id: '1234563',
2108 name: '好吃的薯片',
2109 barcode: '12421432143214323',
2110 price: '7.00',
2111 num: '4',
2112 amount: '28.00'
2113 }, {
2114 id: '1234564',
2115 name: '特别好吃的蛋卷',
2116 barcode: '12421432143214324',
2117 price: '8.50',
2118 num: '3',
2119 amount: '25.50'
2120 }];
2121 var basicProgress = [{
2122 key: '1',
2123 time: '2017-10-01 14:10',
2124 rate: '联系客户',
2125 status: 'processing',
2126 operator: '取货员 ID1234',
2127 cost: '5mins'
2128 }, {
2129 key: '2',
2130 time: '2017-10-01 14:05',
2131 rate: '取货员出发',
2132 status: 'success',
2133 operator: '取货员 ID1234',
2134 cost: '1h'
2135 }, {
2136 key: '3',
2137 time: '2017-10-01 13:05',
2138 rate: '取货员接单',
2139 status: 'success',
2140 operator: '取货员 ID1234',
2141 cost: '5mins'
2142 }, {
2143 key: '4',
2144 time: '2017-10-01 13:00',
2145 rate: '申请审批通过',
2146 status: 'success',
2147 operator: '系统',
2148 cost: '1h'
2149 }, {
2150 key: '5',
2151 time: '2017-10-01 12:00',
2152 rate: '发起退货申请',
2153 status: 'success',
2154 operator: '用户',
2155 cost: '5mins'
2156 }];
2157 var advancedOperation1 = [{
2158 key: 'op1',
2159 type: '订购关系生效',
2160 name: '曲丽丽',
2161 status: 'agree',
2162 updatedAt: '2017-10-03 19:23:12',
2163 memo: '-'
2164 }, {
2165 key: 'op2',
2166 type: '财务复审',
2167 name: '付小小',
2168 status: 'reject',
2169 updatedAt: '2017-10-03 19:23:12',
2170 memo: '不通过原因'
2171 }, {
2172 key: 'op3',
2173 type: '部门初审',
2174 name: '周毛毛',
2175 status: 'agree',
2176 updatedAt: '2017-10-03 19:23:12',
2177 memo: '-'
2178 }, {
2179 key: 'op4',
2180 type: '提交订单',
2181 name: '林东东',
2182 status: 'agree',
2183 updatedAt: '2017-10-03 19:23:12',
2184 memo: '很棒'
2185 }, {
2186 key: 'op5',
2187 type: '创建订单',
2188 name: '汗牙牙',
2189 status: 'agree',
2190 updatedAt: '2017-10-03 19:23:12',
2191 memo: '-'
2192 }];
2193 var advancedOperation2 = [{
2194 key: 'op1',
2195 type: '订购关系生效',
2196 name: '曲丽丽',
2197 status: 'agree',
2198 updatedAt: '2017-10-03 19:23:12',
2199 memo: '-'
2200 }];
2201 var advancedOperation3 = [{
2202 key: 'op1',
2203 type: '创建订单',
2204 name: '汗牙牙',
2205 status: 'agree',
2206 updatedAt: '2017-10-03 19:23:12',
2207 memo: '-'
2208 }];
2209 var getProfileBasicData = {
2210 basicGoods: basicGoods,
2211 basicProgress: basicProgress
2212 };
2213 var getProfileAdvancedData = {
2214 advancedOperation1: advancedOperation1,
2215 advancedOperation2: advancedOperation2,
2216 advancedOperation3: advancedOperation3
2217 };
2218 var profile = {
2219 'GET /api/profile/advanced': getProfileAdvancedData,
2220 'GET /api/profile/basic': getProfileBasicData
2221 };
2222
2223 /*! https://mths.be/punycode v1.4.1 by @mathias */
2224
2225
2226 /** Highest positive signed 32-bit float value */
2227 var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
2228
2229 /** Bootstring parameters */
2230 var base = 36;
2231 var tMin = 1;
2232 var tMax = 26;
2233 var skew = 38;
2234 var damp = 700;
2235 var initialBias = 72;
2236 var initialN = 128; // 0x80
2237 var delimiter = '-'; // '\x2D'
2238 var regexNonASCII = /[^\x20-\x7E]/; // unprintable ASCII chars + non-ASCII chars
2239 var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g; // RFC 3490 separators
2240
2241 /** Error messages */
2242 var errors = {
2243 'overflow': 'Overflow: input needs wider integers to process',
2244 'not-basic': 'Illegal input >= 0x80 (not a basic code point)',
2245 'invalid-input': 'Invalid input'
2246 };
2247
2248 /** Convenience shortcuts */
2249 var baseMinusTMin = base - tMin;
2250 var floor = Math.floor;
2251 var stringFromCharCode = String.fromCharCode;
2252
2253 /*--------------------------------------------------------------------------*/
2254
2255 /**
2256 * A generic error utility function.
2257 * @private
2258 * @param {String} type The error type.
2259 * @returns {Error} Throws a `RangeError` with the applicable error message.
2260 */
2261 function error(type) {
2262 throw new RangeError(errors[type]);
2263 }
2264
2265 /**
2266 * A generic `Array#map` utility function.
2267 * @private
2268 * @param {Array} array The array to iterate over.
2269 * @param {Function} callback The function that gets called for every array
2270 * item.
2271 * @returns {Array} A new array of values returned by the callback function.
2272 */
2273 function map(array, fn) {
2274 var length = array.length;
2275 var result = [];
2276 while (length--) {
2277 result[length] = fn(array[length]);
2278 }
2279 return result;
2280 }
2281
2282 /**
2283 * A simple `Array#map`-like wrapper to work with domain name strings or email
2284 * addresses.
2285 * @private
2286 * @param {String} domain The domain name or email address.
2287 * @param {Function} callback The function that gets called for every
2288 * character.
2289 * @returns {Array} A new string of characters returned by the callback
2290 * function.
2291 */
2292 function mapDomain(string, fn) {
2293 var parts = string.split('@');
2294 var result = '';
2295 if (parts.length > 1) {
2296 // In email addresses, only the domain name should be punycoded. Leave
2297 // the local part (i.e. everything up to `@`) intact.
2298 result = parts[0] + '@';
2299 string = parts[1];
2300 }
2301 // Avoid `split(regex)` for IE8 compatibility. See #17.
2302 string = string.replace(regexSeparators, '\x2E');
2303 var labels = string.split('.');
2304 var encoded = map(labels, fn).join('.');
2305 return result + encoded;
2306 }
2307
2308 /**
2309 * Creates an array containing the numeric code points of each Unicode
2310 * character in the string. While JavaScript uses UCS-2 internally,
2311 * this function will convert a pair of surrogate halves (each of which
2312 * UCS-2 exposes as separate characters) into a single code point,
2313 * matching UTF-16.
2314 * @see `punycode.ucs2.encode`
2315 * @see <https://mathiasbynens.be/notes/javascript-encoding>
2316 * @memberOf punycode.ucs2
2317 * @name decode
2318 * @param {String} string The Unicode input string (UCS-2).
2319 * @returns {Array} The new array of code points.
2320 */
2321 function ucs2decode(string) {
2322 var output = [],
2323 counter = 0,
2324 length = string.length,
2325 value,
2326 extra;
2327 while (counter < length) {
2328 value = string.charCodeAt(counter++);
2329 if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
2330 // high surrogate, and there is a next character
2331 extra = string.charCodeAt(counter++);
2332 if ((extra & 0xFC00) == 0xDC00) { // low surrogate
2333 output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
2334 } else {
2335 // unmatched surrogate; only append this code unit, in case the next
2336 // code unit is the high surrogate of a surrogate pair
2337 output.push(value);
2338 counter--;
2339 }
2340 } else {
2341 output.push(value);
2342 }
2343 }
2344 return output;
2345 }
2346
2347 /**
2348 * Converts a digit/integer into a basic code point.
2349 * @see `basicToDigit()`
2350 * @private
2351 * @param {Number} digit The numeric value of a basic code point.
2352 * @returns {Number} The basic code point whose value (when used for
2353 * representing integers) is `digit`, which needs to be in the range
2354 * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is
2355 * used; else, the lowercase form is used. The behavior is undefined
2356 * if `flag` is non-zero and `digit` has no uppercase form.
2357 */
2358 function digitToBasic(digit, flag) {
2359 // 0..25 map to ASCII a..z or A..Z
2360 // 26..35 map to ASCII 0..9
2361 return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
2362 }
2363
2364 /**
2365 * Bias adaptation function as per section 3.4 of RFC 3492.
2366 * https://tools.ietf.org/html/rfc3492#section-3.4
2367 * @private
2368 */
2369 function adapt(delta, numPoints, firstTime) {
2370 var k = 0;
2371 delta = firstTime ? floor(delta / damp) : delta >> 1;
2372 delta += floor(delta / numPoints);
2373 for ( /* no initialization */ ; delta > baseMinusTMin * tMax >> 1; k += base) {
2374 delta = floor(delta / baseMinusTMin);
2375 }
2376 return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
2377 }
2378
2379 /**
2380 * Converts a string of Unicode symbols (e.g. a domain name label) to a
2381 * Punycode string of ASCII-only symbols.
2382 * @memberOf punycode
2383 * @param {String} input The string of Unicode symbols.
2384 * @returns {String} The resulting Punycode string of ASCII-only symbols.
2385 */
2386 function encode(input) {
2387 var n,
2388 delta,
2389 handledCPCount,
2390 basicLength,
2391 bias,
2392 j,
2393 m,
2394 q,
2395 k,
2396 t,
2397 currentValue,
2398 output = [],
2399 /** `inputLength` will hold the number of code points in `input`. */
2400 inputLength,
2401 /** Cached calculation results */
2402 handledCPCountPlusOne,
2403 baseMinusT,
2404 qMinusT;
2405
2406 // Convert the input in UCS-2 to Unicode
2407 input = ucs2decode(input);
2408
2409 // Cache the length
2410 inputLength = input.length;
2411
2412 // Initialize the state
2413 n = initialN;
2414 delta = 0;
2415 bias = initialBias;
2416
2417 // Handle the basic code points
2418 for (j = 0; j < inputLength; ++j) {
2419 currentValue = input[j];
2420 if (currentValue < 0x80) {
2421 output.push(stringFromCharCode(currentValue));
2422 }
2423 }
2424
2425 handledCPCount = basicLength = output.length;
2426
2427 // `handledCPCount` is the number of code points that have been handled;
2428 // `basicLength` is the number of basic code points.
2429
2430 // Finish the basic string - if it is not empty - with a delimiter
2431 if (basicLength) {
2432 output.push(delimiter);
2433 }
2434
2435 // Main encoding loop:
2436 while (handledCPCount < inputLength) {
2437
2438 // All non-basic code points < n have been handled already. Find the next
2439 // larger one:
2440 for (m = maxInt, j = 0; j < inputLength; ++j) {
2441 currentValue = input[j];
2442 if (currentValue >= n && currentValue < m) {
2443 m = currentValue;
2444 }
2445 }
2446
2447 // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>,
2448 // but guard against overflow
2449 handledCPCountPlusOne = handledCPCount + 1;
2450 if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) {
2451 error('overflow');
2452 }
2453
2454 delta += (m - n) * handledCPCountPlusOne;
2455 n = m;
2456
2457 for (j = 0; j < inputLength; ++j) {
2458 currentValue = input[j];
2459
2460 if (currentValue < n && ++delta > maxInt) {
2461 error('overflow');
2462 }
2463
2464 if (currentValue == n) {
2465 // Represent delta as a generalized variable-length integer
2466 for (q = delta, k = base; /* no condition */ ; k += base) {
2467 t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias);
2468 if (q < t) {
2469 break;
2470 }
2471 qMinusT = q - t;
2472 baseMinusT = base - t;
2473 output.push(
2474 stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))
2475 );
2476 q = floor(qMinusT / baseMinusT);
2477 }
2478
2479 output.push(stringFromCharCode(digitToBasic(q, 0)));
2480 bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
2481 delta = 0;
2482 ++handledCPCount;
2483 }
2484 }
2485
2486 ++delta;
2487 ++n;
2488
2489 }
2490 return output.join('');
2491 }
2492
2493 /**
2494 * Converts a Unicode string representing a domain name or an email address to
2495 * Punycode. Only the non-ASCII parts of the domain name will be converted,
2496 * i.e. it doesn't matter if you call it with a domain that's already in
2497 * ASCII.
2498 * @memberOf punycode
2499 * @param {String} input The domain name or email address to convert, as a
2500 * Unicode string.
2501 * @returns {String} The Punycode representation of the given domain name or
2502 * email address.
2503 */
2504 function toASCII(input) {
2505 return mapDomain(input, function(string) {
2506 return regexNonASCII.test(string) ?
2507 'xn--' + encode(string) :
2508 string;
2509 });
2510 }
2511
2512 // shim for using process in browser
2513 if (typeof global.setTimeout === 'function') ;
2514 if (typeof global.clearTimeout === 'function') ;
2515
2516 // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
2517 var performance = global.performance || {};
2518 var performanceNow =
2519 performance.now ||
2520 performance.mozNow ||
2521 performance.msNow ||
2522 performance.oNow ||
2523 performance.webkitNow ||
2524 function(){ return (new Date()).getTime() };
2525
2526 // Copyright Joyent, Inc. and other Node contributors.
2527
2528 function isNull(arg) {
2529 return arg === null;
2530 }
2531
2532 function isNullOrUndefined(arg) {
2533 return arg == null;
2534 }
2535
2536 function isString(arg) {
2537 return typeof arg === 'string';
2538 }
2539
2540 function isObject(arg) {
2541 return typeof arg === 'object' && arg !== null;
2542 }
2543
2544 // Copyright Joyent, Inc. and other Node contributors.
2545 //
2546 // Permission is hereby granted, free of charge, to any person obtaining a
2547 // copy of this software and associated documentation files (the
2548 // "Software"), to deal in the Software without restriction, including
2549 // without limitation the rights to use, copy, modify, merge, publish,
2550 // distribute, sublicense, and/or sell copies of the Software, and to permit
2551 // persons to whom the Software is furnished to do so, subject to the
2552 // following conditions:
2553 //
2554 // The above copyright notice and this permission notice shall be included
2555 // in all copies or substantial portions of the Software.
2556 //
2557 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
2558 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2559 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
2560 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
2561 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
2562 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
2563 // USE OR OTHER DEALINGS IN THE SOFTWARE.
2564
2565
2566 // If obj.hasOwnProperty has been overridden, then calling
2567 // obj.hasOwnProperty(prop) will break.
2568 // See: https://github.com/joyent/node/issues/1707
2569 function hasOwnProperty$1(obj, prop) {
2570 return Object.prototype.hasOwnProperty.call(obj, prop);
2571 }
2572 var isArray$1 = Array.isArray || function (xs) {
2573 return Object.prototype.toString.call(xs) === '[object Array]';
2574 };
2575 function stringifyPrimitive(v) {
2576 switch (typeof v) {
2577 case 'string':
2578 return v;
2579
2580 case 'boolean':
2581 return v ? 'true' : 'false';
2582
2583 case 'number':
2584 return isFinite(v) ? v : '';
2585
2586 default:
2587 return '';
2588 }
2589 }
2590
2591 function stringify (obj, sep, eq, name) {
2592 sep = sep || '&';
2593 eq = eq || '=';
2594 if (obj === null) {
2595 obj = undefined;
2596 }
2597
2598 if (typeof obj === 'object') {
2599 return map$1(objectKeys(obj), function(k) {
2600 var ks = encodeURIComponent(stringifyPrimitive(k)) + eq;
2601 if (isArray$1(obj[k])) {
2602 return map$1(obj[k], function(v) {
2603 return ks + encodeURIComponent(stringifyPrimitive(v));
2604 }).join(sep);
2605 } else {
2606 return ks + encodeURIComponent(stringifyPrimitive(obj[k]));
2607 }
2608 }).join(sep);
2609
2610 }
2611
2612 if (!name) return '';
2613 return encodeURIComponent(stringifyPrimitive(name)) + eq +
2614 encodeURIComponent(stringifyPrimitive(obj));
2615 }
2616 function map$1 (xs, f) {
2617 if (xs.map) return xs.map(f);
2618 var res = [];
2619 for (var i = 0; i < xs.length; i++) {
2620 res.push(f(xs[i], i));
2621 }
2622 return res;
2623 }
2624
2625 var objectKeys = Object.keys || function (obj) {
2626 var res = [];
2627 for (var key in obj) {
2628 if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key);
2629 }
2630 return res;
2631 };
2632
2633 function parse(qs, sep, eq, options) {
2634 sep = sep || '&';
2635 eq = eq || '=';
2636 var obj = {};
2637
2638 if (typeof qs !== 'string' || qs.length === 0) {
2639 return obj;
2640 }
2641
2642 var regexp = /\+/g;
2643 qs = qs.split(sep);
2644
2645 var maxKeys = 1000;
2646 if (options && typeof options.maxKeys === 'number') {
2647 maxKeys = options.maxKeys;
2648 }
2649
2650 var len = qs.length;
2651 // maxKeys <= 0 means that we should not limit keys count
2652 if (maxKeys > 0 && len > maxKeys) {
2653 len = maxKeys;
2654 }
2655
2656 for (var i = 0; i < len; ++i) {
2657 var x = qs[i].replace(regexp, '%20'),
2658 idx = x.indexOf(eq),
2659 kstr, vstr, k, v;
2660
2661 if (idx >= 0) {
2662 kstr = x.substr(0, idx);
2663 vstr = x.substr(idx + 1);
2664 } else {
2665 kstr = x;
2666 vstr = '';
2667 }
2668
2669 k = decodeURIComponent(kstr);
2670 v = decodeURIComponent(vstr);
2671
2672 if (!hasOwnProperty$1(obj, k)) {
2673 obj[k] = v;
2674 } else if (isArray$1(obj[k])) {
2675 obj[k].push(v);
2676 } else {
2677 obj[k] = [obj[k], v];
2678 }
2679 }
2680
2681 return obj;
2682 }
2683
2684 // Copyright Joyent, Inc. and other Node contributors.
2685 function Url() {
2686 this.protocol = null;
2687 this.slashes = null;
2688 this.auth = null;
2689 this.host = null;
2690 this.port = null;
2691 this.hostname = null;
2692 this.hash = null;
2693 this.search = null;
2694 this.query = null;
2695 this.pathname = null;
2696 this.path = null;
2697 this.href = null;
2698 }
2699
2700 // Reference: RFC 3986, RFC 1808, RFC 2396
2701
2702 // define these here so at least they only have to be
2703 // compiled once on the first module load.
2704 var protocolPattern = /^([a-z0-9.+-]+:)/i,
2705 portPattern = /:[0-9]*$/,
2706
2707 // Special case for a simple path URL
2708 simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
2709
2710 // RFC 2396: characters reserved for delimiting URLs.
2711 // We actually just auto-escape these.
2712 delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'],
2713
2714 // RFC 2396: characters not allowed for various reasons.
2715 unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims),
2716
2717 // Allowed by RFCs, but cause of XSS attacks. Always escape these.
2718 autoEscape = ['\''].concat(unwise),
2719 // Characters that are never ever allowed in a hostname.
2720 // Note that any invalid chars are also handled, but these
2721 // are the ones that are *expected* to be seen, so we fast-path
2722 // them.
2723 nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape),
2724 hostEndingChars = ['/', '?', '#'],
2725 hostnameMaxLen = 255,
2726 hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
2727 hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
2728 // protocols that can allow "unsafe" and "unwise" chars.
2729 unsafeProtocol = {
2730 'javascript': true,
2731 'javascript:': true
2732 },
2733 // protocols that never have a hostname.
2734 hostlessProtocol = {
2735 'javascript': true,
2736 'javascript:': true
2737 },
2738 // protocols that always contain a // bit.
2739 slashedProtocol = {
2740 'http': true,
2741 'https': true,
2742 'ftp': true,
2743 'gopher': true,
2744 'file': true,
2745 'http:': true,
2746 'https:': true,
2747 'ftp:': true,
2748 'gopher:': true,
2749 'file:': true
2750 };
2751
2752 function urlParse(url, parseQueryString, slashesDenoteHost) {
2753 if (url && isObject(url) && url instanceof Url) return url;
2754
2755 var u = new Url;
2756 u.parse(url, parseQueryString, slashesDenoteHost);
2757 return u;
2758 }
2759 Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
2760 return parse$1(this, url, parseQueryString, slashesDenoteHost);
2761 };
2762
2763 function parse$1(self, url, parseQueryString, slashesDenoteHost) {
2764 if (!isString(url)) {
2765 throw new TypeError('Parameter \'url\' must be a string, not ' + typeof url);
2766 }
2767
2768 // Copy chrome, IE, opera backslash-handling behavior.
2769 // Back slashes before the query string get converted to forward slashes
2770 // See: https://code.google.com/p/chromium/issues/detail?id=25916
2771 var queryIndex = url.indexOf('?'),
2772 splitter =
2773 (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#',
2774 uSplit = url.split(splitter),
2775 slashRegex = /\\/g;
2776 uSplit[0] = uSplit[0].replace(slashRegex, '/');
2777 url = uSplit.join(splitter);
2778
2779 var rest = url;
2780
2781 // trim before proceeding.
2782 // This is to support parse stuff like " http://foo.com \n"
2783 rest = rest.trim();
2784
2785 if (!slashesDenoteHost && url.split('#').length === 1) {
2786 // Try fast path regexp
2787 var simplePath = simplePathPattern.exec(rest);
2788 if (simplePath) {
2789 self.path = rest;
2790 self.href = rest;
2791 self.pathname = simplePath[1];
2792 if (simplePath[2]) {
2793 self.search = simplePath[2];
2794 if (parseQueryString) {
2795 self.query = parse(self.search.substr(1));
2796 } else {
2797 self.query = self.search.substr(1);
2798 }
2799 } else if (parseQueryString) {
2800 self.search = '';
2801 self.query = {};
2802 }
2803 return self;
2804 }
2805 }
2806
2807 var proto = protocolPattern.exec(rest);
2808 if (proto) {
2809 proto = proto[0];
2810 var lowerProto = proto.toLowerCase();
2811 self.protocol = lowerProto;
2812 rest = rest.substr(proto.length);
2813 }
2814
2815 // figure out if it's got a host
2816 // user@server is *always* interpreted as a hostname, and url
2817 // resolution will treat //foo/bar as host=foo,path=bar because that's
2818 // how the browser resolves relative URLs.
2819 if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
2820 var slashes = rest.substr(0, 2) === '//';
2821 if (slashes && !(proto && hostlessProtocol[proto])) {
2822 rest = rest.substr(2);
2823 self.slashes = true;
2824 }
2825 }
2826 var i, hec, l, p;
2827 if (!hostlessProtocol[proto] &&
2828 (slashes || (proto && !slashedProtocol[proto]))) {
2829
2830 // there's a hostname.
2831 // the first instance of /, ?, ;, or # ends the host.
2832 //
2833 // If there is an @ in the hostname, then non-host chars *are* allowed
2834 // to the left of the last @ sign, unless some host-ending character
2835 // comes *before* the @-sign.
2836 // URLs are obnoxious.
2837 //
2838 // ex:
2839 // http://a@b@c/ => user:a@b host:c
2840 // http://a@b?@c => user:a host:c path:/?@c
2841
2842 // v0.12 TODO(isaacs): This is not quite how Chrome does things.
2843 // Review our test case against browsers more comprehensively.
2844
2845 // find the first instance of any hostEndingChars
2846 var hostEnd = -1;
2847 for (i = 0; i < hostEndingChars.length; i++) {
2848 hec = rest.indexOf(hostEndingChars[i]);
2849 if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
2850 hostEnd = hec;
2851 }
2852
2853 // at this point, either we have an explicit point where the
2854 // auth portion cannot go past, or the last @ char is the decider.
2855 var auth, atSign;
2856 if (hostEnd === -1) {
2857 // atSign can be anywhere.
2858 atSign = rest.lastIndexOf('@');
2859 } else {
2860 // atSign must be in auth portion.
2861 // http://a@b/c@d => host:b auth:a path:/c@d
2862 atSign = rest.lastIndexOf('@', hostEnd);
2863 }
2864
2865 // Now we have a portion which is definitely the auth.
2866 // Pull that off.
2867 if (atSign !== -1) {
2868 auth = rest.slice(0, atSign);
2869 rest = rest.slice(atSign + 1);
2870 self.auth = decodeURIComponent(auth);
2871 }
2872
2873 // the host is the remaining to the left of the first non-host char
2874 hostEnd = -1;
2875 for (i = 0; i < nonHostChars.length; i++) {
2876 hec = rest.indexOf(nonHostChars[i]);
2877 if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
2878 hostEnd = hec;
2879 }
2880 // if we still have not hit it, then the entire thing is a host.
2881 if (hostEnd === -1)
2882 hostEnd = rest.length;
2883
2884 self.host = rest.slice(0, hostEnd);
2885 rest = rest.slice(hostEnd);
2886
2887 // pull out port.
2888 parseHost(self);
2889
2890 // we've indicated that there is a hostname,
2891 // so even if it's empty, it has to be present.
2892 self.hostname = self.hostname || '';
2893
2894 // if hostname begins with [ and ends with ]
2895 // assume that it's an IPv6 address.
2896 var ipv6Hostname = self.hostname[0] === '[' &&
2897 self.hostname[self.hostname.length - 1] === ']';
2898
2899 // validate a little.
2900 if (!ipv6Hostname) {
2901 var hostparts = self.hostname.split(/\./);
2902 for (i = 0, l = hostparts.length; i < l; i++) {
2903 var part = hostparts[i];
2904 if (!part) continue;
2905 if (!part.match(hostnamePartPattern)) {
2906 var newpart = '';
2907 for (var j = 0, k = part.length; j < k; j++) {
2908 if (part.charCodeAt(j) > 127) {
2909 // we replace non-ASCII char with a temporary placeholder
2910 // we need this to make sure size of hostname is not
2911 // broken by replacing non-ASCII by nothing
2912 newpart += 'x';
2913 } else {
2914 newpart += part[j];
2915 }
2916 }
2917 // we test again with ASCII char only
2918 if (!newpart.match(hostnamePartPattern)) {
2919 var validParts = hostparts.slice(0, i);
2920 var notHost = hostparts.slice(i + 1);
2921 var bit = part.match(hostnamePartStart);
2922 if (bit) {
2923 validParts.push(bit[1]);
2924 notHost.unshift(bit[2]);
2925 }
2926 if (notHost.length) {
2927 rest = '/' + notHost.join('.') + rest;
2928 }
2929 self.hostname = validParts.join('.');
2930 break;
2931 }
2932 }
2933 }
2934 }
2935
2936 if (self.hostname.length > hostnameMaxLen) {
2937 self.hostname = '';
2938 } else {
2939 // hostnames are always lower case.
2940 self.hostname = self.hostname.toLowerCase();
2941 }
2942
2943 if (!ipv6Hostname) {
2944 // IDNA Support: Returns a punycoded representation of "domain".
2945 // It only converts parts of the domain name that
2946 // have non-ASCII characters, i.e. it doesn't matter if
2947 // you call it with a domain that already is ASCII-only.
2948 self.hostname = toASCII(self.hostname);
2949 }
2950
2951 p = self.port ? ':' + self.port : '';
2952 var h = self.hostname || '';
2953 self.host = h + p;
2954 self.href += self.host;
2955
2956 // strip [ and ] from the hostname
2957 // the host field still retains them, though
2958 if (ipv6Hostname) {
2959 self.hostname = self.hostname.substr(1, self.hostname.length - 2);
2960 if (rest[0] !== '/') {
2961 rest = '/' + rest;
2962 }
2963 }
2964 }
2965
2966 // now rest is set to the post-host stuff.
2967 // chop off any delim chars.
2968 if (!unsafeProtocol[lowerProto]) {
2969
2970 // First, make 100% sure that any "autoEscape" chars get
2971 // escaped, even if encodeURIComponent doesn't think they
2972 // need to be.
2973 for (i = 0, l = autoEscape.length; i < l; i++) {
2974 var ae = autoEscape[i];
2975 if (rest.indexOf(ae) === -1)
2976 continue;
2977 var esc = encodeURIComponent(ae);
2978 if (esc === ae) {
2979 esc = escape(ae);
2980 }
2981 rest = rest.split(ae).join(esc);
2982 }
2983 }
2984
2985
2986 // chop off from the tail first.
2987 var hash = rest.indexOf('#');
2988 if (hash !== -1) {
2989 // got a fragment string.
2990 self.hash = rest.substr(hash);
2991 rest = rest.slice(0, hash);
2992 }
2993 var qm = rest.indexOf('?');
2994 if (qm !== -1) {
2995 self.search = rest.substr(qm);
2996 self.query = rest.substr(qm + 1);
2997 if (parseQueryString) {
2998 self.query = parse(self.query);
2999 }
3000 rest = rest.slice(0, qm);
3001 } else if (parseQueryString) {
3002 // no query string, but parseQueryString still requested
3003 self.search = '';
3004 self.query = {};
3005 }
3006 if (rest) self.pathname = rest;
3007 if (slashedProtocol[lowerProto] &&
3008 self.hostname && !self.pathname) {
3009 self.pathname = '/';
3010 }
3011
3012 //to support http.request
3013 if (self.pathname || self.search) {
3014 p = self.pathname || '';
3015 var s = self.search || '';
3016 self.path = p + s;
3017 }
3018
3019 // finally, reconstruct the href based on what has been validated.
3020 self.href = format$1(self);
3021 return self;
3022 }
3023
3024 function format$1(self) {
3025 var auth = self.auth || '';
3026 if (auth) {
3027 auth = encodeURIComponent(auth);
3028 auth = auth.replace(/%3A/i, ':');
3029 auth += '@';
3030 }
3031
3032 var protocol = self.protocol || '',
3033 pathname = self.pathname || '',
3034 hash = self.hash || '',
3035 host = false,
3036 query = '';
3037
3038 if (self.host) {
3039 host = auth + self.host;
3040 } else if (self.hostname) {
3041 host = auth + (self.hostname.indexOf(':') === -1 ?
3042 self.hostname :
3043 '[' + this.hostname + ']');
3044 if (self.port) {
3045 host += ':' + self.port;
3046 }
3047 }
3048
3049 if (self.query &&
3050 isObject(self.query) &&
3051 Object.keys(self.query).length) {
3052 query = stringify(self.query);
3053 }
3054
3055 var search = self.search || (query && ('?' + query)) || '';
3056
3057 if (protocol && protocol.substr(-1) !== ':') protocol += ':';
3058
3059 // only the slashedProtocols get the //. Not mailto:, xmpp:, etc.
3060 // unless they had them to begin with.
3061 if (self.slashes ||
3062 (!protocol || slashedProtocol[protocol]) && host !== false) {
3063 host = '//' + (host || '');
3064 if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname;
3065 } else if (!host) {
3066 host = '';
3067 }
3068
3069 if (hash && hash.charAt(0) !== '#') hash = '#' + hash;
3070 if (search && search.charAt(0) !== '?') search = '?' + search;
3071
3072 pathname = pathname.replace(/[?#]/g, function(match) {
3073 return encodeURIComponent(match);
3074 });
3075 search = search.replace('#', '%23');
3076
3077 return protocol + host + pathname + search + hash;
3078 }
3079
3080 Url.prototype.format = function() {
3081 return format$1(this);
3082 };
3083
3084 Url.prototype.resolve = function(relative) {
3085 return this.resolveObject(urlParse(relative, false, true)).format();
3086 };
3087
3088 Url.prototype.resolveObject = function(relative) {
3089 if (isString(relative)) {
3090 var rel = new Url();
3091 rel.parse(relative, false, true);
3092 relative = rel;
3093 }
3094
3095 var result = new Url();
3096 var tkeys = Object.keys(this);
3097 for (var tk = 0; tk < tkeys.length; tk++) {
3098 var tkey = tkeys[tk];
3099 result[tkey] = this[tkey];
3100 }
3101
3102 // hash is always overridden, no matter what.
3103 // even href="" will remove it.
3104 result.hash = relative.hash;
3105
3106 // if the relative url is empty, then there's nothing left to do here.
3107 if (relative.href === '') {
3108 result.href = result.format();
3109 return result;
3110 }
3111
3112 // hrefs like //foo/bar always cut to the protocol.
3113 if (relative.slashes && !relative.protocol) {
3114 // take everything except the protocol from relative
3115 var rkeys = Object.keys(relative);
3116 for (var rk = 0; rk < rkeys.length; rk++) {
3117 var rkey = rkeys[rk];
3118 if (rkey !== 'protocol')
3119 result[rkey] = relative[rkey];
3120 }
3121
3122 //urlParse appends trailing / to urls like http://www.example.com
3123 if (slashedProtocol[result.protocol] &&
3124 result.hostname && !result.pathname) {
3125 result.path = result.pathname = '/';
3126 }
3127
3128 result.href = result.format();
3129 return result;
3130 }
3131 var relPath;
3132 if (relative.protocol && relative.protocol !== result.protocol) {
3133 // if it's a known url protocol, then changing
3134 // the protocol does weird things
3135 // first, if it's not file:, then we MUST have a host,
3136 // and if there was a path
3137 // to begin with, then we MUST have a path.
3138 // if it is file:, then the host is dropped,
3139 // because that's known to be hostless.
3140 // anything else is assumed to be absolute.
3141 if (!slashedProtocol[relative.protocol]) {
3142 var keys = Object.keys(relative);
3143 for (var v = 0; v < keys.length; v++) {
3144 var k = keys[v];
3145 result[k] = relative[k];
3146 }
3147 result.href = result.format();
3148 return result;
3149 }
3150
3151 result.protocol = relative.protocol;
3152 if (!relative.host && !hostlessProtocol[relative.protocol]) {
3153 relPath = (relative.pathname || '').split('/');
3154 while (relPath.length && !(relative.host = relPath.shift()));
3155 if (!relative.host) relative.host = '';
3156 if (!relative.hostname) relative.hostname = '';
3157 if (relPath[0] !== '') relPath.unshift('');
3158 if (relPath.length < 2) relPath.unshift('');
3159 result.pathname = relPath.join('/');
3160 } else {
3161 result.pathname = relative.pathname;
3162 }
3163 result.search = relative.search;
3164 result.query = relative.query;
3165 result.host = relative.host || '';
3166 result.auth = relative.auth;
3167 result.hostname = relative.hostname || relative.host;
3168 result.port = relative.port;
3169 // to support http.request
3170 if (result.pathname || result.search) {
3171 var p = result.pathname || '';
3172 var s = result.search || '';
3173 result.path = p + s;
3174 }
3175 result.slashes = result.slashes || relative.slashes;
3176 result.href = result.format();
3177 return result;
3178 }
3179
3180 var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'),
3181 isRelAbs = (
3182 relative.host ||
3183 relative.pathname && relative.pathname.charAt(0) === '/'
3184 ),
3185 mustEndAbs = (isRelAbs || isSourceAbs ||
3186 (result.host && relative.pathname)),
3187 removeAllDots = mustEndAbs,
3188 srcPath = result.pathname && result.pathname.split('/') || [],
3189 psychotic = result.protocol && !slashedProtocol[result.protocol];
3190 relPath = relative.pathname && relative.pathname.split('/') || [];
3191 // if the url is a non-slashed url, then relative
3192 // links like ../.. should be able
3193 // to crawl up to the hostname, as well. This is strange.
3194 // result.protocol has already been set by now.
3195 // Later on, put the first path part into the host field.
3196 if (psychotic) {
3197 result.hostname = '';
3198 result.port = null;
3199 if (result.host) {
3200 if (srcPath[0] === '') srcPath[0] = result.host;
3201 else srcPath.unshift(result.host);
3202 }
3203 result.host = '';
3204 if (relative.protocol) {
3205 relative.hostname = null;
3206 relative.port = null;
3207 if (relative.host) {
3208 if (relPath[0] === '') relPath[0] = relative.host;
3209 else relPath.unshift(relative.host);
3210 }
3211 relative.host = null;
3212 }
3213 mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === '');
3214 }
3215 var authInHost;
3216 if (isRelAbs) {
3217 // it's absolute.
3218 result.host = (relative.host || relative.host === '') ?
3219 relative.host : result.host;
3220 result.hostname = (relative.hostname || relative.hostname === '') ?
3221 relative.hostname : result.hostname;
3222 result.search = relative.search;
3223 result.query = relative.query;
3224 srcPath = relPath;
3225 // fall through to the dot-handling below.
3226 } else if (relPath.length) {
3227 // it's relative
3228 // throw away the existing file, and take the new path instead.
3229 if (!srcPath) srcPath = [];
3230 srcPath.pop();
3231 srcPath = srcPath.concat(relPath);
3232 result.search = relative.search;
3233 result.query = relative.query;
3234 } else if (!isNullOrUndefined(relative.search)) {
3235 // just pull out the search.
3236 // like href='?foo'.
3237 // Put this after the other two cases because it simplifies the booleans
3238 if (psychotic) {
3239 result.hostname = result.host = srcPath.shift();
3240 //occationaly the auth can get stuck only in host
3241 //this especially happens in cases like
3242 //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
3243 authInHost = result.host && result.host.indexOf('@') > 0 ?
3244 result.host.split('@') : false;
3245 if (authInHost) {
3246 result.auth = authInHost.shift();
3247 result.host = result.hostname = authInHost.shift();
3248 }
3249 }
3250 result.search = relative.search;
3251 result.query = relative.query;
3252 //to support http.request
3253 if (!isNull(result.pathname) || !isNull(result.search)) {
3254 result.path = (result.pathname ? result.pathname : '') +
3255 (result.search ? result.search : '');
3256 }
3257 result.href = result.format();
3258 return result;
3259 }
3260
3261 if (!srcPath.length) {
3262 // no path at all. easy.
3263 // we've already handled the other stuff above.
3264 result.pathname = null;
3265 //to support http.request
3266 if (result.search) {
3267 result.path = '/' + result.search;
3268 } else {
3269 result.path = null;
3270 }
3271 result.href = result.format();
3272 return result;
3273 }
3274
3275 // if a url ENDs in . or .., then it must get a trailing slash.
3276 // however, if it ends in anything else non-slashy,
3277 // then it must NOT get a trailing slash.
3278 var last = srcPath.slice(-1)[0];
3279 var hasTrailingSlash = (
3280 (result.host || relative.host || srcPath.length > 1) &&
3281 (last === '.' || last === '..') || last === '');
3282
3283 // strip single dots, resolve double dots to parent dir
3284 // if the path tries to go above the root, `up` ends up > 0
3285 var up = 0;
3286 for (var i = srcPath.length; i >= 0; i--) {
3287 last = srcPath[i];
3288 if (last === '.') {
3289 srcPath.splice(i, 1);
3290 } else if (last === '..') {
3291 srcPath.splice(i, 1);
3292 up++;
3293 } else if (up) {
3294 srcPath.splice(i, 1);
3295 up--;
3296 }
3297 }
3298
3299 // if the path is allowed to go above the root, restore leading ..s
3300 if (!mustEndAbs && !removeAllDots) {
3301 for (; up--; up) {
3302 srcPath.unshift('..');
3303 }
3304 }
3305
3306 if (mustEndAbs && srcPath[0] !== '' &&
3307 (!srcPath[0] || srcPath[0].charAt(0) !== '/')) {
3308 srcPath.unshift('');
3309 }
3310
3311 if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) {
3312 srcPath.push('');
3313 }
3314
3315 var isAbsolute = srcPath[0] === '' ||
3316 (srcPath[0] && srcPath[0].charAt(0) === '/');
3317
3318 // put the host back
3319 if (psychotic) {
3320 result.hostname = result.host = isAbsolute ? '' :
3321 srcPath.length ? srcPath.shift() : '';
3322 //occationaly the auth can get stuck only in host
3323 //this especially happens in cases like
3324 //url.resolveObject('mailto:local1@domain1', 'local2@domain2')
3325 authInHost = result.host && result.host.indexOf('@') > 0 ?
3326 result.host.split('@') : false;
3327 if (authInHost) {
3328 result.auth = authInHost.shift();
3329 result.host = result.hostname = authInHost.shift();
3330 }
3331 }
3332
3333 mustEndAbs = mustEndAbs || (result.host && srcPath.length);
3334
3335 if (mustEndAbs && !isAbsolute) {
3336 srcPath.unshift('');
3337 }
3338
3339 if (!srcPath.length) {
3340 result.pathname = null;
3341 result.path = null;
3342 } else {
3343 result.pathname = srcPath.join('/');
3344 }
3345
3346 //to support request.http
3347 if (!isNull(result.pathname) || !isNull(result.search)) {
3348 result.path = (result.pathname ? result.pathname : '') +
3349 (result.search ? result.search : '');
3350 }
3351 result.auth = relative.auth || result.auth;
3352 result.slashes = result.slashes || relative.slashes;
3353 result.href = result.format();
3354 return result;
3355 };
3356
3357 Url.prototype.parseHost = function() {
3358 return parseHost(this);
3359 };
3360
3361 function parseHost(self) {
3362 var host = self.host;
3363 var port = portPattern.exec(host);
3364 if (port) {
3365 port = port[0];
3366 if (port !== ':') {
3367 self.port = port.substr(1);
3368 }
3369 host = host.substr(0, host.length - port.length);
3370 }
3371 if (host) self.hostname = host;
3372 }
3373
3374 var tableListDataSource = [];
3375
3376 for (var i$1 = 0; i$1 < 46; i$1 += 1) {
3377 tableListDataSource.push({
3378 key: i$1,
3379 disabled: i$1 % 6 === 0,
3380 href: 'https://ant.design',
3381 avatar: ['https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png', 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png'][i$1 % 2],
3382 name: "TradeCode ".concat(i$1),
3383 title: "\u4E00\u4E2A\u4EFB\u52A1\u540D\u79F0 ".concat(i$1),
3384 owner: '曲丽丽',
3385 desc: '这是一段描述',
3386 callNo: Math.floor(Math.random() * 1000),
3387 status: Math.floor(Math.random() * 10) % 4,
3388 updatedAt: new Date("2017-07-".concat(Math.floor(i$1 / 2) + 1)),
3389 createdAt: new Date("2017-07-".concat(Math.floor(i$1 / 2) + 1)),
3390 progress: Math.ceil(Math.random() * 100)
3391 });
3392 }
3393
3394 function getRule(req, res, u) {
3395 var url$$1 = u;
3396
3397 if (!url$$1 || Object.prototype.toString.call(url$$1) !== '[object String]') {
3398 url$$1 = req.url; // eslint-disable-line
3399 }
3400
3401 var params = urlParse(url$$1, true).query;
3402 var dataSource = tableListDataSource;
3403
3404 if (params.sorter) {
3405 var s = params.sorter.split('_');
3406 dataSource = dataSource.sort(function (prev, next) {
3407 if (s[1] === 'descend') {
3408 return next[s[0]] - prev[s[0]];
3409 }
3410
3411 return prev[s[0]] - next[s[0]];
3412 });
3413 }
3414
3415 if (params.status) {
3416 var status = params.status.split(',');
3417 var filterDataSource = [];
3418 status.forEach(function (s) {
3419 filterDataSource = filterDataSource.concat(dataSource.filter(function (data) {
3420 return parseInt(data.status, 10) === parseInt(s[0], 10);
3421 }));
3422 });
3423 dataSource = filterDataSource;
3424 }
3425
3426 if (params.name) {
3427 dataSource = dataSource.filter(function (data) {
3428 return data.name.indexOf(params.name) > -1;
3429 });
3430 }
3431
3432 var pageSize = 10;
3433
3434 if (params.pageSize) {
3435 pageSize = params.pageSize * 1;
3436 }
3437
3438 var result = {
3439 list: dataSource,
3440 pagination: {
3441 total: dataSource.length,
3442 pageSize: pageSize,
3443 current: parseInt(params.currentPage, 10) || 1
3444 }
3445 };
3446
3447 if (res && res.json) {
3448 res.json(result);
3449 } else {
3450 return result;
3451 }
3452 }
3453
3454 function postRule(req, res, u, b) {
3455 var url$$1 = u;
3456
3457 if (!url$$1 || Object.prototype.toString.call(url$$1) !== '[object String]') {
3458 url$$1 = req.url; // eslint-disable-line
3459 }
3460
3461 var body = b && b.body || req.body;
3462 var method = body.method,
3463 name = body.name,
3464 desc = body.desc,
3465 key = body.key;
3466
3467 switch (method) {
3468 /* eslint no-case-declarations:0 */
3469 case 'delete':
3470 tableListDataSource = tableListDataSource.filter(function (item) {
3471 return key.indexOf(item.key) === -1;
3472 });
3473 break;
3474
3475 case 'post':
3476 var _i = Math.ceil(Math.random() * 10000);
3477
3478 tableListDataSource.unshift({
3479 key: _i,
3480 href: 'https://ant.design',
3481 avatar: ['https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png', 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png'][_i % 2],
3482 name: "TradeCode ".concat(_i),
3483 title: "\u4E00\u4E2A\u4EFB\u52A1\u540D\u79F0 ".concat(_i),
3484 owner: '曲丽丽',
3485 desc: desc,
3486 callNo: Math.floor(Math.random() * 1000),
3487 status: Math.floor(Math.random() * 10) % 2,
3488 updatedAt: new Date(),
3489 createdAt: new Date(),
3490 progress: Math.ceil(Math.random() * 100)
3491 });
3492 break;
3493
3494 case 'update':
3495 tableListDataSource = tableListDataSource.map(function (item) {
3496 if (item.key === key) {
3497 _Object$assign(item, {
3498 desc: desc,
3499 name: name
3500 });
3501
3502 return item;
3503 }
3504
3505 return item;
3506 });
3507 break;
3508
3509 default:
3510 break;
3511 }
3512
3513 var result = {
3514 list: tableListDataSource,
3515 pagination: {
3516 total: tableListDataSource.length
3517 }
3518 };
3519
3520 if (res && res.json) {
3521 res.json(result);
3522 } else {
3523 return result;
3524 }
3525 }
3526
3527 var rule = {
3528 'GET /api/rule': getRule,
3529 'POST /api/rule': postRule
3530 };
3531
3532 // 代码中会兼容本地 service mock 以及部署站点的静态数据
3533 var user$1 = {
3534 // 支持值为 Object 和 Array
3535 'GET /api/currentUser': {
3536 name: 'Serati Ma',
3537 avatar: 'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png',
3538 userid: '00000001',
3539 email: 'antdesign@alipay.com',
3540 signature: '海纳百川,有容乃大',
3541 title: '交互专家',
3542 group: '蚂蚁金服-某某某事业群-某某平台部-某某技术部-UED',
3543 tags: [{
3544 key: '0',
3545 label: '很有想法的'
3546 }, {
3547 key: '1',
3548 label: '专注设计'
3549 }, {
3550 key: '2',
3551 label: '辣~'
3552 }, {
3553 key: '3',
3554 label: '大长腿'
3555 }, {
3556 key: '4',
3557 label: '川妹子'
3558 }, {
3559 key: '5',
3560 label: '海纳百川'
3561 }],
3562 notifyCount: 12,
3563 country: 'China',
3564 geographic: {
3565 province: {
3566 label: '浙江省',
3567 key: '330000'
3568 },
3569 city: {
3570 label: '杭州市',
3571 key: '330100'
3572 }
3573 },
3574 address: '西湖区工专路 77 号',
3575 phone: '0752-268888888'
3576 },
3577 // GET POST 可省略
3578 'GET /api/users': [{
3579 key: '1',
3580 name: 'John Brown',
3581 age: 32,
3582 address: 'New York No. 1 Lake Park'
3583 }, {
3584 key: '2',
3585 name: 'Jim Green',
3586 age: 42,
3587 address: 'London No. 1 Lake Park'
3588 }, {
3589 key: '3',
3590 name: 'Joe Black',
3591 age: 32,
3592 address: 'Sidney No. 1 Lake Park'
3593 }],
3594 'POST /api/login/account': function POSTApiLoginAccount(req, res) {
3595 var _req$body = req.body,
3596 password = _req$body.password,
3597 userName = _req$body.userName,
3598 type = _req$body.type;
3599
3600 if (password === '888888' && userName === 'admin') {
3601 res.send({
3602 status: 'ok',
3603 type: type,
3604 currentAuthority: 'admin'
3605 });
3606 return;
3607 }
3608
3609 if (password === '123456' && userName === 'user') {
3610 res.send({
3611 status: 'ok',
3612 type: type,
3613 currentAuthority: 'user'
3614 });
3615 return;
3616 }
3617
3618 res.send({
3619 status: 'error',
3620 type: type,
3621 currentAuthority: 'guest'
3622 });
3623 },
3624 'POST /api/register': function POSTApiRegister(req, res) {
3625 res.send({
3626 status: 'ok',
3627 currentAuthority: 'user'
3628 });
3629 },
3630 'GET /api/500': function GETApi500(req, res) {
3631 res.status(500).send({
3632 timestamp: 1513932555104,
3633 status: 500,
3634 error: 'error',
3635 message: 'error',
3636 path: '/base/category/list'
3637 });
3638 },
3639 'GET /api/404': function GETApi404(req, res) {
3640 res.status(404).send({
3641 timestamp: 1513932643431,
3642 status: 404,
3643 error: 'Not Found',
3644 message: 'No message available',
3645 path: '/base/category/list/2121212'
3646 });
3647 },
3648 'GET /api/403': function GETApi403(req, res) {
3649 res.status(403).send({
3650 timestamp: 1513932555104,
3651 status: 403,
3652 error: 'Unauthorized',
3653 message: 'Unauthorized',
3654 path: '/base/category/list'
3655 });
3656 },
3657 'GET /api/401': function GETApi401(req, res) {
3658 res.status(401).send({
3659 timestamp: 1513932555104,
3660 status: 401,
3661 error: 'Unauthorized',
3662 message: 'Unauthorized',
3663 path: '/base/category/list'
3664 });
3665 }
3666 };
3667
3668 var data = _objectSpread({}, api, chart, geographic, notices, profile, rule, user$1);
3669
3670 return data;
3671
3672})));