index.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // components/radioAndcheckbox/index.js
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. properties: {
  7. // picker类型
  8. type: {
  9. type: String,
  10. value: 'checkbox'
  11. },
  12. // 未选择时提示
  13. placeholder: {
  14. type: Array,
  15. value: ['请选择']
  16. },
  17. // 数据列表
  18. list: {
  19. type: Array,
  20. value: []
  21. },
  22. // 显示参数key
  23. rangeKey: {
  24. type: String,
  25. value: ''
  26. },
  27. // 选择下标
  28. index: {
  29. type: Number,
  30. value: null
  31. },
  32. // 日期时间选择器
  33. dateTime: {
  34. type: String,
  35. value: null
  36. },
  37. delay: {
  38. type: Number,
  39. value: null
  40. },
  41. chooseBuilding: {
  42. type: Boolean,
  43. value: false
  44. },
  45. className:{
  46. type: String,
  47. value:''
  48. },
  49. sn:{
  50. type:Boolean,
  51. value: false
  52. }
  53. },
  54. /**
  55. * 组件的初始数据
  56. */
  57. data: {
  58. radio:null,
  59. checkbox:null,
  60. },
  61. /**
  62. * 组件的方法列表
  63. */
  64. methods: {
  65. // 确定
  66. sure() {
  67. if (this.data.type == 'radio') {
  68. if (this.data.radio) {
  69. this.setData({
  70. chooseBuilding: false
  71. })
  72. this.triggerEvent('change', this.data.radio)
  73. } else {
  74. wx.showToast({
  75. title: '请选择',
  76. icon:'none'
  77. })
  78. }
  79. } else if (this.data.type == 'checkbox') {
  80. if (this.data.checkbox) {
  81. this.setData({
  82. chooseBuilding: false
  83. })
  84. this.triggerEvent('change', this.data.checkbox)
  85. } else {
  86. wx.showToast({
  87. title: '请选择',
  88. icon:'none'
  89. })
  90. }
  91. }
  92. },
  93. // 关闭租赁楼幢弹出框
  94. crossBuilding(e) {
  95. this.setData({
  96. chooseBuilding: false
  97. })
  98. },
  99. // 多选框
  100. checkboxChange(e) {
  101. this.data.checkbox = e.detail.value
  102. },
  103. // 单选框
  104. chooserRadio(e) {
  105. this.setData({
  106. radio : e.detail.value
  107. })
  108. },
  109. }
  110. })