index.js 2.0 KB

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