index.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. import baseComponent from '../helpers/baseComponent'
  2. import classNames from '../helpers/classNames'
  3. baseComponent({
  4. properties: {
  5. prefixCls: {
  6. type: String,
  7. value: 'wux-button',
  8. },
  9. type: {
  10. type: String,
  11. value: 'stable',
  12. },
  13. clear: {
  14. type: Boolean,
  15. value: false,
  16. },
  17. block: {
  18. type: Boolean,
  19. value: false,
  20. },
  21. full: {
  22. type: Boolean,
  23. value: false,
  24. },
  25. outline: {
  26. type: Boolean,
  27. value: false,
  28. },
  29. bordered: {
  30. type: Boolean,
  31. value: true,
  32. },
  33. size: {
  34. type: String,
  35. value: 'default',
  36. },
  37. disabled: {
  38. type: Boolean,
  39. value: false,
  40. },
  41. loading: {
  42. type: Boolean,
  43. value: false,
  44. },
  45. formType: {
  46. type: String,
  47. value: '',
  48. },
  49. openType: {
  50. type: String,
  51. value: '',
  52. },
  53. hoverClass: {
  54. type: String,
  55. value: 'default',
  56. },
  57. hoverStopPropagation: {
  58. type: Boolean,
  59. value: false,
  60. },
  61. hoverStartTime: {
  62. type: Number,
  63. value: 20,
  64. },
  65. hoverStayTime: {
  66. type: Number,
  67. value: 70,
  68. },
  69. lang: {
  70. type: String,
  71. value: 'en',
  72. },
  73. sessionFrom: {
  74. type: String,
  75. value: '',
  76. },
  77. sendMessageTitle: {
  78. type: String,
  79. value: '',
  80. },
  81. sendMessagePath: {
  82. type: String,
  83. value: '',
  84. },
  85. sendMessageImg: {
  86. type: String,
  87. value: '',
  88. },
  89. showMessageCard: {
  90. type: Boolean,
  91. value: false,
  92. },
  93. appParameter: {
  94. type: String,
  95. value: '',
  96. },
  97. },
  98. computed: {
  99. classes() {
  100. const { prefixCls, hoverClass, type, size, block, full, clear, outline, bordered, disabled } = this.data
  101. const wrap = classNames(prefixCls, {
  102. [`${prefixCls}--${type}`]: type,
  103. [`${prefixCls}--${size}`]: size,
  104. [`${prefixCls}--block`]: block,
  105. [`${prefixCls}--full`]: full,
  106. [`${prefixCls}--clear`]: clear,
  107. [`${prefixCls}--outline`]: outline,
  108. [`${prefixCls}--bordered`]: bordered,
  109. [`${prefixCls}--disabled`]: disabled,
  110. })
  111. const hover = hoverClass && hoverClass !== 'default' ? hoverClass : `${prefixCls}--hover`
  112. return {
  113. wrap,
  114. hover,
  115. }
  116. },
  117. },
  118. methods: {
  119. onTap() {
  120. if (!this.data.disabled && !this.data.loading) {
  121. this.triggerEvent('click')
  122. }
  123. },
  124. bindgetuserinfo(e) {
  125. this.triggerEvent('getuserinfo', e.detail)
  126. },
  127. bindcontact(e) {
  128. this.triggerEvent('contact', e.detail)
  129. },
  130. bindgetphonenumber(e) {
  131. this.triggerEvent('getphonenumber', e.detail)
  132. },
  133. bindopensetting(e) {
  134. this.triggerEvent('opensetting', e.detail)
  135. },
  136. onError(e) {
  137. this.triggerEvent('error', e.detail)
  138. },
  139. },
  140. })