index.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // components/w-dialog/index.ts
  2. Component({
  3. options: {
  4. multipleSlots: true,
  5. styleIsolation: "shared"
  6. },
  7. /**
  8. * 组件的属性列表
  9. */
  10. properties: {
  11. show: {
  12. type: Boolean,
  13. value: false
  14. },
  15. /** 标题 */
  16. title: {
  17. type: String,
  18. value: ''
  19. },
  20. /** 文本内容 */
  21. message: {
  22. type: String,
  23. value: ''
  24. },
  25. /**
  26. * 内容对齐方式,可选值为left right
  27. */
  28. messageAlign: {
  29. type: String,
  30. value: 'center'
  31. },
  32. /**
  33. * 样式风格,可选值为round-button
  34. */
  35. theme: {
  36. type: String,
  37. value: 'default'
  38. },
  39. /**
  40. * z-index 层级
  41. */
  42. zIndex: {
  43. type: Number,
  44. default: 100
  45. },
  46. /** 是否展示确认按钮 */
  47. showConfirmButton: {
  48. type: Boolean,
  49. value: true,
  50. },
  51. /** 是否展示取消按钮 */
  52. showCancelButton: {
  53. type: Boolean,
  54. value: true,
  55. },
  56. /** 确认按钮的文案 */
  57. confirmButtonText: {
  58. type: String,
  59. value: '确认'
  60. },
  61. /** 取消按钮的文案 */
  62. cancelButtonText: {
  63. type: String,
  64. value: '取消'
  65. },
  66. /** 是否展示遮罩层 */
  67. overlay: {
  68. type: Boolean,
  69. value: true,
  70. },
  71. /** 是否在点击遮罩层后关闭 */
  72. closeOnClickOverlay: {
  73. type: Boolean,
  74. value: true,
  75. }
  76. },
  77. /**
  78. * 组件的初始数据
  79. */
  80. data: {
  81. },
  82. /**
  83. * 组件的方法列表
  84. */
  85. methods: {
  86. /** 取消 */
  87. onDialogClose() {
  88. this.setData({
  89. show: false
  90. })
  91. this.triggerEvent('close', false)
  92. },
  93. /** 确认 */
  94. onDialogConfirm() {
  95. this.setData({
  96. show: false
  97. })
  98. this.triggerEvent('confirm')
  99. },
  100. onClickOverlay() {
  101. if(this.data.closeOnClickOverlay) {
  102. this.setData({
  103. show: false
  104. })
  105. this.triggerEvent('click-overlay')
  106. }
  107. }
  108. }
  109. })