sharePoster.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <view class="share-poster-wrap">
  3. <image @click="handleCreatePoster" :style="style" class="share-icon" src="@/static/share-poster-icon.png" mode="aspectFill"/>
  4. <view class="poster-mask" v-if="show||showPoster" @click="showPoster=false"></view>
  5. <view class="loading-box" v-if="show">
  6. <image class="load-img" src="../../static/loading.png" mode="aspectFill" />
  7. <view>海报生成中...</view>
  8. </view>
  9. <image v-if="showPoster" class="poster-img" :src="posterImg" mode="widthFix" show-menu-by-longpress />
  10. </view>
  11. </template>
  12. <script>
  13. import {apiGetPoster} from '@/api/common'
  14. export default {
  15. // shareData.type 分享页面:
  16. //activity_detail(活动详情) activity_list(活动列表) special_column_list(专栏列表) special_column_detail(专栏详情)
  17. //report_list(报告列表) report_detail(报告详情) chart_list(图库列表) chart_detail(图库详情)
  18. props:{
  19. style:null,
  20. shareData:null,
  21. },
  22. data () {
  23. return {
  24. loading:false,
  25. show:false,
  26. posterImg:'',
  27. showPoster:false
  28. }
  29. },
  30. methods: {
  31. async handleCreatePoster(){
  32. this.show=true
  33. const res=await apiGetPoster({
  34. code_page:this.shareData.code_page,
  35. code_scene:this.shareData.code_scene,
  36. source:this.shareData.type,
  37. pars:JSON.stringify(this.shareData.data)
  38. })
  39. if(res.code==200){
  40. this.show=false
  41. this.posterImg=res.data
  42. this.showPoster=true
  43. }
  44. }
  45. }
  46. }
  47. </script>
  48. <style lang="scss" scoped>
  49. .share-poster-wrap{
  50. .share-icon{
  51. position: fixed;
  52. bottom: 100rpx;
  53. right: 34rpx;
  54. z-index: 50;
  55. width: 76rpx;
  56. height: 76rpx;
  57. }
  58. .poster-mask{
  59. position: fixed;
  60. left: 0;
  61. top: 0;
  62. right: 0;
  63. bottom: 0;
  64. background: rgba(0, 0, 0, 0.4);
  65. z-index: 998;
  66. }
  67. .loading-box{
  68. background-color: #fff;
  69. position: fixed;
  70. left: 50%;
  71. top: 50%;
  72. z-index: 999;
  73. transform: translate(-50%,-50%);
  74. width: 417rpx;
  75. height: 261rpx;
  76. text-align: center;
  77. padding-top: 80rpx;
  78. font-size: 32rpx;
  79. font-weight: bold;
  80. .load-img{
  81. width: 91rpx;
  82. height: 91rpx;
  83. animation: circle 1s linear infinite;
  84. }
  85. @keyframes circle {
  86. 0%{
  87. transform: rotateZ(0);
  88. }
  89. 100%{
  90. transform: rotateZ(360deg);
  91. }
  92. }
  93. }
  94. .poster-img{
  95. width: 90vw;
  96. display: block;
  97. position: fixed;
  98. left: 50%;
  99. top: 50%;
  100. z-index: 999;
  101. transform: translate(-50%,-50%);
  102. border-radius: 16rpx;
  103. }
  104. }
  105. </style>