index.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { VantComponent } from '../common/component';
  2. import { button } from '../mixins/button';
  3. import { canIUseFormFieldButton } from '../common/version';
  4. const mixins = [button];
  5. if (canIUseFormFieldButton()) {
  6. mixins.push('wx://form-field-button');
  7. }
  8. VantComponent({
  9. mixins,
  10. classes: ['hover-class', 'loading-class'],
  11. data: {
  12. baseStyle: '',
  13. },
  14. props: {
  15. formType: String,
  16. icon: String,
  17. classPrefix: {
  18. type: String,
  19. value: 'van-icon',
  20. },
  21. plain: Boolean,
  22. block: Boolean,
  23. round: Boolean,
  24. square: Boolean,
  25. loading: Boolean,
  26. hairline: Boolean,
  27. disabled: Boolean,
  28. loadingText: String,
  29. customStyle: String,
  30. loadingType: {
  31. type: String,
  32. value: 'circular',
  33. },
  34. type: {
  35. type: String,
  36. value: 'default',
  37. },
  38. dataset: null,
  39. size: {
  40. type: String,
  41. value: 'normal',
  42. },
  43. loadingSize: {
  44. type: String,
  45. value: '20px',
  46. },
  47. color: String,
  48. },
  49. methods: {
  50. onClick(event) {
  51. this.$emit('click', event);
  52. const { canIUseGetUserProfile, openType, getUserProfileDesc, lang, } = this.data;
  53. if (openType === 'getUserInfo' && canIUseGetUserProfile) {
  54. wx.getUserProfile({
  55. desc: getUserProfileDesc || ' ',
  56. lang: lang || 'en',
  57. complete: (userProfile) => {
  58. this.$emit('getuserinfo', userProfile);
  59. },
  60. });
  61. }
  62. },
  63. },
  64. });