index.js 97 KB

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