|
楼主 |
发表于 2018-1-7 21:29:40
|
显示全部楼层
江苏省苏州市
$.module("MM.live.activity.packet",function(){function a(){k=$(".act-area .content"),g=k.find("ul"),_=$(".live-wrap"),e(!0),s(),MM.live.socket.addHandle("red_packet",l),MM.live.socket.addHandle("bigWheel",l),MM.live.socket.addHandle("spring_festival2015",l);var a=!0;_.on("click",".packet-act-area>div",function(){a&&(d(),a=!1,setTimeout(function(){a=!0},3e3))}),_.on("click",".packet-act-area-colse",function(){_.find(".packet-act-area").remove()})}function e(a){var e=function(e){var n=e.data;$.isArray(n)||(h=n.count,t(n),v=n.timestamp,MM.live.activity.refreshArea(),a&&MM.live.leftArea.show("act"))};MM.core.getResult({url:f.room,data:{room_id:MM.live.room.getRoomId()},success:e})}function t(a){n(),_.append($.template(w,{data:a})),i(a.timestamp)}function n(a){var e=function(){_.find(".packet-act-area").remove(),MM.live.activity.refreshArea()};a?setTimeout(e,4e3):e()}function i(a){var a=a,e=function(e){clearInterval(y);var t=e.ts-Date.now();y=setInterval(function(){var e=Math.round((Date.now()+t-a)/1e3),n=180-e;_.find(".packet-act-area-time").html(c(n)),0>=n&&(clearInterval(y),_.find(".packet-act-area-time").html(c(n)),_.find(".packet-act-area").remove()),n--},1e3)};MM.core.getResult({url:"public/timestamp",success:e})}function c(a,e){var e=e?e+" : ":"",t=Math.floor(a/60),n=a%60;return 10>n&&(n="0"+n),10>t&&(t="0"+t),e+t+":"+n}function o(a){var e=!1;switch(a=parseInt(a,10)){case 500:case 501:case 502:e=!0}return e}function s(){MM.core.getResult({url:f.info,success:function(a){for(var e=a.data||[],t=0;t<e.length;t++)e[t].sale=!0;MM.live.gift.addCallback(function(){MM.live.gift.add(a.data)})}})}function r(a,e){return 50>e?MM.ui.messager.warn("红包礼物最少要50个哦~"):void MM.core.getResult({url:f.send,requireToken:!0,data:{room_id:MM.live.room.getRoomId(),gift_id:a,count:e},resolveError:function(a){var e="";switch(a.code){case 30516:e="当前直播间还有红包没有领完,请稍等~"}MM.ui.messager.warn(e||a.msg)}})}function d(){return MM.user.isLogin()?MM.user.isAnchor()?MM.ui.messager.warn("主播不能抢红包哦,把机会留给用户吧"):"已关注"!=$(".liveinfo-area-follow").text()?MM.ui.popup.showConfirm("关注提示","关注主播后才可以抢红包哦~",function(){$(".liveinfo-area-follow").click()},null,"关注主播"):void MM.core.getResult({url:f.draw,requireToken:!0,data:{room_id:MM.live.room.getRoomId(),key:md5(MM.live.room.getRoomId()+v+MM.user.getUserId()+M)},success:function(a){MM.ui.messager.success("恭喜您抽到了一个"+a.data.coins+"柠檬红包")},resolveError:function(a){var e="";switch(a.code){case 30512:e="您不能抽自己送的红包哦~";break;case 30513:e="红包已经抽完了,下次手快些~",n(!0);break;case 30518:e="未关注主播"}MM.ui.messager.warn(e||a.msg)}}):MM.user.popupLogin()}function l(a){switch(a.action.module){case"red_packet":u(a);break;case"bigWheel":p(a.data_d);break;case"spring_festival2015":m(a.data_d)}}function u(a){switch(a.action.action){case"notify":e(!0),a.data_d.gift={_id:a.data_d.gift_id,count:a.data_d.count},MM.live.gift.handleSocket(a);break;case"marquee":var t=a.data_d;t.gift={_id:t.gift_id,count:t.count},t.gift=$.extend(t.gift,MM.live.gift.get(t.gift_id));break;case"drawPrize":h=a.data_d.count,_.find(".packet-count").html(h),0===h&&_.find(".packet-act-area").remove(),MM.live.message.show($.template(x,a.data_d))}}function p(a){a.award=b[a.award_name].tip,MM.live.marquee.show(null,$.template(I,a),"/activity/spring-festival.html")}function m(a){MM.live.marquee.show(a.room_id,$.template(R,a))}var f={info:"activity/packet_list",send:"redpacket/send?access_token={access_token}&room_id={room_id}&id={gift_id}&count={count}",draw:"redpacket/drawPrize?access_token={access_token}&room_id={room_id}&s={key}",room:"activity/room_packet?room_id={room_id}"},M="OSSDPGLK234MV/ITFOS23SD@#XA1CQQ&6UQ6",v=null,k=null,g=null,_=null,h=0,w=' <%var data = data;%> <div class="packet-act-area"> <span class="packet-act-area-colse"><i class="iconfont icon-close"></i></span> <div> <div class="packet-act-area-top fix"> <span class="packet-act-area-time">03:00</span> </div> <div class="packet-act-area-msg"> <div><img src="<%= data.from_user.pic %>" alt="<%= data.from_user.nick_name %>"></div> <p>【<span class="packet-act-area-name text-overflow"> <%= data.from_user.nick_name %></span>】的红包</p> <h1><span class="packet-count"><%=data.count%></span> 个</h1> </div> <div> </div> ',y=null,x=' <span>恭喜</span> <span class="mt-nickname"><%=user.nick_name%></span> <span> 玩命抢红包抽中了 </span> <span class="mt-primary"><%=coins%>柠檬</span> ',I=' <span>恭喜</span> <span class="color-yellow"><%=user.nick_name%></span> <span>玩新春大转盘游戏抽中了</span> <span class="color-green"><%=award%></span> ',b={jiehun1:{tip:"结婚套礼1个",index:0},tuoguang1:{tip:"我要脱光1个",index:1},AiHuoShang1:{tip:"爱的火山1个",index:2},hunli1:{tip:"豪华婚礼1个",index:3},lvxing1:{tip:"旅行套礼1个",index:4},zhuguang1:{tip:"烛光晚餐1个",index:5}},R=' <span>恭喜</span> <%=MM.level.createRichIcon(from.finance.coin_spend_total ||0)%> <span class="color-yellow"><%=from.nick_name%></span> <span>送新年礼物获得了全额免单</span> ';return a(),{send:r,isPacket:o,draw:d,handleSocket:l,clear:n,show:e}}); |
|