city.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <view class="page-container" :style="{ paddingTop: (12 + statusBarHeight) + 'px' }">
  3. <view class="custom-navbar">
  4. <view class="navbar-content">
  5. <view class="nav-left" @click="goBack">
  6. <u-icon name="close" color="#333" size="32"></u-icon>
  7. </view>
  8. <view class="nav-title">{{city}}</view>
  9. <view class="nav-right" v-if="onlyShowOneCity"></view>
  10. <view @click="goTo" class="nav-right" v-else>
  11. <image src="../../static/images/filter.svg" mode="widthFix"></image> 筛选城市
  12. </view>
  13. </view>
  14. </view>
  15. <view class="page-content">
  16. <hg-level4-address :city="city" :county="county" :street="street" :onlyShowOneCity="onlyShowOneCity" @confirm="onAddressConfirm"></hg-level4-address>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. import hgLevel4Address from '@/components/hg-level4-address/hgLevel4Address.vue';
  22. export default {
  23. components: {
  24. hgLevel4Address
  25. },
  26. data() {
  27. return {
  28. statusBarHeight: 0, // 状态栏高度
  29. city: '', //市
  30. county: '', //区
  31. street:'',//街道
  32. onlyShowOneCity: false, // 判断是否只显示一个城市
  33. };
  34. },
  35. onLoad(options) {
  36. // 获取状态栏高度
  37. let systemInfo = uni.getSystemInfoSync();
  38. this.statusBarHeight = systemInfo.statusBarHeight || 0;
  39. this.city = options&&options.city||'深圳市'
  40. this.county = options&&options.county||''
  41. this.street = options&&options.street||''
  42. if (options.onlyShowOneCity) {
  43. this.onlyShowOneCity = true
  44. }
  45. },
  46. onShow() {
  47. },
  48. methods: {
  49. onAddressConfirm(selected) {
  50. console.log("选中的地址:", selected);
  51. this.city = selected[1].name
  52. this.county = selected[2].name
  53. let data = {
  54. city: this.city=='全国'||this.city=='全部'?'':this.city,
  55. county: this.county == '全部' ? '' : this.county
  56. }
  57. uni.$emit('filterCity', data)
  58. uni.navigateBack()
  59. },
  60. goBack(){
  61. uni.navigateBack()
  62. },
  63. goTo(){
  64. uni.navigateTo({
  65. url:'/package/jobIntention/city?type=search&onlyShowOneCity=true'
  66. })
  67. }
  68. }
  69. }
  70. </script>
  71. <style lang="scss" scoped>
  72. .page-container{
  73. display: flex;
  74. flex-direction: column;
  75. height: 100vh;
  76. background: #FBFBFB;
  77. }
  78. .custom-navbar {
  79. width: 100%;
  80. height: 88rpx;
  81. box-sizing: border-box;
  82. display: flex;
  83. flex-direction: column;
  84. .navbar-content {
  85. display: flex;
  86. align-items: center;
  87. justify-content: space-between;
  88. box-sizing: border-box;
  89. padding: 0 32rpx;
  90. .nav-left, .nav-right {
  91. width: 146rpx;
  92. height: 60rpx;
  93. display: flex;
  94. align-items: center;
  95. justify-content: flex-start;
  96. padding-left: 20rpx;
  97. }
  98. .nav-right{
  99. // width: fit-content;
  100. white-space: nowrap;
  101. color: #016Bf6;
  102. align-items: center;
  103. justify-content: flex-end;
  104. padding-left: 0rpx;
  105. image{
  106. width: 28rpx;
  107. display: block;
  108. margin-right:6rpx;
  109. position: relative;
  110. top:2rpx
  111. }
  112. }
  113. .nav-title {
  114. color: rgba(51, 51, 51, 1);
  115. font-family: DM Sans;
  116. font-size: 30rpx;
  117. font-weight: 700;
  118. line-height: 26px;
  119. letter-spacing: 0px;
  120. text-align: center;
  121. }
  122. }
  123. }
  124. .page-content {
  125. flex: 1;
  126. overflow: hidden;
  127. display: flex;
  128. }
  129. </style>