share-popup.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <div>
  3. <van-share-sheet
  4. class="sheet"
  5. v-model="showShare"
  6. :options="options"
  7. @select="onSelect"
  8. />
  9. <poster
  10. ref="sharePoster"
  11. @handlerShowPoster="handlerShowPoster"
  12. :userInfo="userInfo"
  13. :dataInfo="dataInfo"
  14. ></poster>
  15. </div>
  16. </template>
  17. <script>
  18. import { Toast } from 'vant'
  19. export default {
  20. props: {
  21. sharePopup: {
  22. type: Boolean,
  23. default: () => false
  24. },
  25. userInfo: {
  26. type: Object,
  27. default: () => ({})
  28. },
  29. dataInfo: {
  30. type: Object,
  31. default: () => ({})
  32. }
  33. },
  34. watch: {
  35. sharePopup (val) {
  36. this.showShare = val
  37. },
  38. showShare (val) {
  39. if (!val) {
  40. this.$emit('handlerShow')
  41. }
  42. }
  43. },
  44. data () {
  45. return {
  46. showShare: false,
  47. options: [
  48. { name: '微信', icon: 'wechat', id: 0 },
  49. {
  50. name: '分享海报',
  51. icon: 'https://static.caimei365.com/app/mini-distribution/haibao.png',
  52. id: 1
  53. }
  54. ],
  55. sharePoster: true
  56. }
  57. },
  58. methods: {
  59. onSelect ($event) {
  60. const form = {
  61. 0: () => {
  62. Toast.success('请点击右上角...分享好友')
  63. this.showShare = false
  64. },
  65. 1: () => this.getPoster()
  66. }
  67. form[$event.id]()
  68. },
  69. getPoster () {
  70. this.showShare = false
  71. Toast.loading({
  72. message: '加载中...',
  73. forbidClick: true
  74. })
  75. this.$refs.sharePoster.show = true
  76. this.$refs.sharePoster.showPoster = true
  77. },
  78. handlerShowPoster () {
  79. this.sharePoster = false
  80. }
  81. }
  82. }
  83. </script>
  84. <style lang="scss" scoped>
  85. ::v-deep .sheet .van-share-sheet__options {
  86. justify-content: space-around;
  87. }
  88. </style>