addressdata.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. *请求获取省市区
  3. *已提供给地区选择picker组件使用
  4. */
  5. import ajaxService from '@/services/ajax.service.js'
  6. import PublicService from '@/services/public.service'
  7. const _PublicService = new PublicService(ajaxService)
  8. const provinceData=[];
  9. const cityData=[];
  10. const areaData=[];
  11. _PublicService.GetAllAddressData().then(res =>{
  12. let list = res.data;
  13. list.forEach(item => {
  14. let xxx = handleCitys(item);
  15. provinceData.push(item);
  16. cityData.push(xxx.e);
  17. areaData.push(xxx.f);
  18. })
  19. //获取市后继续处理
  20. function handleCitys(data) {
  21. const x = [];
  22. const s = [];
  23. if (data.cityList.length) {
  24. data.cityList.forEach(item => {
  25. let xxx = handleTowns(item);
  26. s.push(xxx);
  27. x.push(item)
  28. })
  29. }else{
  30. s.push([{name:''}]);
  31. x.push([{name:''}]);
  32. }
  33. return {
  34. e: x,
  35. f: s,
  36. };
  37. }
  38. //获取区后继续处理
  39. function handleTowns(data) {
  40. const x = [];
  41. data.townList.forEach(item => {
  42. x.push(item)
  43. })
  44. return x;
  45. }
  46. function handleData3(data) {
  47. const xxx = [];
  48. data.forEach(item => {
  49. const ooo = []
  50. item.forEach(opt => {
  51. opt.forEach(z => {
  52. ooo.push(z);
  53. })
  54. })
  55. xxx.push(ooo)
  56. })
  57. return xxx;
  58. }
  59. })
  60. module.exports = {
  61. provinceData,
  62. cityData,
  63. areaData
  64. }