addressdata.js 1.4 KB

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