addressdata.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. let list = res.data
  19. list.forEach(item => {
  20. let xxx = handleCitys(item)
  21. provinceData.push(item)
  22. cityData.push(xxx.e)
  23. areaData.push(xxx.f)
  24. })
  25. })
  26. //获取市后继续处理
  27. function handleCitys(data) {
  28. const x = []
  29. const s = []
  30. if (data.cityList.length) {
  31. data.cityList.forEach(item => {
  32. let xxx = handleTowns(item)
  33. s.push(xxx)
  34. x.push(item)
  35. })
  36. } else {
  37. s.push([{
  38. name: ''
  39. }])
  40. x.push([{
  41. name: ''
  42. }])
  43. }
  44. return {
  45. e: x,
  46. f: s,
  47. }
  48. }
  49. //获取区后继续处理
  50. function handleTowns(data) {
  51. const x = []
  52. data.townList.forEach(item => {
  53. x.push(item)
  54. })
  55. return x
  56. }
  57. function handleData3(data) {
  58. const xxx = []
  59. data.forEach(item => {
  60. const ooo = []
  61. item.forEach(opt => {
  62. opt.forEach(z => {
  63. ooo.push(z)
  64. })
  65. })
  66. xxx.push(ooo)
  67. })
  68. return xxx
  69. }
  70. })
  71. module.exports = {
  72. provinceData,
  73. cityData,
  74. areaData
  75. }