shareCardPage.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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 v-if="shareUrl" class="shareCard" :src="shareUrl" mode="widthFix"></image>
  16. <view class="shareCard" v-else>
  17. <image style="width: 100%;height: 100%;" src="../../static/icons/share_img_zhanwei.png" mode="widthFix"></image>
  18. <view class="share_card_loading">
  19. <view class="loader">
  20. <svg class="circular" viewBox="25 25 50 50">
  21. <circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10" />
  22. </svg>
  23. </view>
  24. 正在为您加载分享图
  25. </view>
  26. </view>
  27. </view>
  28. <view class="share_copy_txt">
  29. 长按图片保存至本地
  30. </view>
  31. <view class="share_copy_notice">
  32. 友情提醒,认证业主并通过后再分享才会产生相应的收益
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. export default {
  38. data() {
  39. return {
  40. shareUrl:"",
  41. type:"",
  42. projectId:"",
  43. page:"",
  44. shareRemark:"",
  45. };
  46. },
  47. created() {
  48. },
  49. onLoad(param) {
  50. this.page = param.page;
  51. this.projectId =param.projectId;
  52. this.type=param.type;
  53. this.getShareCard();
  54. this.queryProjectByH5();
  55. },
  56. methods:{
  57. async getShareCard(){
  58. uni.showLoading({
  59. title:"分享图片生成中"
  60. })
  61. let ret = await this.$myRequest({
  62. url: "/share/shareCard",
  63. data: {
  64. "page": this.page,
  65. "projectId": this.projectId,
  66. "type":this.type
  67. }
  68. })
  69. if (ret.data.success) {
  70. this.shareUrl = ret.data.single;
  71. uni.hideLoading()
  72. }else{
  73. uni.hideLoading()
  74. }
  75. },
  76. async queryProjectByH5(){
  77. let ret = await this.$myRequest({
  78. url: "/project/queryProjectByH5",
  79. data: {
  80. "projectId": this.projectId,
  81. }
  82. })
  83. if (ret.data.success) {
  84. this.shareRemark = ret.data.single.shareRemark||''
  85. }
  86. },
  87. back(){
  88. uni.navigateBack({
  89. delta:1
  90. })
  91. },
  92. copy(){
  93. let textarea = document.createElement("textarea")
  94. textarea.value = this.shareRemark
  95. textarea.readOnly = "readOnly"
  96. document.body.appendChild(textarea)
  97. textarea.select() // 选中文本内容
  98. textarea.setSelectionRange(0, this.shareRemark.length)
  99. let result = document.execCommand("copy")
  100. textarea.remove()
  101. uni.showToast({
  102. icon:"none",
  103. title:"复制成功"
  104. })
  105. }
  106. }
  107. }
  108. </script>
  109. <style lang="scss">
  110. .share_body{
  111. display: flex;
  112. flex-direction: column;
  113. justify-content: center;
  114. align-items: center;
  115. width: 100%;
  116. background: #4e4e4e;
  117. height: 100vh;
  118. }
  119. .share_card_info{
  120. width: 550rpx;
  121. display: flex;
  122. flex-direction: column;
  123. align-items: center;
  124. background-color: #FFFFFF;
  125. border-radius: 10rpx;
  126. .share_title{
  127. width: 100%;
  128. display: flex;
  129. justify-content: center;
  130. align-items: center;
  131. margin-top: 30rpx;
  132. position: relative;
  133. .title{
  134. width: 292rpx;
  135. height: 34rpx;
  136. }
  137. .close{
  138. width: 24rpx;
  139. height: 24rpx;
  140. position: absolute;
  141. right: 20rpx;
  142. top: 5rpx;
  143. }
  144. }
  145. .share_desc{
  146. width: calc(100% - 60rpx);
  147. font-size: 24rpx;
  148. font-family: Verdana, Verdana-Regular;
  149. font-weight: 400;
  150. text-align: left;
  151. color: #7f7f7f;
  152. margin-top: 22rpx;
  153. box-sizing: border-box;
  154. text-overflow: -o-ellipsis-lastline;
  155. overflow: hidden;
  156. text-overflow: ellipsis;
  157. display: -webkit-box;
  158. -webkit-line-clamp: 2;
  159. line-clamp: 2;
  160. -webkit-box-orient: vertical;
  161. }
  162. .share_copy{
  163. display: flex;
  164. justify-content: center;
  165. align-items: center;
  166. margin-top: 12rpx;
  167. .icon_share_copy{
  168. width: 24rpx;
  169. height: 24rpx;
  170. }
  171. .share_txt{
  172. font-size: 24rpx;
  173. font-family: Verdana, Verdana-Regular;
  174. font-weight: 400;
  175. text-align: left;
  176. color: #2c2c2c;
  177. margin-left: 6rpx;
  178. }
  179. }
  180. .shareCard{
  181. width: 490rpx;
  182. margin-top: 10rpx;
  183. margin-bottom: 30rpx;
  184. position: relative;
  185. .share_card_loading{
  186. position: absolute;
  187. left: 50%;
  188. top: 50%;
  189. transform: translate(-50%,-50%);
  190. font-size: 24rpx;
  191. font-family: Verdana, Verdana-Regular;
  192. font-weight: 400;
  193. text-align: center;
  194. color: #919191;
  195. }
  196. }
  197. }
  198. .share_copy_txt{
  199. font-size: 28rpx;
  200. font-family: Verdana, Verdana-Regular;
  201. font-weight: 400;
  202. text-align: center;
  203. color: #ffffff;
  204. margin-top: 40rpx;
  205. }
  206. .share_copy_notice{
  207. font-size: 22rpx;
  208. font-family: Verdana, Verdana-Regular;
  209. font-weight: 400;
  210. text-align: center;
  211. color: #919191;
  212. }
  213. .loader {
  214. position: relative;
  215. margin: 0 auto;
  216. width: 70rpx;
  217. height: 70rpx;
  218. top: 50%;
  219. transform: translateY(-50%);
  220. &:before {
  221. content: '';
  222. display: block;
  223. padding-top: 100%;
  224. }
  225. }
  226. .circular {
  227. animation: rotate 2s linear infinite;
  228. height: 100%;
  229. transform-origin: center center;
  230. width: 100%;
  231. position: absolute;
  232. top: 0;
  233. bottom: 0;
  234. left: 0;
  235. right: 0;
  236. margin: auto;
  237. }
  238. .path {
  239. stroke-dasharray: 1, 200;
  240. stroke-dashoffset: 0;
  241. animation: dash 1.5s ease-in-out infinite, color 6s ease-in-out infinite;
  242. stroke-linecap: round;
  243. }
  244. @keyframes rotate {
  245. 100% {
  246. transform: rotate(360deg);
  247. }
  248. }
  249. @keyframes dash {
  250. 0% {
  251. stroke-dasharray: 1, 200;
  252. stroke-dashoffset: 0;
  253. }
  254. 50% {
  255. stroke-dasharray: 89, 200;
  256. stroke-dashoffset: -35rpx;
  257. }
  258. 100% {
  259. stroke-dasharray: 89, 200;
  260. stroke-dashoffset: -124rpx;
  261. }
  262. }
  263. @keyframes color {
  264. 100%,
  265. 0% {
  266. stroke: #919191;
  267. }
  268. 40% {
  269. stroke: #919191;
  270. }
  271. 66% {
  272. stroke: #919191;
  273. }
  274. 80%,
  275. 90% {
  276. stroke: #919191;
  277. }
  278. }
  279. </style>