addressdata.js 1.3 KB

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