index.js 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { VantComponent } from '../common/component';
  2. import { button } from '../mixins/button';
  3. VantComponent({
  4. mixins: [button],
  5. props: {
  6. show: Boolean,
  7. title: String,
  8. cancelText: String,
  9. description: String,
  10. round: {
  11. type: Boolean,
  12. value: true,
  13. },
  14. zIndex: {
  15. type: Number,
  16. value: 100,
  17. },
  18. actions: {
  19. type: Array,
  20. value: [],
  21. },
  22. overlay: {
  23. type: Boolean,
  24. value: true,
  25. },
  26. closeOnClickOverlay: {
  27. type: Boolean,
  28. value: true,
  29. },
  30. closeOnClickAction: {
  31. type: Boolean,
  32. value: true,
  33. },
  34. safeAreaInsetBottom: {
  35. type: Boolean,
  36. value: true,
  37. },
  38. },
  39. methods: {
  40. onSelect(event) {
  41. const { index } = event.currentTarget.dataset;
  42. const { actions, closeOnClickAction, canIUseGetUserProfile } = this.data;
  43. const item = actions[index];
  44. if (item) {
  45. this.$emit('select', item);
  46. if (closeOnClickAction) {
  47. this.onClose();
  48. }
  49. if (item.openType === 'getUserInfo' && canIUseGetUserProfile) {
  50. wx.getUserProfile({
  51. desc: item.getUserProfileDesc || ' ',
  52. complete: (userProfile) => {
  53. this.$emit('getuserinfo', userProfile);
  54. },
  55. });
  56. }
  57. }
  58. },
  59. onCancel() {
  60. this.$emit('cancel');
  61. },
  62. onClose() {
  63. this.$emit('close');
  64. },
  65. onClickOverlay() {
  66. this.$emit('click-overlay');
  67. this.onClose();
  68. },
  69. },
  70. });