优惠券分享

index.html 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <title>猎豆优选</title>
  5. <meta name="viewport" content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
  6. <meta name="format-detection" content="telephone=no,address=no,email=no" />
  7. <meta name="mobileOptimized" content="width" />
  8. <meta name="handheldFriendly" content="true" />
  9. <meta name="apple-mobile-web-app-capable" content="yes" />
  10. <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  11. <meta name="description" content="" />
  12. <meta name="keywords" content=""/>
  13. <script>
  14. ;(function() {
  15. var docEl = document.documentElement,
  16. resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
  17. clientWidth = docEl.clientWidth;
  18. s();
  19. window.addEventListener(resizeEvt, s, false);
  20. function s() {
  21. docEl.style.fontSize = 50.0 * (clientWidth / 375) + 'px';
  22. }
  23. })();
  24. </script>
  25. <script>
  26. var _ua = navigator.userAgent;
  27. if (!!_ua.match(/.*OS\s([\d_]+)/) || !!_ua.match(/(Android)\s+([\d.]+)/)) {
  28. document.write('<style>body{min-width:320px;min-height:320px;}</style>');
  29. }
  30. </script>
  31. <style type="text/css" media="screen">
  32. html,
  33. body,
  34. div,
  35. h3, h4, h5, h6, p,
  36. span, em, i,
  37. ::before,
  38. ::after{
  39. padding: 0;
  40. margin: 0;
  41. -webkit-box-sizing: border-box;
  42. box-sizing: border-box;
  43. -webkit-tap-highlight-color: transparent;
  44. }
  45. ol, ul{
  46. list-style: none;
  47. padding: 0;
  48. margin: 0;
  49. }
  50. body{
  51. font-size: 14px;
  52. color: #333;
  53. }
  54. em, i{
  55. font-style: normal;
  56. }
  57. a{
  58. text-decoration: none;
  59. }
  60. .clearfix::before,
  61. .clearfix::after{
  62. content: "";
  63. display: block;
  64. height: 0;
  65. line-height: 0;
  66. visibility: hidden;
  67. clear: both;
  68. }
  69. .elli{
  70. display: box;
  71. overflow: hidden;
  72. text-overflow: ellipsis;
  73. display: -webkit-box;
  74. -webkit-line-clamp: 2;
  75. -webkit-box-orient: vertical;
  76. }
  77. .copy_1{
  78. outline: none;
  79. border: 0px;
  80. color: rgba(0,0,0,0.0);
  81. position: absolute;
  82. left:-200px;
  83. background-color: transparent;
  84. }
  85. .copy_2{
  86. position: absolute;
  87. left:-200px;
  88. color: rgba(0,0,0,0);
  89. background-color: transparent
  90. }
  91. .wrapper{}
  92. .wrapper .activity_list{
  93. }
  94. .wrapper .list-item{
  95. display: flex;
  96. display: -webkit-flex;
  97. flex-direction: column;
  98. justify-content: center;
  99. /*align-items: center;*/
  100. margin: 0 12px;
  101. padding-top: 20px;
  102. border-bottom: #D8D8D8 solid 1px;
  103. }
  104. .wrapper .list-item .title{
  105. font-size: 15px;
  106. line-height: 22px;
  107. color: #333333;
  108. font-weight: 500;
  109. }
  110. .wrapper .list-item .desc{
  111. font-size: 12px;
  112. color: #999999;
  113. line-height: 16px;
  114. margin: 8px 0 15px;
  115. }
  116. .wrapper .list-item .img-box{
  117. width: 7.02rem;
  118. height: 2.87rem;
  119. overflow: hidden;
  120. }
  121. .wrapper .list-item .img-box img{
  122. width: 100%;
  123. }
  124. .wrapper .list-item .bottom-content{
  125. display: flex;
  126. height: 28px;
  127. justify-content: space-between;
  128. align-items: center;
  129. margin: 12px 0;
  130. }
  131. .wrapper .list-item .bottom-content .rate{
  132. font-size: 20px;
  133. color: #262626;
  134. line-height: 28px;
  135. }
  136. .wrapper .list-item .bottom-content .right span{
  137. border: #FF6000 solid 1px;
  138. color: #FF6000;
  139. line-height: 20px;
  140. font-size: 12px;
  141. padding: 0 10px;
  142. border-radius: 10px;
  143. }
  144. .weui-mask_transparent {
  145. position: fixed;
  146. z-index: 1000;
  147. top: 0;
  148. right: 0;
  149. left: 0;
  150. bottom: 0;
  151. }
  152. .weui-toast {
  153. position: fixed;
  154. z-index: 5000;
  155. width: 7.6em;
  156. min-height: 7.6em;
  157. top: 180px;
  158. left: 50%;
  159. margin-left: -3.8em;
  160. background: rgba(17, 17, 17, 0.7);
  161. text-align: center;
  162. border-radius: 5px;
  163. color: #FFFFFF;
  164. }
  165. .hide{
  166. display: none;
  167. opacity: 0;
  168. }
  169. .show{
  170. display: block;
  171. opacity: 1;
  172. }
  173. .weui-icon-success-no-circle {
  174. display: inline-block;
  175. vertical-align: middle;
  176. margin: 22px 0 0;
  177. width: 39px;
  178. height: 30px;
  179. background: url(getIt.png) no-repeat 0 0;
  180. -webkit-background-size: 39px 30px;
  181. background-size: 39px 30px;
  182. }
  183. .weui-toast__content {
  184. margin: 6px 0 15px;
  185. }
  186. </style>
  187. </head>
  188. <body>
  189. <div class="wrapper">
  190. <ul class="activity_list">
  191. <li class="list-item">
  192. <!-- <h5 class="title">2018天猫618理想生活狂欢季,趁热预售开抢!</h5> <p class="desc">有效期:2018-05-23至2018-05-31</p> <div class="img-box"><img src="" alt=""></div> <div class="bottom-content"> <div class="left">预估收入比率 <span class="rate">20%</span></div> <div class="right"> <input class="copy_1" type="text" readOnly="true" value=""/> <div class="copy_2"></div> <span>复制淘口令,进入淘宝</span> </div> </div> -->
  193. </li>
  194. </ul>
  195. </div>
  196. <div id="toast" class="hide">
  197. <div class="weui-mask_transparent"></div>
  198. <div class="weui-toast">
  199. <i class="weui-icon-success-no-circle"></i>
  200. <p class="weui-toast__content">已完成</p>
  201. </div>
  202. </div>
  203. <script src="axios.min.js" type="text/javascript" charset="utf-8"></script>
  204. <script type="text/javascript" charset="utf-8">
  205. window.onload = function () {
  206. var copy_2 = document.querySelector("copy_2"),
  207. copy_1 = document.querySelector("copy_1"),
  208. toast = document.getElementById("toast"),
  209. btn = [],
  210. listWrapper = document.querySelector('.wrapper .activity_list');
  211. axios.get('/api/v2/adv/advActivityMini', {
  212. activity_id: 1
  213. })
  214. .then(function (response) {
  215. var res = response.data, data = null, html = '';
  216. if (res.errno == 0) {
  217. data = res.rst.data;
  218. if (data.length > 0) {
  219. for (var i = 0; i < data.length; i++) {
  220. html += '<li class="list-item"><h5 class="title">'+ data[i].title +'</h5><p class="desc">有效期:'+ data[i].start_time +'至'+ data[i].end_time +'</p><div class="img-box"><img src="'+ data[i].img +'" alt=""></div><div class="bottom-content"><div class="left">淘口令 '+ data[i].command +'</div> <div class="right"><input class="copy_1" type="text" readOnly="true" value="'+ data[i].command +'"/><div class="copy_2">'+ data[i].command +'</div><span class="btn-copy">复制淘口令,进入淘宝</span></div></div></li>';
  221. }
  222. }
  223. listWrapper.innerHTML = html;
  224. btn = document.querySelectorAll('.wrapper .list-item .btn-copy');
  225. for (var j = 0; j < btn.length; j++) {
  226. btn[j].addEventListener('click', function () {
  227. // console.log(this);
  228. var copy_1 = this.previousElementSibling,
  229. copy_2 = this.previousElementSibling.previousElementSibling;
  230. // console.log(copy_1, copy_2);
  231. toast.classList.add('show');
  232. // toCopy();
  233. if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
  234. //区分iPhone设备
  235. window.getSelection().removeAllRanges();//这段代码必须放在前面否则无效
  236. // var Url2=document.getElementById("copy_2");//要复制文字的节点
  237. var range = document.createRange();
  238. // 选中需要复制的节点
  239. range.selectNode(copy_2);
  240. // 执行选中元素
  241. window.getSelection().addRange(range);
  242. // 执行 copy 操作
  243. var successful = document.execCommand('copy');
  244. window.getSelection().removeAllRanges();
  245. }else{
  246. copy_1.select(); // 选择对象
  247. document.execCommand("Copy"); // 执行浏览器复制命令
  248. }
  249. setTimeout(function () {
  250. toast.classList.remove('show');
  251. toast.classList.add('hide')
  252. }, 2000)
  253. }, false)
  254. }
  255. // console.log(data);
  256. // console.log(btn);
  257. }
  258. })
  259. .catch(function (error) {
  260. console.log(error);
  261. });
  262. };
  263. function toCopy() {
  264. if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
  265. //区分iPhone设备
  266. window.getSelection().removeAllRanges();//这段代码必须放在前面否则无效
  267. var Url2=document.getElementById("copy_2");//要复制文字的节点
  268. var range = document.createRange();
  269. // 选中需要复制的节点
  270. range.selectNode(Url2);
  271. // 执行选中元素
  272. window.getSelection().addRange(range);
  273. // 执行 copy 操作
  274. var successful = document.execCommand('copy');
  275. // 移除选中的元素
  276. window.getSelection().removeAllRanges();
  277. }else{
  278. var Url2=document.getElementById("copy_1");//要复制文字的节点
  279. Url2.select(); // 选择对象
  280. document.execCommand("Copy"); // 执行浏览器复制命令
  281. }
  282. }
  283. </script>
  284. </body>
  285. </html>