index.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. },
  40. methods: {
  41. onSelect(event) {
  42. const { index } = event.currentTarget.dataset;
  43. const { actions, closeOnClickAction, canIUseGetUserProfile } = this.data;
  44. const item = actions[index];
  45. if (item) {
  46. this.$emit('select', item);
  47. if (closeOnClickAction) {
  48. this.onClose();
  49. }
  50. if (item.openType === 'getUserInfo' && canIUseGetUserProfile) {
  51. wx.getUserProfile({
  52. desc: item.getUserProfileDesc || ' ',
  53. complete: (userProfile) => {
  54. this.$emit('getuserinfo', userProfile);
  55. },
  56. });
  57. }
  58. }
  59. },
  60. onCancel() {
  61. this.$emit('cancel');
  62. },
  63. onClose() {
  64. this.$emit('close');
  65. },
  66. onClickOverlay() {
  67. this.$emit('click-overlay');
  68. this.onClose();
  69. },
  70. },
  71. });