index.js 937 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. Component({
  2. properties: {
  3. visible: {
  4. type: Boolean,
  5. value: !1
  6. },
  7. title: {
  8. type: String,
  9. value: ""
  10. },
  11. optionsList: {
  12. type: Array
  13. },
  14. defaultVal: {
  15. type: Number,
  16. value: null
  17. }
  18. },
  19. data: {
  20. selected: null
  21. },
  22. methods: {
  23. close: function () {
  24. this.triggerEvent("cancel");
  25. },
  26. radioChange: function (t) {
  27. this.setData({
  28. selected: Number(t.detail.value),
  29. defaultVal: Number(t.detail.value)
  30. });
  31. },
  32. cancel: function () {
  33. this.triggerEvent("cancel");
  34. },
  35. confirm: function () {
  36. (this.data.defaultVal || 0 === this.data.defaultVal) && (this.triggerEvent("selectOption", this.data.defaultVal),
  37. this.triggerEvent("cancel")), (this.data.selected || 0 === this.data.selected) && (this.triggerEvent("selectOption", this.data.selected),
  38. this.triggerEvent("cancel"));
  39. }
  40. }
  41. });