shareCardPage.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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.type=param.type;
  52. if(this.type==2){
  53. this.projectId =param.projectId;
  54. this.queryProjectByH5();
  55. this.getShareCard();
  56. }else {
  57. this.queryProtocolConfigView();
  58. this.getShareCard();
  59. }
  60. wx.hideMenuItems({
  61. menuList: ['menuItem:share:qq','menuItem:share:QZone','menuItem:favorite','menuItem:originPage','menuItem:copyUrl','menuItem:openWithSafari','menuItem:openWithQQBrowser'] // 要隐藏的菜单项,只能隐藏“传播类”和“保护类”按钮,所有menu项见附录3
  62. });
  63. },
  64. methods:{
  65. async queryProtocolConfigView(){
  66. let res = await this.$myRequest({
  67. url: "/project/queryProtocolConfigView",
  68. data: {},
  69. })
  70. if(res.data.success){
  71. this.shareRemark = res.data.single.shareRemark||''
  72. }
  73. },
  74. async getShareCard(){
  75. let ret = await this.$myRequest({
  76. url: "/share/shareCard",
  77. data: {
  78. "page": this.page,
  79. "projectId": this.projectId,
  80. "type":this.type
  81. }
  82. })
  83. if (ret.data.success) {
  84. this.shareUrl = ret.data.single;
  85. }
  86. },
  87. async queryProjectByH5(){
  88. let ret = await this.$myRequest({
  89. url: "/project/queryProjectByH5",
  90. data: {
  91. "projectId": this.projectId,
  92. }
  93. })
  94. if (ret.data.success) {
  95. this.shareRemark = ret.data.single.shareRemark||''
  96. }
  97. },
  98. back(){
  99. uni.navigateBack({
  100. delta:1
  101. })
  102. },
  103. copy(){
  104. let textarea = document.createElement("textarea")
  105. textarea.value = this.shareRemark
  106. textarea.readOnly = "readOnly"
  107. document.body.appendChild(textarea)
  108. textarea.select() // 选中文本内容
  109. textarea.setSelectionRange(0, this.shareRemark.length)
  110. let result = document.execCommand("copy")
  111. textarea.remove()
  112. uni.showToast({
  113. icon:"none",
  114. title:"复制成功"
  115. })
  116. }
  117. }
  118. }
  119. </script>
  120. <style lang="scss">
  121. page{
  122. width: 100%;
  123. height: 100%;
  124. background: #4e4e4e;
  125. }
  126. .share_body{
  127. display: flex;
  128. flex-direction: column;
  129. justify-content: center;
  130. align-items: center;
  131. width: 100%;
  132. background: #4e4e4e;
  133. }
  134. .share_card_info{
  135. width: 550rpx;
  136. display: flex;
  137. flex-direction: column;
  138. align-items: center;
  139. background-color: #FFFFFF;
  140. border-radius: 10rpx;
  141. margin-top: 60rpx;
  142. .share_title{
  143. width: 100%;
  144. display: flex;
  145. justify-content: center;
  146. align-items: center;
  147. margin-top: 30rpx;
  148. position: relative;
  149. .title{
  150. width: 292rpx;
  151. height: 34rpx;
  152. }
  153. .close{
  154. width: 24rpx;
  155. height: 24rpx;
  156. position: absolute;
  157. right: 20rpx;
  158. top: 5rpx;
  159. }
  160. }
  161. .share_desc{
  162. width: calc(100% - 60rpx);
  163. font-size: 24rpx;
  164. font-family: Verdana, Verdana-Regular;
  165. font-weight: 400;
  166. text-align: left;
  167. color: #7f7f7f;
  168. margin-top: 22rpx;
  169. box-sizing: border-box;
  170. text-overflow: -o-ellipsis-lastline;
  171. overflow: hidden;
  172. text-overflow: ellipsis;
  173. display: -webkit-box;
  174. -webkit-line-clamp: 2;
  175. line-clamp: 2;
  176. -webkit-box-orient: vertical;
  177. }
  178. .share_copy{
  179. display: flex;
  180. justify-content: center;
  181. align-items: center;
  182. margin-top: 12rpx;
  183. .icon_share_copy{
  184. width: 24rpx !important;
  185. height: 24rpx !important;
  186. }
  187. .share_txt{
  188. font-size: 24rpx;
  189. font-family: Verdana, Verdana-Regular;
  190. font-weight: 400;
  191. text-align: left;
  192. color: #2c2c2c;
  193. margin-left: 6rpx;
  194. }
  195. }
  196. .shareCard{
  197. width: 490rpx;
  198. margin-top: 10rpx;
  199. margin-bottom: 30rpx;
  200. position: relative;
  201. .share_card_loading{
  202. position: absolute;
  203. left: 50%;
  204. top: 50%;
  205. transform: translate(-50%,-50%);
  206. font-size: 24rpx;
  207. font-family: Verdana, Verdana-Regular;
  208. font-weight: 400;
  209. text-align: center;
  210. color: #919191;
  211. }
  212. }
  213. }
  214. .share_copy_txt{
  215. font-size: 28rpx;
  216. font-family: Verdana, Verdana-Regular;
  217. font-weight: 400;
  218. text-align: center;
  219. color: #ffffff;
  220. margin-top: 40rpx;
  221. }
  222. .share_copy_notice{
  223. font-size: 22rpx;
  224. font-family: Verdana, Verdana-Regular;
  225. font-weight: 400;
  226. text-align: center;
  227. color: #919191;
  228. margin-bottom: 40rpx;
  229. }
  230. .loader {
  231. position: relative;
  232. margin: 0 auto;
  233. width: 70rpx;
  234. height: 70rpx;
  235. top: 50%;
  236. transform: translateY(-50%);
  237. &:before {
  238. content: '';
  239. display: block;
  240. padding-top: 100%;
  241. }
  242. }
  243. .circular {
  244. animation: rotate 2s linear infinite;
  245. height: 100%;
  246. transform-origin: center center;
  247. width: 100%;
  248. position: absolute;
  249. top: 0;
  250. bottom: 0;
  251. left: 0;
  252. right: 0;
  253. margin: auto;
  254. }
  255. .path {
  256. stroke-dasharray: 1, 200;
  257. stroke-dashoffset: 0;
  258. animation: dash 1.5s ease-in-out infinite, color 6s ease-in-out infinite;
  259. stroke-linecap: round;
  260. }
  261. @keyframes rotate {
  262. 100% {
  263. transform: rotate(360deg);
  264. }
  265. }
  266. @keyframes dash {
  267. 0% {
  268. stroke-dasharray: 1, 200;
  269. stroke-dashoffset: 0;
  270. }
  271. 50% {
  272. stroke-dasharray: 89, 200;
  273. stroke-dashoffset: -35rpx;
  274. }
  275. 100% {
  276. stroke-dasharray: 89, 200;
  277. stroke-dashoffset: -124rpx;
  278. }
  279. }
  280. @keyframes color {
  281. 100%,
  282. 0% {
  283. stroke: #919191;
  284. }
  285. 40% {
  286. stroke: #919191;
  287. }
  288. 66% {
  289. stroke: #919191;
  290. }
  291. 80%,
  292. 90% {
  293. stroke: #919191;
  294. }
  295. }
  296. </style>