addressdata.js 1.2 KB

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