linkage.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <view class="page">
  3. <view class="title">
  4. <view class="tt">
  5. {{province}}
  6. </view>
  7. <view class="tt">
  8. {{city}}
  9. </view>
  10. <view class="tt">
  11. {{area}}
  12. </view>
  13. </view>
  14. <view class="link u-f u-f-jsb flex ">
  15. <ul class="content" :style="'height:'+ heightCot + 'upx'">
  16. <scroll-view scroll-y style="height: 500rpx;">
  17. <li :class="index == isprovince?'active':''" @click="selectProvince(item, index)"
  18. v-for="(item,index) in provincelist" :key="index">
  19. {{item.label}}
  20. </li>
  21. </scroll-view>
  22. </ul>
  23. <ul class="content" :style="'height:'+ heightCot + 'upx'">
  24. <scroll-view scroll-y style="height: 500rpx;">
  25. <li :class="index == iscity?'active':''" @click="selectCity(item, index)"
  26. v-for="(item,index) in citylist" :key="index">{{item.label}}
  27. </li>
  28. </scroll-view>
  29. </ul>
  30. <ul class="content" :style="'height:'+ heightCot + 'upx'">
  31. <scroll-view scroll-y style="height: 500rpx;">
  32. <li :class="index == isarea?'active':''" @click="selectaArea(item, index)"
  33. v-for="(item,index) in arealist" :key="index">{{item.label}}
  34. </li>
  35. </scroll-view>
  36. </ul>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import {
  42. address
  43. } from '../data/data.js'
  44. export default {
  45. name: "linkage",
  46. data() {
  47. return {
  48. isprovince: null,
  49. iscity: null,
  50. isarea: null,
  51. province: '',
  52. city: '',
  53. area: '',
  54. provincelist: [],
  55. citylist: [],
  56. arealist: [],
  57. chooseprovince: '',
  58. choosecity: '',
  59. choosearea: '',
  60. heightCot: 0,
  61. };
  62. },
  63. created() {
  64. uni.getSystemInfo({
  65. success: res => {
  66. //console.log(res.safeArea.height)
  67. this.heightCot = (res.safeArea.height * 2) / 2
  68. }
  69. })
  70. this.provincelist = address
  71. },
  72. onLoad() {
  73. },
  74. methods: {
  75. selectProvince(item, i) {
  76. this.isprovince = i
  77. if (item.child) {
  78. this.citylist = item.child
  79. }
  80. this.setchose(1)
  81. this.chooseprovince = item.label
  82. this.getchoose()
  83. },
  84. selectCity(item, i) {
  85. this.iscity = i
  86. if (item.child) {
  87. this.arealist = item.child
  88. }
  89. this.setchose(2)
  90. if (item.label != '市辖区' && item.label != '特别行政区') {
  91. this.choosecity = item.label
  92. }
  93. this.getchoose()
  94. },
  95. selectaArea(item, i) {
  96. this.isarea = i
  97. this.choosearea = item.label
  98. this.getchoose()
  99. },
  100. getchoose() {
  101. const {
  102. chooseprovince,
  103. choosecity,
  104. choosearea
  105. } = this
  106. this.$emit('conceal', {
  107. chooseprovince,
  108. choosecity,
  109. choosearea
  110. })
  111. },
  112. setchose(id){
  113. if(id == 1){
  114. this.choosecity = ''
  115. this.choosearea = ''
  116. this.iscity = null
  117. this.isarea = null
  118. }else if(id == 2){
  119. this.choosearea = ''
  120. this.isarea = null
  121. }
  122. }
  123. }
  124. }
  125. </script>
  126. <style lang="scss" scoped>
  127. ul,
  128. li {
  129. list-style: none;
  130. }
  131. .page {
  132. z-index: 999;
  133. background: #FFFFFF;
  134. width: 100%;
  135. height: 200px;
  136. position: absolute;
  137. bottom: 0px;
  138. // margin-left: 30rpx;
  139. // padding: 30rpx;
  140. .link {
  141. width: 100%;
  142. // margin-left: 30rpx;
  143. // padding: 10rpx 40rpx;
  144. .title{
  145. display: flex;
  146. }
  147. .content {
  148. //margin-top: 30upx;
  149. width: 33.333%;
  150. height: 500upx;
  151. overflow-y: auto;
  152. text-align: center;
  153. li {
  154. border-bottom: 1px solid #f1f1f1;
  155. padding: 30upx 0;
  156. }
  157. li:last-child {
  158. border-bototm: none !important;
  159. }
  160. .active {
  161. color: #FF5529 !important;
  162. }
  163. }
  164. }
  165. }
  166. </style>