sharePoster.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <view class="share-poster-wrap" :catchtouchmove="false">
  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.posterImg=res.data
  41. this.show=false
  42. this.showPoster=true
  43. }else{
  44. this.show=false
  45. }
  46. }
  47. }
  48. }
  49. </script>
  50. <style lang="scss" scoped>
  51. .share-poster-wrap{
  52. .share-icon{
  53. position: fixed;
  54. bottom: 100rpx;
  55. right: 34rpx;
  56. z-index: 50;
  57. width: 76rpx;
  58. height: 76rpx;
  59. }
  60. .poster-mask{
  61. position: fixed;
  62. left: 0;
  63. top: 0;
  64. right: 0;
  65. bottom: 0;
  66. background: rgba(0, 0, 0, 0.4);
  67. z-index: 998;
  68. }
  69. .loading-box{
  70. background-color: #fff;
  71. position: fixed;
  72. left: 50%;
  73. top: 50%;
  74. z-index: 999;
  75. transform: translate(-50%,-50%);
  76. width: 417rpx;
  77. height: 261rpx;
  78. text-align: center;
  79. padding-top: 80rpx;
  80. font-size: 32rpx;
  81. font-weight: bold;
  82. .load-img{
  83. width: 91rpx;
  84. height: 91rpx;
  85. animation: circle 1s linear infinite;
  86. }
  87. @keyframes circle {
  88. 0%{
  89. transform: rotateZ(0);
  90. }
  91. 100%{
  92. transform: rotateZ(360deg);
  93. }
  94. }
  95. }
  96. .poster-img{
  97. width: 90vw;
  98. display: block;
  99. position: fixed;
  100. left: 50%;
  101. top: 50%;
  102. z-index: 999;
  103. transform: translate(-50%,-50%);
  104. border-radius: 16rpx;
  105. }
  106. }
  107. </style>