button.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. //注意:自定义组件无法触发form的bindsubmit,bindreset事件.
  2. // 在基础库2.10.3 以上 添加 behaviors: ['wx://form-field-button'] 属性 form 可以触发bindsubmit事件。
  3. //可以在组件外层嵌套个button按钮,背景设为none,form-type写在外层按钮上(参考登录页面)
  4. Component({
  5. behaviors: ['wx://form-field-button'], // 用于触发bindsubmit事件
  6. externalClasses: ['tui-button-class'], //自定义样式
  7. properties: {
  8. // primary, white, danger, warning, green, gray,gradual
  9. type: {
  10. type: String,
  11. value: 'gradual',
  12. },
  13. // block, mini, small
  14. size: {
  15. type: String,
  16. value: 'block',
  17. },
  18. // circle, square
  19. shape: {
  20. type: String,
  21. value: 'square'
  22. },
  23. plain: {
  24. type: Boolean,
  25. value: false
  26. },
  27. disabled: {
  28. type: Boolean,
  29. value: false,
  30. },
  31. loading: {
  32. type: Boolean,
  33. value: false,
  34. },
  35. openType: {
  36. type: String,
  37. value: ''
  38. },
  39. formType: {
  40. type: String,
  41. value: ''
  42. },
  43. hoverStopPropagation: {
  44. type: Boolean,
  45. value: false
  46. },
  47. lang: {
  48. type: String,
  49. value: 'en'
  50. },
  51. appParameter: {
  52. type: String,
  53. value: ''
  54. },
  55. sessionFrom: {
  56. type: String,
  57. value: ''
  58. },
  59. showMessageCard: {
  60. type: Boolean,
  61. value: false
  62. },
  63. sendMessageImg: {
  64. type: String,
  65. value: ''
  66. },
  67. sendMessagePath: {
  68. type: String,
  69. value: ''
  70. },
  71. sendMessageTitle: {
  72. type: String,
  73. value: ''
  74. },
  75. hidden: {
  76. type: Boolean,
  77. value: false
  78. }
  79. },
  80. data: {
  81. },
  82. methods: {
  83. handleClick() {
  84. if (this.data.disabled) return false;
  85. this.triggerEvent('click', {});
  86. },
  87. bindgetuserinfo({
  88. detail = {}
  89. } = {}) {
  90. this.triggerEvent('getuserinfo', detail);
  91. },
  92. bindcontact({
  93. detail = {}
  94. } = {}) {
  95. this.triggerEvent('contact', detail);
  96. },
  97. bindgetphonenumber({
  98. detail = {}
  99. } = {}) {
  100. this.triggerEvent('getphonenumber', detail);
  101. },
  102. binderror({
  103. detail = {}
  104. } = {}) {
  105. this.triggerEvent('error', detail);
  106. }
  107. }
  108. })