123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- //var userId = null;
- //var str=location.href; //取得整个地址栏
- //var num=str.indexOf("?");
- //str=str.substr(num+1); //str得到?之后的字符串
- //var brr=str.split("&");
- //for(var i = 0 ; i<brr.length; i++){
- // if(brr[i].indexOf('userId') != -1){
- // userId = brr[i].split('=')[1];//用户id
- // }
- //}
- //页面加载,显示数据
- window.onload = function () {
- Lead() ;
- }
- //领红包
- function collarRed() {
- $("#index").css("display","none");
- $("#invitation").css("display","block")
- // $.ajax({
- // type:"post",
- // url:"/api/V2/receiveRedPacket",
- // data:{
- // user_id:userId
- // },
- // success: function (res) {
- // var data =JSON.parse(res)
- // console.log(data)
- // if(data.code == 0){
- // copyPassword();
- // }else if(data.code == 4003){
- // showMsg("领取失败")
- // }else if(data.code == 4002){
- //// showMsg(data.message)
- // copyPassword();//不限制新老用户
- // }
- // }
- // })
- }
- //已领红包
- function Lead() {
- $.ajax({
- type:"post",
- url:"/api/V2/returnRedPacket",
- success: function (res) {
- var data =JSON.parse(res)
- // console.log(data)
- if(data.code == 0){
- var dataArr = data.res.list,html = '',numHtml = '', name = '' , img = '';
- numHtml +='已有'+ data.res.count +'位用户领取红包';
- dataArr.forEach(function (item, index) {
- if(item.user_name){
- name = item.user_name;
- }else{
- name = '匿名';
- }
- if(item.user_img){
- img = item.user_img;
- }else{
- img = 'images/moren.png'
- }
- html += '<li><img src='+ img +' /><span class="username">'+ name +'</span><span class="ed">领取了红包</span><span class="day">'+ item.received_time +'</span></li>'
- })
- $('.num').html(numHtml);
- $('.roll-wrap ul').html(html)
- }
- new scrollTxt().init();
- }
- })
- }
- function scrollTxt(){
- var controls={},
- values={},
- t1=800, /*播放动画的时间*/
- t2=1500, /*播放时间间隔*/
- si;
- controls.rollWrap=$("#roll-wrap");
- controls.rollWrapUl=controls.rollWrap.children();
- controls.rollWrapLIs=controls.rollWrapUl.children();
- values.liNums=controls.rollWrapLIs.length;
- values.liHeight=45;
- values.ulHeight=controls.rollWrap.height();
- this.init=function(){
- autoPlay();
- // pausePlay();
- }
- /*滚动*/
- function play(){
- controls.rollWrapUl.animate({"margin-top" : "-"+values.liHeight}, t1, 'linear',function(){
- $(this).css("margin-top" , "0").children().eq(0).appendTo($(this));
- });
- }
- /*自动滚动*/
- function autoPlay(){
- /*如果所有li标签的高度和大于.roll-wrap的高度则滚动*/
- if(values.liHeight*values.liNums > values.ulHeight){
- si=setInterval(function(){
- play();
- },t2);
- }
- }
- /*鼠标经过ul时暂停滚动*/
- function pausePlay(){
- controls.rollWrapUl.on({
- "mouseenter":function(){
- clearInterval(si);
- }
- ,
- "mouseleave":function(){
- autoPlay();
- }
- });
- }
- }
- /**
- * [showMsg 提示各种错误信息,3s后消失]
- */
- function showMsg(msg) {
- var msgBox = $('.alert-info');
- msgBox.children('p').text(msg);
- msgBox.show();
- setTimeout(function() {
- msgBox.hide();
- }, 3000);
- }
|