No Description

index.html 8.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta content="yes" name="apple-mobile-web-app-capable">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0,user-scalable=0" />
  7. <title>分享领红包</title>
  8. <link rel="stylesheet" type="text/css" href="public/public_css.css"/>
  9. <style type="text/css">
  10. body{ min-height:100vh;}
  11. .banner{width: 3.025rem;height: 1.15rem;margin: auto;padding-top: 0.11rem;}
  12. .banner img{width: 100%;}
  13. .red_packet{margin: auto;}
  14. .red_packet .click{font-size:0.18rem;color:#FB3D38;text-align: center;padding-top: 0.2rem;padding-bottom: 0.2rem;}
  15. .red_packet .copy{width:0.94rem;height:0.26rem;margin:auto;color:#FFF;font-size:0.15rem;line-height: 0.26rem;text-align:center;background:#FB3D38;border-radius:0.075rem;box-shadow:0.02rem 0.045rem 0.05rem rgba(143,141,141,0.22);}
  16. .red_packet .con{font-size:0.14rem;color:#666666;padding-top: 0.2rem;padding-bottom: 0.345rem;text-align: center;}
  17. .already{height: 1.8rem;padding-left: 0.16rem;padding-right: 0.15rem;}
  18. .already .num{font-size:0.15rem;color:#FB3D38;padding-bottom: 0.175rem;}
  19. .already ul{}
  20. .already ul li{float: left;padding-bottom: 0.08rem;color: #666666;line-height: 0.355rem;}
  21. .already ul li img{float: left;display: block;width: 0.355rem;height: 0.355rem;border:0;}
  22. .already ul li .username{ display: inline-block; float: left;padding-left: 0.075rem;width: 1.1rem;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;}
  23. .already ul li .ed{padding-right: 0.48rem;}
  24. .already ul li .username,.already ul li .ed{font-size: 0.14rem;}
  25. .already ul li .day,.already ul li .time{font-size: 0.12rem;}
  26. .already ul li .day{padding-right:0.08rem ;}
  27. .cooperation{width:2.54rem;height: 0.46rem;margin: auto;background: url(images/add.png) no-repeat 0.6rem 0.125rem,url(images/add.png) no-repeat 1.65rem 0.125rem; background-size:0.22rem 0.22rem ;}
  28. .cooperation img{float:left;width: 0.46rem;margin-right: 0.57rem;}
  29. .cooperation img:nth-child(3){margin-right: 0rem;}
  30. .bottom{margin: auto;color: #FB3D38;text-align: center;font-size: 0.14rem;}
  31. .bottom p:nth-child(1){padding-top: 0.185rem;padding-bottom: 0.15rem;font-size: 0.15rem;}
  32. #copy_1,#copy_2,#taokouling{position: absolute;left: -1000rem;}
  33. .alert-info {position: absolute;top: 1.74rem;right: 0;left: 0;bottom: 0;text-align: center;}
  34. .alert-info p {display: inline-block;color: #fff;font-size: 0.14rem;line-height: 0.38rem;padding: 0 0.10rem;background-color: rgba(0, 0, 0, 0.7);border-radius: 5px;}
  35. .roll-wrap{height:1.305rem;overflow:hidden;}
  36. </style>
  37. <script type="text/javascript">
  38. document.documentElement.style.fontSize = 100 * (document.documentElement.clientWidth/375) + "px";
  39. window.onresize = function(){
  40. document.documentElement.style.fontSize = 100 * (document.documentElement.clientWidth/375) + "px";
  41. }
  42. </script>
  43. </head>
  44. <body>
  45. <div class="banner">
  46. <img src="images/banner.png"/>
  47. </div>
  48. <div class="red_packet">
  49. <p class="click">点我领红包</p>
  50. <p class="copy" onclick="collarRed()">领取红包</p>
  51. <p class="con">自动生成淘口令,打开手机淘宝领取红包</p>
  52. </div>
  53. <div class="already">
  54. <p class="num"></p>
  55. <div class="roll-wrap" id="roll-wrap">
  56. <ul>
  57. <!--<li><img src="images/001.png" /><span class="username">小豆***</span><span class="ed">领取了红包</span><span class="day">05-30</span><span class="time">14:36</span></li>
  58. <li><img src="images/001.png" /><span class="username">小兰***</span><span class="ed">领取了红包</span><span class="day">05-30</span><span class="time">14:37</span></li>
  59. <li><img src="images/001.png" /><span class="username">小豆紫***</span><span class="ed">领取了红包</span><span class="day">05-30</span><span class="time">15:36</span></li>-->
  60. </ul>
  61. </div>
  62. </div>
  63. <div class="cooperation">
  64. <img src="images/jinniu.png" alt="" />
  65. <img src="images/taobao.png" alt="" />
  66. <img src="images/liedou.png" alt="" />
  67. </div>
  68. <div class="bottom">
  69. <p>联合送礼</p>
  70. <p>下载猎豆优选,大额红包拿到手软</p>
  71. </div>
  72. <input id="copy_1" type="text" readOnly="true" value=""/>
  73. <div id="copy_2"></div>
  74. <text id="taokouling">€WVXSb1pT51S€</text>
  75. <div class="alert-info" style="display: none;">
  76. <!-- tip提示,3s后消失 -->
  77. <p></p>
  78. </div>
  79. </body>
  80. </html>
  81. <script type="text/javascript" src="public/jquery-2.1.0.js"></script>
  82. <script type="text/javascript">
  83. var userId = null;
  84. var str=location.href; //取得整个地址栏
  85. var num=str.indexOf("?");
  86. str=str.substr(num+1); //str得到?之后的字符串
  87. var brr=str.split("&");
  88. for(var i = 0 ; i<brr.length; i++){
  89. if(brr[i].indexOf('userId') != -1){
  90. userId = brr[i].split('=')[1];//用户id
  91. }
  92. }
  93. //页面加载,显示数据
  94. window.onload = function () {
  95. Lead() ;
  96. }
  97. //领红包
  98. function collarRed() {
  99. $.ajax({
  100. type:"post",
  101. url:"/api/V2/receiveRedPacket",
  102. data:{
  103. user_id:userId
  104. },
  105. success: function (res) {
  106. var data =JSON.parse(res)
  107. console.log(data)
  108. if(data.code == 0){
  109. copyPassword();
  110. }else if(data.code == 4003){
  111. showMsg("领取失败")
  112. }else if(data.code == 4002){
  113. // showMsg(data.message)
  114. copyPassword();//不限制新老用户
  115. }
  116. }
  117. })
  118. }
  119. //已领红包
  120. function Lead() {
  121. $.ajax({
  122. type:"post",
  123. url:"/api/V2/returnRedPacket",
  124. success: function (res) {
  125. var data =JSON.parse(res)
  126. // console.log(data)
  127. if(data.code == 0){
  128. var dataArr = data.res.list,html = '',numHtml = '', name = '' , img = '';
  129. numHtml +='已有'+ data.res.count +'位用户领取红包';
  130. dataArr.forEach(function (item, index) {
  131. if(item.user_name){
  132. name = item.user_name;
  133. }else{
  134. name = '匿名';
  135. }
  136. if(item.user_img){
  137. img = item.user_img;
  138. }else{
  139. img = 'images/moren.png'
  140. }
  141. html += '<li><img src='+ img +' /><span class="username">'+ name +'</span><span class="ed">领取了红包</span><span class="day">'+ item.received_time +'</span></li>'
  142. })
  143. $('.num').html(numHtml);
  144. $('.roll-wrap ul').html(html)
  145. }
  146. new scrollTxt().init();
  147. }
  148. })
  149. }
  150. function copyPassword() {
  151. var data=document.getElementById("taokouling").innerHTML;
  152. copy_2.innerHTML = data;
  153. copy_1.value = data;
  154. if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
  155. //区分iPhone设备
  156. window.getSelection().removeAllRanges();//这段代码必须放在前面否则无效
  157. var Url2=document.getElementById("copy_2");//要复制文字的节点
  158. var range = document.createRange();
  159. // 选中需要复制的节点
  160. range.selectNode(Url2);
  161. // 执行选中元素
  162. window.getSelection().addRange(range);
  163. // 执行 copy 操作
  164. var successful = document.execCommand('copy');
  165. // 移除选中的元素
  166. window.getSelection().removeAllRanges();
  167. }else{
  168. var Url2=document.getElementById("copy_1");//要复制文字的节点
  169. Url2.select(); // 选择对象
  170. document.execCommand("Copy"); // 执行浏览器复制命令
  171. }
  172. window.location.href="Invitation.html?userId=" + userId
  173. }
  174. function scrollTxt(){
  175. var controls={},
  176. values={},
  177. t1=800, /*播放动画的时间*/
  178. t2=1500, /*播放时间间隔*/
  179. si;
  180. controls.rollWrap=$("#roll-wrap");
  181. controls.rollWrapUl=controls.rollWrap.children();
  182. controls.rollWrapLIs=controls.rollWrapUl.children();
  183. values.liNums=controls.rollWrapLIs.length;
  184. values.liHeight=45;
  185. values.ulHeight=controls.rollWrap.height();
  186. this.init=function(){
  187. autoPlay();
  188. // pausePlay();
  189. }
  190. /*滚动*/
  191. function play(){
  192. controls.rollWrapUl.animate({"margin-top" : "-"+values.liHeight}, t1, 'linear',function(){
  193. $(this).css("margin-top" , "0").children().eq(0).appendTo($(this));
  194. });
  195. }
  196. /*自动滚动*/
  197. function autoPlay(){
  198. /*如果所有li标签的高度和大于.roll-wrap的高度则滚动*/
  199. if(values.liHeight*values.liNums > values.ulHeight){
  200. si=setInterval(function(){
  201. play();
  202. },t2);
  203. }
  204. }
  205. /*鼠标经过ul时暂停滚动*/
  206. function pausePlay(){
  207. controls.rollWrapUl.on({
  208. "mouseenter":function(){
  209. clearInterval(si);
  210. }
  211. ,
  212. "mouseleave":function(){
  213. autoPlay();
  214. }
  215. });
  216. }
  217. }
  218. /**
  219. * [showMsg 提示各种错误信息,3s后消失]
  220. */
  221. function showMsg(msg) {
  222. var msgBox = $('.alert-info');
  223. msgBox.children('p').text(msg);
  224. msgBox.show();
  225. setTimeout(function() {
  226. msgBox.hide();
  227. }, 3000);
  228. }
  229. </script>