export default {
  data() {
    return {
      cityAreaLoad: false,
      cityOptions: []
    }
  },
  created () {
    const cityArea = this.$localStorage('cityArea')
    if (cityArea) {
      const options = JSON.parse(cityArea)
      if (options.length > 0) {
        this.cityAreaLoad = true
        this.cityOptions = options
      } else {
        this.getCityArea()
      }
    } else {
      this.getCityArea()
    }
  },
  computed: {},
  methods: {
    getCityArea () {
      this.$api.base.getRegion().then(data => {
        const options = data.options
        if (options && options.length > 0) {
          this.cityAreaLoad = true
          this.$localStorage('cityArea', JSON.stringify(options))
          this.cityOptions = options
        }
      })
    }
  }
}
