index.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import baseComponent from '../helpers/baseComponent'
  2. import classNames from '../helpers/classNames'
  3. baseComponent({
  4. properties: {
  5. prefixCls: {
  6. type: String,
  7. value: 'wux-prompt',
  8. },
  9. classNames: {
  10. type: null,
  11. value: 'wux-animate--fadeIn',
  12. },
  13. icon: {
  14. type: String,
  15. value: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAQAAAAAYLlVAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QAAKqNIzIAAAAHdElNRQfgCxwAHyE2vHbUAAACWUlEQVRo3u2ZP2gTcRTHP7EpBTOJWrDSxdZBxE0yCC3UdilqUBCs4B8ogVfr0EnQ6lAEsylIXR6moFA1g6IoSAct7WhxUBQFsS5aLDgWcWitLjG5y11zufxyl8Hfd8n7vd+79z738svvfkfAysrqf1fC3609jHGYtnDJJBEuHiDpU7yNAkfj6sAmH990fOV9ADTN8fjK+3VA4izvB9AfL4B3EbY67E75Vn9qHeSCHAzfgQZJIU+f7moaAPvpAC7FAKAnPJ6EprkOQFbP6OZIAbSdgna5PEf4wSt6i8O7/NRx3RZdB84B4y7PGFsrYq7RExGAppgAhnV72ScDdDFVGi7ST4s8jqoD/77/UadTvkiW0wB8pltmZX3jBEYAmizd6YSmKiYfATAStLGadWDAYQ+5p+QXF4G5oBQGANrObccwr50VAXmG5HdQFs8RQpfoKA023Ip1N5c563E/5Qrvwj3NkqGiAU2Q5gYHfCczZPio55mvtuyMADTDHbZUDdnDLOhJKbiu+1O23Qe3sGsgFVC+HFejQgLIA1ro40OVkGUO0SpTtWYM/SuQdZljL/t44jM5T5od8lzWas8XehECCLznmO7kDc6HTLcshs9lsA/IEsOO4Wg95U13whmHPV1fCiMAWWWkaOZkpQkAwP3i52S9CQwBZIUccE+WmwQA3AKu1n+5MYB8JyufmggAte96EQGYyQJYAAtgASyA90y46rC/ahM68DLiigtBAFHfdC4AQBZ4GGH5tzwL6gCc8n3paIRe01v52trQ/wuqaI0X3JQZ80RWVlYN11+uNXxr6IunHwAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxNi0xMS0yOFQwMDozMTozMyswODowMBHRiXcAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTYtMTEtMjhUMDA6MzE6MzMrMDg6MDBgjDHLAAAAAElFTkSuQmCC',
  16. },
  17. title: {
  18. type: String,
  19. value: '',
  20. },
  21. text: {
  22. type: String,
  23. value: '',
  24. },
  25. buttons: {
  26. type: Array,
  27. value: [],
  28. },
  29. visible: {
  30. type: Boolean,
  31. value: false,
  32. },
  33. },
  34. computed: {
  35. classes() {
  36. const { prefixCls, buttons: btns } = this.data
  37. const wrap = classNames(prefixCls)
  38. const button = btns.map((button) => {
  39. const wrap = classNames(`${prefixCls}__button`, {
  40. [`${prefixCls}__button--disabled`]: button.disabled,
  41. [`${button.className}`]: button.className,
  42. })
  43. const hover = button.hoverClass && button.hoverClass !== 'default' ? button.hoverClass : `${prefixCls}__button--hover`
  44. return {
  45. wrap,
  46. hover,
  47. }
  48. })
  49. const bd = `${prefixCls}__bd`
  50. const icon = `${prefixCls}__icon`
  51. const title = `${prefixCls}__title`
  52. const buttons = `${prefixCls}__buttons`
  53. return {
  54. wrap,
  55. button,
  56. bd,
  57. icon,
  58. title,
  59. buttons,
  60. }
  61. },
  62. },
  63. methods: {
  64. /**
  65. * 点击按钮触发事件
  66. */
  67. onTap(e) {
  68. const { buttons } = this.data
  69. const { index } = e.currentTarget.dataset
  70. const value = this.data.buttons[index]
  71. if (value.disabled) return
  72. this.triggerEvent('click', { index, value, buttons })
  73. },
  74. bindgetuserinfo(e) {
  75. this.triggerEvent('getuserinfo', {...e.detail, ...e.currentTarget.dataset })
  76. },
  77. bindcontact(e) {
  78. this.triggerEvent('contact', {...e.detail, ...e.currentTarget.dataset })
  79. },
  80. bindgetphonenumber(e) {
  81. this.triggerEvent('getphonenumber', {...e.detail, ...e.currentTarget.dataset })
  82. },
  83. bindopensetting(e) {
  84. this.triggerEvent('opensetting', {...e.detail, ...e.currentTarget.dataset })
  85. },
  86. onError(e) {
  87. this.triggerEvent('error', {...e.detail, ...e.currentTarget.dataset })
  88. },
  89. },
  90. })