shareCardPage.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <view class="share_body">
  3. <view class="share_card_info">
  4. <view class="share_title">
  5. <image class="title" src="../../static/icons/icon_share_title.png" mode=""></image>
  6. <image @click="back" class="close" src="../../static/icons/icon_close_share.png" mode=""></image>
  7. </view>
  8. <view class="share_desc">
  9. {{shareRemark}}
  10. </view>
  11. <view class="share_copy" @click="copy" v-if="shareRemark">
  12. <image class="icon_share_copy" src="../../static/icons/icon_copy.png" mode=""></image>
  13. <text class="share_txt">复制发圈</text>
  14. </view>
  15. <image class="shareCard" :src="shareUrl" mode="widthFix"></image>
  16. </view>
  17. <view class="share_copy_txt">
  18. 长按图片保存至本地
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. data() {
  25. return {
  26. shareUrl:"",
  27. type:"",
  28. projectId:"",
  29. page:"",
  30. shareRemark:"",
  31. };
  32. },
  33. created() {
  34. },
  35. onLoad(param) {
  36. this.page = param.page;
  37. this.projectId =param.projectId;
  38. this.type=param.type;
  39. this.getShareCard();
  40. this.queryProjectByH5();
  41. },
  42. methods:{
  43. async getShareCard(){
  44. uni.showLoading({
  45. title:"分享图片生成中"
  46. })
  47. let ret = await this.$myRequest({
  48. url: "/share/shareCard",
  49. data: {
  50. "page": this.page,
  51. "projectId": this.projectId,
  52. "type":this.type
  53. }
  54. })
  55. if (ret.data.success) {
  56. this.shareUrl = ret.data.single;
  57. uni.hideLoading()
  58. }else{
  59. uni.hideLoading()
  60. }
  61. },
  62. async queryProjectByH5(){
  63. let ret = await this.$myRequest({
  64. url: "/project/queryProjectByH5",
  65. data: {
  66. "projectId": this.projectId,
  67. }
  68. })
  69. if (ret.data.success) {
  70. this.shareRemark = ret.data.single.shareRemark||''
  71. }
  72. },
  73. back(){
  74. uni.navigateBack({
  75. delta:1
  76. })
  77. },
  78. copy(){
  79. let textarea = document.createElement("textarea")
  80. textarea.value = this.shareRemark
  81. textarea.readOnly = "readOnly"
  82. document.body.appendChild(textarea)
  83. textarea.select() // 选中文本内容
  84. textarea.setSelectionRange(0, this.shareRemark.length)
  85. let result = document.execCommand("copy")
  86. textarea.remove()
  87. uni.showToast({
  88. icon:"none",
  89. title:"复制成功"
  90. })
  91. }
  92. }
  93. }
  94. </script>
  95. <style lang="scss">
  96. .share_body{
  97. display: flex;
  98. flex-direction: column;
  99. justify-content: center;
  100. align-items: center;
  101. width: 100%;
  102. background: #4e4e4e;
  103. height: 100vh;
  104. }
  105. .share_card_info{
  106. width: 550rpx;
  107. display: flex;
  108. flex-direction: column;
  109. align-items: center;
  110. background-color: #FFFFFF;
  111. border-radius: 10rpx;
  112. .share_title{
  113. width: 100%;
  114. display: flex;
  115. justify-content: center;
  116. align-items: center;
  117. margin-top: 30rpx;
  118. position: relative;
  119. .title{
  120. width: 292rpx;
  121. height: 34rpx;
  122. }
  123. .close{
  124. width: 24rpx;
  125. height: 24rpx;
  126. position: absolute;
  127. right: 20rpx;
  128. top: 5rpx;
  129. }
  130. }
  131. .share_desc{
  132. width: calc(100% - 60rpx);
  133. font-size: 24rpx;
  134. font-family: Verdana, Verdana-Regular;
  135. font-weight: 400;
  136. text-align: left;
  137. color: #7f7f7f;
  138. margin-top: 22rpx;
  139. box-sizing: border-box;
  140. text-overflow: -o-ellipsis-lastline;
  141. overflow: hidden;
  142. text-overflow: ellipsis;
  143. display: -webkit-box;
  144. -webkit-line-clamp: 2;
  145. line-clamp: 2;
  146. -webkit-box-orient: vertical;
  147. }
  148. .share_copy{
  149. display: flex;
  150. justify-content: center;
  151. align-items: center;
  152. margin-top: 12rpx;
  153. .icon_share_copy{
  154. width: 24rpx;
  155. height: 24rpx;
  156. }
  157. .share_txt{
  158. font-size: 24rpx;
  159. font-family: Verdana, Verdana-Regular;
  160. font-weight: 400;
  161. text-align: left;
  162. color: #2c2c2c;
  163. margin-left: 6rpx;
  164. }
  165. }
  166. .shareCard{
  167. width: 490rpx;
  168. margin-top: 10rpx;
  169. margin-bottom: 30rpx;
  170. }
  171. }
  172. .share_copy_txt{
  173. font-size: 28rpx;
  174. font-family: Verdana, Verdana-Regular;
  175. font-weight: 400;
  176. text-align: center;
  177. color: #ffffff;
  178. margin-top: 40rpx;
  179. }
  180. </style>