index.js 2.1 KB

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