优惠券分享

index.html 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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: 2px 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. function getURLCode() {
  206. var search = location.search.length > 0 ? location.search.substring(1) : '',
  207. args = {},
  208. items = search.length ? search.split('&') : [],
  209. item = null,
  210. name = null,
  211. value = null,
  212. i = 0,
  213. len = items.length,
  214. data = '';
  215. for (i = 0; i < len; i++) {
  216. item = items[i].split('=');
  217. name = decodeURIComponent(item[0]);
  218. value = decodeURIComponent(item[1]);
  219. if (item.length) {args[name] = value }
  220. }
  221. return args;
  222. }
  223. window.onload = function () {
  224. var device_type = getURLCode()['device_type'] || 1;
  225. var copy_2 = document.querySelector("copy_2"),
  226. copy_1 = document.querySelector("copy_1"),
  227. toast = document.getElementById("toast"),
  228. btn = [],
  229. listWrapper = document.querySelector('.wrapper .activity_list');
  230. var titleName = '淘口令';
  231. var clickName = '复制淘口令,进入淘宝';
  232. axios.get('/api/v2/adv/advActivity?activity_id=1&device_type=' + device_type)
  233. .then(function (response) {
  234. var res = response.data, data = null, html = '';
  235. if (res.errno == 0) {
  236. data = res.rst.data;
  237. if (data.length > 0) {
  238. for (var i = 0; i < data.length; i++) {
  239. if(data[i].command_type == 1){
  240. titleName='淘口令';
  241. clickName='复制淘口令,进入淘宝'
  242. }else if (data[i].command_type == 2){
  243. titleName = '搜索码';
  244. clickName = '复制搜索码,进入支付宝';
  245. }
  246. 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">' + titleName + ': '+ 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">' + clickName + '</span></div></div></li>';
  247. }
  248. }
  249. listWrapper.innerHTML = html;
  250. btn = document.querySelectorAll('.wrapper .list-item .btn-copy');
  251. for (var j = 0; j < btn.length; j++) {
  252. btn[j].addEventListener('click', function () {
  253. // console.log(this);
  254. var copy_1 = this.previousElementSibling,
  255. copy_2 = this.previousElementSibling.previousElementSibling;
  256. // console.log(copy_1, copy_2);
  257. toast.classList.add('show');
  258. // toCopy();
  259. if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
  260. //区分iPhone设备
  261. window.getSelection().removeAllRanges();//这段代码必须放在前面否则无效
  262. // var Url2=document.getElementById("copy_2");//要复制文字的节点
  263. var range = document.createRange();
  264. // 选中需要复制的节点
  265. range.selectNode(copy_2);
  266. // 执行选中元素
  267. window.getSelection().addRange(range);
  268. // 执行 copy 操作
  269. var successful = document.execCommand('copy');
  270. window.getSelection().removeAllRanges();
  271. }else{
  272. copy_1.select(); // 选择对象
  273. document.execCommand("Copy"); // 执行浏览器复制命令
  274. }
  275. setTimeout(function () {
  276. toast.classList.remove('show');
  277. toast.classList.add('hide')
  278. }, 2000)
  279. }, false)
  280. }
  281. // console.log(data);
  282. // console.log(btn);
  283. }
  284. })
  285. .catch(function (error) {
  286. console.log(error);
  287. });
  288. };
  289. function toCopy() {
  290. if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
  291. //区分iPhone设备
  292. window.getSelection().removeAllRanges();//这段代码必须放在前面否则无效
  293. var Url2=document.getElementById("copy_2");//要复制文字的节点
  294. var range = document.createRange();
  295. // 选中需要复制的节点
  296. range.selectNode(Url2);
  297. // 执行选中元素
  298. window.getSelection().addRange(range);
  299. // 执行 copy 操作
  300. var successful = document.execCommand('copy');
  301. // 移除选中的元素
  302. window.getSelection().removeAllRanges();
  303. }else{
  304. var Url2=document.getElementById("copy_1");//要复制文字的节点
  305. Url2.select(); // 选择对象
  306. document.execCommand("Copy"); // 执行浏览器复制命令
  307. }
  308. }
  309. </script>
  310. </body>
  311. </html>