cityList.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. backUrl:'',
  22. checkInDate:'',
  23. checkOutDate:'',
  24. key:''
  25. }
  26. },
  27. methods: {
  28. handleCity(name){
  29. let city = name.replace('市','')
  30. if(this.backUrl){
  31. uni.navigateTo({
  32. url:`${this.backUrl}?cityName=${city}&key=${this.key}&checkInDate=${this.checkInDate}&checkOutDate=${this.checkOutDate}`
  33. })
  34. }else{
  35. uni.navigateTo({
  36. url:'/hotel/index?cityName='+city
  37. })
  38. }
  39. },
  40. getCityList() {
  41. this.status = 'loading'
  42. getCityList().then(res=>{
  43. if(res.state == 'Success'){
  44. this.list = res.content.content
  45. this.status = 'noMore'
  46. }
  47. })
  48. }
  49. },
  50. onLoad(options) {
  51. this.backUrl = options.backUrl
  52. this.checkInDate=options.checkInDate,
  53. this.checkOutDate=options.checkOutDate,
  54. this.key=options.key
  55. this.getCityList()
  56. }
  57. }
  58. </script>
  59. <style lang="scss" >
  60. .cityList{
  61. background: #fff;
  62. .search-box{
  63. position: fixed;
  64. top: 0%;
  65. left: 0%;
  66. padding: 0 24rpx ;
  67. background: #fff;
  68. .search{
  69. width: 702rpx;
  70. height: 72rpx;
  71. text-indent: 20rpx;
  72. background: #F6F6F6;
  73. border-radius: 36rpx;
  74. }
  75. }
  76. .zs-list{
  77. .item{
  78. padding: 28rpx 0;
  79. font-size: 24rpx;
  80. color: #222222;
  81. border-bottom: 1rpx solid #F0F0F0;
  82. margin: 0 24rpx;
  83. }
  84. }
  85. }
  86. </style>