copy_link.html 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>推广链接</title>
  6. <meta name="renderer" content="webkit">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  8. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  9. <link rel="stylesheet" href="../../component/pear/css/pear.css"/>
  10. <link rel="stylesheet" href="../../admin/css/other/console1.css?v=v2.0.3"/>
  11. <style>
  12. .pear-btn-primary {
  13. width: 100%;
  14. margin-top: 10px;
  15. }
  16. .project-list-item .project-list-item-cover {
  17. width: 100%;
  18. display: block;
  19. border-top-left-radius: 4px;
  20. border-top-right-radius: 4px;
  21. }
  22. .layui-text button{
  23. text-align: center;
  24. }
  25. .project-list-item-body {
  26. padding: 10px;
  27. border: 1px solid #e8e8e8;
  28. }
  29. .project-list-item .project-list-item-cover {
  30. height: auto;
  31. }
  32. .project-list-item .project-list-item-text {
  33. text-align: center;
  34. height: 40px;
  35. overflow: hidden;
  36. margin-bottom: 0px;
  37. }
  38. .project-list-item .project-list-item-text button{
  39. width: 40%;
  40. height: 40px;
  41. border-radius: 10px;
  42. }
  43. .show-app{
  44. padding: 20px;
  45. }
  46. </style>
  47. </head>
  48. <body class="pear-container">
  49. <input type="text" id="link" required lay-verify="required" placeholder="" readonly autocomplete="off" class="layui-input">
  50. <textarea hidden id="taCode" rows="8" style="resize: none"></textarea>
  51. <button id="btCopy" type="button" class="pear-btn pear-btn-primary">复制链接</button>
  52. <script src="../../component/layui/layui.js"></script>
  53. <script src="../../component/pear/pear.js"></script>
  54. <script src="../../app/app.js?v=v2.0.3"></script>
  55. <script src="../../config/config.js?v=v2.0.3"></script>
  56. <script src="../../public/config/login.js?v=v2.0.3"></script>
  57. <script>
  58. layui.use(['jquery','layer',], function () {
  59. let $ = layui.jquery;
  60. let layer = layui.layer;
  61. let url = window.location.search;
  62. let link = url.split('?|||')[1];
  63. $('#taCode').text(link);
  64. $('#link').val(link);
  65. // 复制文本内容到剪切板
  66. $("#btCopy").click(function() {
  67. copyText($("#taCode").val());
  68. layer.msg('复制链接成功!快去分享吧!')
  69. });
  70. function copyText(obj) {
  71. if (!obj) {
  72. return false;
  73. }
  74. var text;
  75. if (typeof(obj) == 'object') {
  76. if (obj.nodeType) { // DOM node
  77. obj = $(obj); // to jQuery object
  78. }
  79. try {
  80. text = obj.text();
  81. if (!text) { // Maybe <textarea />
  82. text = obj.val();
  83. }
  84. } catch (err) { // as JSON
  85. text = JSON.stringify(obj);
  86. }
  87. } else {
  88. text = obj;
  89. }
  90. //var $temp = $('<input>'); // Line feed is not supported
  91. var $temp = $('<textarea>');
  92. $('body').append($temp);
  93. $temp.val(text).select();
  94. var res = document.execCommand('copy');
  95. $temp.remove();
  96. return res;
  97. }
  98. });
  99. </script>
  100. </body>
  101. </html>