兼兼街租房小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

141 lines
3.4 KiB

  1. <template>
  2. <view class="content">
  3. <!-- 选择展示框 -->
  4. <u-dropdown ref="uDropdown" @open="open" @close="close">
  5. <u-dropdown-item v-model="region" :title="region" :options="options1">
  6. <!-- 地区联动 -->
  7. </u-dropdown-item>
  8. <u-dropdown-item v-model="live" :title="live.length>1?'多选':live[0]" :options="options2">
  9. <!-- 分栏 -->
  10. </u-dropdown-item>
  11. <u-dropdown-item v-model="price" :title="price" :options="options2">
  12. <!-- 价格区间选择 -->
  13. <view class="Price-box">
  14. <view class="Price-box-title">
  15. 快捷选择
  16. </view>
  17. <view class="Price-box-select">
  18. <view class="Price-box-select-row" v-for="(item,index) in price_list" :key="index" @click="changePriceIndex(index)">
  19. <u-tag :text="item.conten" :mode="item.mode" size="select-custom"/>
  20. </view>
  21. </view>
  22. </view>
  23. <!-- 间隔区间线 -->
  24. </u-dropdown-item>
  25. </u-dropdown>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. name: "select-search",
  31. props: {
  32. list: {
  33. typeof: Array,
  34. default: []
  35. }
  36. },
  37. data() {
  38. return {
  39. region: '区域',
  40. live: ['居住',],
  41. price: '租金',
  42. priceIndex: '', //记录价格坐标
  43. price_list: [
  44. {
  45. mode: 'plain',
  46. conten: '不限'
  47. },{
  48. mode: 'plain',
  49. conten: '<800'
  50. },{
  51. mode: 'plain',
  52. conten: '800-1000'
  53. },{
  54. mode: 'plain',
  55. conten: '>1000'
  56. }]
  57. };
  58. },
  59. methods: {
  60. open(index) {
  61. console.log(index,"打开")
  62. // 展开某个下来菜单时,先关闭原来的其他菜单的高亮
  63. // 同时内部会自动给当前展开项进行高亮
  64. this.$refs.uDropdown.highlight();
  65. },
  66. close(index) {
  67. console.log(index,"关闭")
  68. // 关闭的时候,给当前项加上高亮
  69. // 当然,您也可以通过监听dropdown-item的@change事件进行处理
  70. this.$refs.uDropdown.highlight(index);
  71. },
  72. change() {
  73. // 更多的细节,如有需要请自行根据业务逻辑进行处理
  74. // this.$refs.uDropdown.highlight(xxx);
  75. console.log(this.$refs.uDropdown)
  76. },
  77. // 请求数据
  78. /*
  79. * 将请求的价格做相应的处理
  80. * 小标的plain空 light量
  81. * list[
  82. * {mode: 'plain', content:'内容'}]
  83. *
  84. */
  85. // 选择价格
  86. changePriceIndex(index){
  87. console.log(index)
  88. // 只能选择一个
  89. const price_list = this.price_list;
  90. // 如果记录的下标值不为空且与之前记录的值不同则将之前的暗灭
  91. if(this.priceIndex !== index && this.priceIndex !== ''){
  92. this.price_list[this.priceIndex].mode = 'plain';
  93. // 将值保存到一个地方
  94. }
  95. if(this.priceIndex === index ){
  96. // 取消保存的值
  97. }
  98. this.priceIndex = index
  99. if(price_list[index].mode === 'dark'){
  100. this.price_list[index].mode = 'plain'
  101. }else {
  102. this.price_list[index].mode = 'dark'
  103. }
  104. this.price_list = price_list
  105. }
  106. }
  107. }
  108. </script>
  109. <style lang="scss" scoped>
  110. .content {
  111. width: 100%;
  112. height: 80rpx;
  113. border-bottom: rgba(167, 164, 162, .3);
  114. .Price-box{
  115. background-color: #fff;
  116. &-title{
  117. padding-top: 26rpx;
  118. padding-left: 20rpx;
  119. font-weight: 700;
  120. font-size: 36rpx;
  121. }
  122. &-select{
  123. display: flex;
  124. flex-wrap: wrap;
  125. padding-top: 24rpx;
  126. width: 100%;
  127. &-row{
  128. padding: 30rpx 20rpx;
  129. height: 80rpx;
  130. font-size: 28rpx;
  131. }
  132. }
  133. }
  134. }
  135. </style>