city.vue 969 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <template>
  2. <view>
  3. <city-select @cityClick="cityClick" :formatName="formatName" :activeCity="activeCity" :hotCity="hotCity"
  4. :obtainCitys="obtainCitys" :isSearch="true" ref="citys">
  5. </city-select>
  6. </view>
  7. </template>
  8. <script>
  9. import citys from '@/components/city-select/citys.js'
  10. import citySelect from '@/components/city-select/city-select.vue'
  11. export default {
  12. data() {
  13. return {
  14. //需要构建索引参数的名称(注意:传递的对象里面必须要有这个名称的参数)
  15. formatName: 'cityName',
  16. //当前城市
  17. activeCity: {},
  18. //热门城市
  19. hotCity: [],
  20. //显示的城市数据
  21. obtainCitys: citys
  22. }
  23. },
  24. components: {
  25. citySelect
  26. },
  27. onShow() {
  28. },
  29. onLoad(body) {
  30. this.activeCity = JSON.parse(body.activeCity);
  31. },
  32. methods: {
  33. cityClick(item) {
  34. uni.$emit('changeCity', item);
  35. uni.navigateBack();
  36. }
  37. }
  38. }
  39. </script>
  40. <style></style>