text: // 使用 Mock
  var Mock = require('mockjs');
  var Random=Mock.Random;
  var fs = require('fs');
  var series={"奥迪":{"children":["一汽奥迪","奥迪","奥迪RS"],"mark":"A"},"奥克斯":{"children":["奥克斯"],"mark":"A"},"阿尔法·罗密欧":{"children":["阿尔法·罗密欧"],"mark":"A"},"阿斯顿·马丁":{"children":["阿斯顿·马丁"],"mark":"A"},"AC Schnitzer":{"children":["AC Schnitzer"],"mark":"A"},"奔驰":{"children":["北京奔驰","福建奔驰","奔驰","奔驰AMG"],"mark":"B"},"宝马":{"children":["华晨宝马","宝马","宝马M系"],"mark":"B"},"标致":{"children":["东风标致","广州标致","标致"],"mark":"B"},"北汽制造":{"children":["北汽"],"mark":"B"},"比亚迪":{"children":["比亚迪"],"mark":"B"},"本田":{"children":["东风本田","广汽本田","本田"],"mark":"B"},"奔腾":{"children":["一汽奔腾"],"mark":"B"},"宝龙":{"children":["宝龙"],"mark":"B"},"保时捷":{"children":["保时捷"],"mark":"B"},"宾利":{"children":["宾利"],"mark":"B"},"别克":{"children":["上海通用别克","别克"],"mark":"B"},"布加迪":{"children":["布加迪"],"mark":"B"},"宝骏":{"children":["宝骏"],"mark":"B"},"北京汽车":{"children":["北京汽车"],"mark":"B"},"北汽威旺":{"children":["北汽威旺"],"mark":"B"},"巴博斯":{"children":["巴博斯"],"mark":"B"},"保斐利":{"children":["保斐利"],"mark":"B"},"北汽幻速":{"children":["北汽幻速"],"mark":"B"},"北汽新能源":{"children":["北汽新能源"],"mark":"B"},"长城":{"children":["长城"],"mark":"C"},"昌河":{"children":["昌河"],"mark":"C"},"长安轿车":{"children":["长安轿车"],"mark":"C"},"长安商用":{"children":["长安商用"],"mark":"C"},"大众":{"children":["上海大众","一汽-大众","大众"],"mark":"D"},"东风":{"children":["东风","东风校车系列"],"mark":"D"},"东南":{"children":["东南"],"mark":"D"},"大迪":{"children":["大迪"],"mark":"D"},"大宇":{"children":["大宇"],"mark":"D"},"道奇":{"children":["东南道奇","道奇"],"mark":"D"},"东风风行":{"children":["东风风行"],"mark":"D"},"东风风神":{"children":["东风风神"],"mark":"D"},"DS":{"children":["长安DS","DS"],"mark":"D"},"东风风度":{"children":["东风风度"],"mark":"D"},"东风小康":{"children":["东风小康"],"mark":"D"},"东风御风":{"children":["东风御风"],"mark":"D"},"丰田":{"children":["广汽丰田","一汽丰田","丰田"],"mark":"F"},"福特":{"children":["长安福特","福特"],"mark":"F"},"菲亚特":{"children":["广汽菲亚特","南京菲亚特","菲亚特","海酷"],"mark":"F"},"富奇":{"children":["华翔富奇"],"mark":"F"},"福迪":{"children":["福迪"],"mark":"F"},"法拉利":{"children":["法拉利"],"mark":"F"},"福田":{"children":["福田","欧辉"],"mark":"F"},"福达":{"children":["福达"],"mark":"F"},"Faralli Mazzanti":{"children":["Faralli Mazzanti"],"mark":"F"},"飞驰商务车":{"children":["飞驰"],"mark":"F"},"福汽启腾":{"children":["福汽启腾"],"mark":"F"},"广汽吉奥":{"children":["广汽吉奥"],"mark":"G"},"GMC":{"children":["GMC"],"mark":"G"},"光冈":{"children":["光冈"],"mark":"G"},"广汽日野":{"children":["广汽日野"],"mark":"G"},"广汽":{"children":["广汽传祺"],"mark":"G"},"观致汽车":{"children":["观致汽车"],"mark":"G"},"哈飞":{"children":["哈飞"],"mark":"H"},"海马":{"children":["海马"],"mark":"H"},"华普":{"children":["华普"],"mark":"H"},"汇众":{"children":["上海汇众"],"mark":"H"},"黄海":{"children":["黄海汽车"],"mark":"H"},"红旗":{"children":["红旗"],"mark":"H"},"航天圆通":{"children":["航天圆通"],"mark":"H"},"悍马":{"children":["悍马"],"mark":"H"},"华泰":{"children":["华泰"],"mark":"H"},"汉江":{"children":["汉江"],"mark":"H"},"黑豹":{"children":["富桑黑豹"],"mark":"H"},"华阳":{"children":["华阳"],"mark":"H"},"海马商用车":{"children":["郑州海马"],"mark":"H"},"海格":{"children":["海格"],"mark":"H"},"恒天汽车":{"children":["恒天汽车"],"mark":"H"},"哈弗":{"children":["哈弗"],"mark":"H"},"Jeep":{"children":["北京吉普","北京吉普切诺基","Jeep"],"mark":"J"},"吉利汽车":{"children":["吉利汽车"],"mark":"J"},"江淮":{"children":["江淮","江淮安驰"],"mark":"J"},"江铃":{"children":["江铃"],"mark":"J"},"江南":{"children":["江南"],"mark":"J"},"金杯":{"children":["华晨金杯"],"mark":"J"},"金龙联合":{"children":["大金龙"],"mark":"J"},"金程":{"children":["金程"],"mark":"J"},"捷豹":{"children":["捷豹"],"mark":"J"},"吉林江北":{"children":["吉林江北"],"mark":"J"},"九龙":{"children":["九龙"],"mark":"J"},"金旅客车":{"children":["金旅客车"],"mark":"J"},"克莱斯勒":{"children":["北奔克莱斯勒","东南克莱斯勒","克莱斯勒"],"mark":"K"},"凯迪拉克":{"children":["上海通用凯迪拉克","凯迪拉克"],"mark":"K"},"科尼塞克":{"children":["科尼塞克"],"mark":"K"},"开瑞":{"children":["开瑞"],"mark":"K"},"卡尔森":{"children":["卡尔森"],"mark":"K"},"KTM":{"children":["KTM"],"mark":"K"},"卡威":{"children":["卡威"],"mark":"K"},"铃木":{"children":["昌河铃木","长安铃木","西安奥拓","铃木"],"mark":"L"},"陆风":{"children":["陆风"],"mark":"L"},"力帆":{"children":["力帆"],"mark":"L"},"劳斯莱斯":{"children":["劳斯莱斯"],"mark":"L"},"路特斯":{"children":["路特斯"],"mark":"L"},"兰博基尼":{"children":["兰博基尼"],"mark":"L"},"雷克萨斯":{"children":["雷克萨斯"],"mark":"L"},"林肯":{"children":["林肯"],"mark":"L"},"路虎":{"children":["路虎"],"mark":"L"},"雷诺":{"children":["雷诺"],"mark":"L"},"罗孚":{"children":["罗孚"],"mark":"L"},"莲花":{"children":["莲花","莲花(进口)"],"mark":"L"},"猎豹汽车":{"children":["猎豹SUV","猎豹皮卡"],"mark":"L"},"理念":{"children":["理念"],"mark":"L"},"蓝海房车":{"children":["蓝海房车"],"mark":"L"},"马自达":{"children":["长安马自达","一汽马自达","马自达"],"mark":"M"},"美亚":{"children":["美亚"],"mark":"M"},"MG":{"children":["MG"],"mark":"M"},"MINI":{"children":["MINI","MINI JCW"],"mark":"M"},"迈巴赫":{"children":["迈巴赫"],"mark":"M"},"玛莎拉蒂":{"children":["玛莎拉蒂"],"mark":"M"},"迈凯伦":{"children":["迈凯伦"],"mark":"M"},"摩根":{"children":["摩根"],"mark":"M"},"纳智捷":{"children":["纳智捷"],"mark":"N"},"讴歌":{"children":["讴歌"],"mark":"O"},"欧宝":{"children":["欧宝"],"mark":"O"},"欧朗":{"children":["欧朗"],"mark":"O"},"旁蒂克":{"children":["旁蒂克"],"mark":"P"},"帕加尼":{"children":["帕加尼"],"mark":"P"},"皮特比尔特卡车":{"children":["皮特比尔特"],"mark":"P"},"起亚":{"children":["东风悦达起亚","起亚"],"mark":"Q"},"奇瑞":{"children":["奇瑞"],"mark":"Q"},"庆铃":{"children":["庆铃"],"mark":"Q"},"启辰":{"children":["启辰"],"mark":"Q"},"日产":{"children":["东风日产","郑州日产","日产"],"mark":"R"},"荣威":{"children":["上汽荣威"],"mark":"R"},"瑞麒":{"children":["瑞麒"],"mark":"R"},"斯柯达":{"children":["上海大众斯柯达","斯柯达"],"mark":"S"},"三菱":{"children":["北奔三菱","东南三菱","广汽三菱","三菱"],"mark":"S"},"双环":{"children":["双环"],"mark":"S"},"顺旅":{"children":["顺旅汽车"],"mark":"S"}," ":{"children":["smart"],"mark":"s"},"双龙":{"children":["双龙"],"mark":"S"},"萨博":{"children":["萨博"],"mark":"S"},"斯巴鲁":{"children":["斯巴鲁"],"mark":"S"},"三星":{"children":["广东三星"],"mark":"S"},"世爵":{"children":["世爵"],"mark":"S"},"上汽大通MAXUS":{"children":["上汽大通MAXUS"],"mark":"S"},"陕汽通家":{"children":["通家"],"mark":"S"},"绅宝":{"children":["绅宝"],"mark":"S"},"山姆":{"children":["山姆"],"mark":"S"},"天马":{"children":["天马"],"mark":"T"},"通田":{"children":["通田"],"mark":"T"},"塔菲克":{"children":["塔菲克"],"mark":"T"},"腾势":{"children":["腾势"],"mark":"T"},"特斯拉":{"children":["特斯拉"],"mark":"T"},"泰卡特":{"children":["泰卡特"],"mark":"T"},"沃尔沃":{"children":["长安沃尔沃","沃尔沃亚太","沃尔沃"],"mark":"W"},"万丰":{"children":["上海万丰"],"mark":"W"},"五菱":{"children":["五菱"],"mark":"W"},"五十铃":{"children":["五十铃"],"mark":"W"},"威麟":{"children":["威麟"],"mark":"W"},"威兹曼":{"children":["威兹曼"],"mark":"W"},"雪铁龙":{"children":["东风雪铁龙","雪铁龙"],"mark":"X"},"现代":{"children":["北京现代","四川现代","现代"],"mark":"X"},"雪佛兰":{"children":["金杯通用雪佛兰","上海通用雪佛兰","上汽通用五菱雪佛兰","雪佛兰"],"mark":"X"},"新雅途":{"children":["南汽新雅途"],"mark":"X"},"新大地":{"children":["大地"],"mark":"X"},"新凯":{"children":["新凯"],"mark":"X"},"西雅特":{"children":["西雅特"],"mark":"X"},"星客特":{"children":["星客特"],"mark":"X"},"依维柯":{"children":["南京依维柯"],"mark":"Y"},"仪征":{"children":["上汽仪征"],"mark":"Y"},"一汽":{"children":["天津一汽","一汽华利","一汽吉林","一汽吉林大发","一汽轻型汽车","一汽通用"],"mark":"Y"},"永源":{"children":["永源汽车"],"mark":"Y"},"英菲尼迪":{"children":["英菲尼迪"],"mark":"Y"},"云豹":{"children":["广州云豹"],"mark":"Y"},"云雀":{"children":["贵州云雀"],"mark":"Y"},"野马汽车":{"children":["野马汽车"],"mark":"Y"},"友谊客车":{"children":["友谊"],"mark":"Y"},"宇通":{"children":["宇通"],"mark":"Y"},"扬州亚星客车":{"children":["扬州亚星客车"],"mark":"Y"},"中兴":{"children":["中兴"],"mark":"Z"},"中华":{"children":["华晨中华"],"mark":"Z"},"中客华北":{"children":["中客华北"],"mark":"Z"},"中顺":{"children":["中顺"],"mark":"Z"},"众泰":{"children":["众泰"],"mark":"Z"},"中欧":{"children":["中欧汽车"],"mark":"Z"},"中通客车":{"children":["中通客车"],"mark":"Z"},"浙江卡尔森":{"children":[],"mark":"Z"}};
  var colork=[
      'red',
      'gray',
      'green',
      'silver',
      'black',
      'blue',
      'yellow',
      'white',
      'gold',
      'orange',
      'purple',
      'pink',
      'brown',
      'champagne',
      'cyan'
  ];
  var type=[
  	'微型车','小型车','紧凑型车','中型车','中大型车','豪华车','MPV','SUV','跑车','皮卡','面包车'
  ];
  var seat=[2,4,5,6,7,8];
  var colorv={
      red: '红色',
      gray: '灰色',
      green: '绿色',
      silver: '银色',
      black: '黑色',
      blue: '蓝色',
      yellow: '黄色',
      white: '白色',
      gold: '金色',
      orange: '橙色',
      purple: '紫色',
      pink: '粉色',
      brown: '咖啡色',
      champagne: '香槟色',
      cyan:'青色'
  };
  var colorimg={
      red: './images/red.jpg',
      gray: './images/gray.jpg',
      green: './images/green.jpg',
      silver: './images/silver.jpg',
      black: './images/black.jpg',
      blue: './images/blue.jpg',
      yellow: './images/yellow.jpg',
      white: './images/white.jpg',
      gold: './images/gold.jpg',
      orange: './images/orange.jpg',
      purple: './images/purple.jpg',
      pink: './images/pink.jpg',
      brown: './images/brown.jpg',
      champagne: './images/champagne.jpg',
      cyan:'./images/cyan.jpg'
  };
  var imgs={
      '奥迪':{
          path:'Audi_A3',
          color:['green','orange','red','white']
      },
      '宝马':{
          path:'bmw_330i',
          color:['blue','red']
      },
      '别克':{
          path:'Buick_verano',
          color:['blue','brown','gray','white']
      },
      '长安':{
          path:'Buick_verano',
          color:['black','gold','gray','red','white']
      },
      '吉利':{
          path:'geely',
          color:['brown','gold','red','white']
      },
      '本田':{
          path:'Honda',
          color:['blue','brown','white']
      },
      '东风':{
          path:'Nissan_xuanyi',
          color:['black','gold','white']
      },
      '荣威':{
          path:'Roewe',
          color:['black','blue','brown','red','white']
      },
      '大众':{
          path:'VolksWagenwerk_Lavida',
          color:['black','blue','gold','red','silver','white']
      }
  };
  var gt=['国一','国二','国三','国四','国五'];
  var data = Mock.mock({
      // 属性 list 的值是一个数组，其中含有 1 到 10 个元素
      'list|40000': [{
          // 属性 id 是一个自增数，起始值为 1，每次增 1
          'id|+1': 100000,
          'color|1':colork,
          'brand|1':Object.keys(series),
          'rate|1':['★','★★','★★★','★★★★','★★★★★'],
          'serie':function(){
              var arr=series[this.brand].children;
              return arr;
          },
  		'serie_type|1':type,
          'serie_seat|1':seat,
          'pinyin':function(){
              var str=series[this.brand].mark;
              return str;
          },
          'buydate':function(){
              let date=new Date(Random.integer(2013,2017),Random.integer(1,12),Random.integer(1,31));
              return date;
          },
          'detail':function(){
              return Random.cparagraph(1,3);
          },
          'saler':function(){
              return Random.cname()
          },
          'km':function(){
              return parseInt(Random.float(0.4, 100) * 100) / 100;
          },
          'engine':function(){
              let num=0.0;
              let arr=[];
              for(let i=0;i<=50;i++){
                  num+=0.1;
                  arr.push(num.toFixed(1));
              }
              return arr[Random.integer(0,49)]
          },
          'province':function(){
              return Random.county(true);
          },
          'price':function(){
              return parseInt(Random.float(0.4, 100) * 100) / 100;
          },
          'paifang|1':gt,
          'biansuxiang|1':['自动','手动','手自一体']
      }]
  });
  data=data.list.map((item)=>{
      let length=item.serie.length;
      let index=Random.integer(0,length-1);
      let color=imgs[item.brand]?imgs[item.brand].color[Random.integer(0,imgs[item.brand].color.length-1)]:item.color;
      return {
          ...item,
          serie_name:item.serie[index],
          path:imgs[item.brand]?imgs[item.brand].path:null,
          images:colorimg[color],
          color:color,
          colorChinese:colorv[color]
      }
  });
  fs.writeFile('./static/result.json',JSON.stringify(data),function(err){
      console.log('写入成功')
  });
  