cityList.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <view class="cityList">
  3. <view class="search-box">
  4. <input class="search" v-model="value" type="text" placeholder="搜索城市名称" />
  5. </view>
  6. <zs-list class="list" mt="120rpx" :status="status">
  7. <view class="item" v-for="item in list" :key="item.code" @click="handleCity(item.name)">
  8. {{item.name}}
  9. </view>
  10. </zs-list>
  11. </view>
  12. </template>
  13. <script>
  14. import {getCityList} from '@/api/common'
  15. export default {
  16. data() {
  17. return {
  18. value:'',
  19. list:[],
  20. status:'more'
  21. }
  22. },
  23. methods: {
  24. handleCity(name){
  25. let city = name.replace('市','')
  26. uni.navigateTo({
  27. url:'/hotel/index?cityName='+city
  28. })
  29. },
  30. getCityList() {
  31. this.status = 'loading'
  32. getCityList().then(res=>{
  33. if(res.state == 'Success'){
  34. this.list = res.content.content
  35. this.status = 'noMore'
  36. }
  37. })
  38. }
  39. },
  40. onLoad() {
  41. this.getCityList()
  42. }
  43. }
  44. </script>
  45. <style lang="scss" >
  46. .cityList{
  47. background: #fff;
  48. .search-box{
  49. position: fixed;
  50. top: 0%;
  51. left: 0%;
  52. padding: 0 24rpx ;
  53. background: #fff;
  54. .search{
  55. width: 702rpx;
  56. height: 72rpx;
  57. text-indent: 20rpx;
  58. background: #F6F6F6;
  59. border-radius: 36rpx;
  60. }
  61. }
  62. .zs-list{
  63. .item{
  64. padding: 28rpx 0;
  65. font-size: 24rpx;
  66. color: #222222;
  67. border-bottom: 1rpx solid #F0F0F0;
  68. margin: 0 24rpx;
  69. }
  70. }
  71. }
  72. </style>