drop-down.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. //Component Object
  2. let LD = {
  3. name:'不限',
  4. id:''
  5. }
  6. import { bindInput } from '../../utils/utils'
  7. Component({
  8. properties: {
  9. arr:{
  10. type:Array,
  11. value:[],
  12. observer: function() {
  13. }
  14. },
  15. active:{
  16. type:String,
  17. value:'',
  18. observer: function() {
  19. }
  20. },
  21. city:{
  22. type:String,
  23. value:'',
  24. observer: function(val) {
  25. this.setData({
  26. selectObj:{
  27. quyu: {
  28. name:val,
  29. id:''
  30. },
  31. didian: LD,
  32. xianshi: LD
  33. }
  34. })
  35. }
  36. }
  37. },
  38. data: {
  39. selectObj:{},
  40. min:'',
  41. max:''
  42. },
  43. methods: {
  44. bindInput,
  45. handleClick(e){
  46. console.log(this.properties.arr)
  47. let {type,row} = e.currentTarget.dataset
  48. let tmp = {}
  49. tmp[type] = row
  50. let obj = {
  51. selectObj:Object.assign(this.data.selectObj,tmp)
  52. }
  53. if (type==='quyu') {
  54. obj = {
  55. selectObj:Object.assign(this.data.selectObj,{
  56. didian: LD,
  57. xianshi:LD
  58. })
  59. }
  60. }
  61. if (type==='didian') {
  62. obj = {
  63. selectObj:Object.assign(this.data.selectObj,{
  64. xianshi: LD
  65. })
  66. }
  67. }
  68. if (type === 'jiage') {
  69. obj = {
  70. selectObj:Object.assign(this.data.selectObj,tmp),
  71. minjiage: '',
  72. maxjiage: ''
  73. }
  74. }
  75. if (type === 'jushi') {
  76. obj = {
  77. selectObj:Object.assign(this.data.selectObj,tmp),
  78. minjushi: '',
  79. maxjushi: ''
  80. }
  81. }
  82. Object.keys(this.data.selectObj).forEach(item=>{
  83. let i =this.data.selectObj[item]
  84. i.name = i.name.replace('不限','')
  85. })
  86. this.setData(obj)
  87. this.triggerEvent('selecthandle',{
  88. type,
  89. selectObj:this.data.selectObj
  90. })
  91. },
  92. comfirm(e){
  93. let {type} = e.currentTarget.dataset
  94. let tmp = {}
  95. let min =this.data['min'+type]
  96. let max =this.data['max'+type]
  97. tmp[type] = (!isNaN(min)&&!isNaN(max))?`${min}#${max}`:''
  98. // console.log(tmp);
  99. // let test = new RegExp(/\D/g)
  100. this.triggerEvent('comfirmhandle',tmp)
  101. }
  102. },
  103. created: function() {
  104. },
  105. attached: function() {
  106. },
  107. ready: function() {
  108. },
  109. moved: function() {
  110. },
  111. detached: function() {
  112. }
  113. });