123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969 |
- $(function() {
- // 禁止微信字体修改
- (function () {
- if (typeof WeixinJSBridge == "object" && typeof WeixinJSBridge.invoke == "function") {
- handleFontSize();
- } else {
- if (document.addEventListener) {
- document.addEventListener("WeixinJSBridgeReady", handleFontSize, false);
- } else if (document.attachEvent) {
- document.attachEvent("WeixinJSBridgeReady", handleFontSize);
- document.attachEvent("onWeixinJSBridgeReady", handleFontSize);
- }
- }
- function handleFontSize() {
- // 设置网页字体为默认大小
- WeixinJSBridge.invoke('setFontSizeCallback', {
- 'fontSize': 0
- });
- // 重写设置网页字体大小的事件
- WeixinJSBridge.on('menu:setfont', function () {
- WeixinJSBridge.invoke('setFontSizeCallback', {
- 'fontSize': 0
- })
- });
- }
- })();
- var dev = false; // 测试数据开关
- var $cards = $(".box li"), //所有卡牌
- $maskCard = $("#mask-card"), //翻牌遮罩
- length = $cards.length,
- index = length, //轮流滚动的卡牌下标
- data = 9999, //次数
- rem = 72,
- initArr = [
- [80 / rem, 0],
- [280 / rem, 0],
- [480 / rem, 0],
- [80 / rem, 300 / rem],
- [280 / rem, 300 / rem],
- [480 / rem, 300 / rem]
- ], //卡牌位置数组
- clickTime = 0,
- bool = false, //首次点击时不能在卡牌归位期间
- timer, //轮流提示定时器
- nowTab = 0;
- var isFirst = true;
- $("#change").html(data);
- var timer_a = null;
- var list_data = { // Tab 中奖名单nameList,我的奖品recordList
- 'nameList': '',
- 'recordList': ''
- };
- var srandom = Math.random();
- var _data = '';
- //url参数
- var actId = GetQueryString('actId') || '';
- var url = GetQueryString('json'),
- opub,
- opri,
- drawtime = null,
- drawopen = true,
- getdrawdata,
- tiptime = null;
- var isiOS = false;
- // 判断是否在url拿到json参数
- if (url) {
- url = JSON.parse(url);
- if (url['pub']) {
- opub = url['pub'];
- if (!opub.p) {
- opub.p = 0;
- // wifilogdp([602,'json_pub_p_null']);
- }
- // 通过参数确认是否是ios
- try {
- if (opub.appCode == 'i001') {
- isiOS = true;
- }
- } catch (e) {
- console.log(e);
- }
- } else {
- console.log('没有拿到pub参数');
- // wifilogdp([602,'json_pub_null']);
- }
- if (url['pri']) {
- opri = url['pri'];
- if (!opri.uId) {
- opri = {
- 'uId': 0
- };
- // wifilogdp([602,'json_pri_uId_null']);
- }
- } else {
- opri = {
- 'uId': 0
- };
- console.log('没有拿到pri参数');
- // wifilogdp([602,'json_pri_null']);
- }
- } else {
- console.log('没有拿到json参数');
- // wifilogdp([602,'json_null']);
- }
- if (dev) {
- _data = {
- "data": {
- "userAwardList": [{
- "awardName": "再来一次",
- "type": 6,
- "bookId": null
- },
- {
- "awardName": "100成长值",
- "type": 4,
- "bookId": null
- },
- {
- "awardName": "100成长值",
- "type": 4,
- "bookId": null
- },
- {
- "awardName": "再来一次",
- "type": 6,
- "bookId": null
- },
- {
- "awardName": "10元话费",
- "type": 2,
- "bookId": null
- },
- {
- "awardName": "10元话费",
- "type": 2,
- "bookId": null
- },
- {
- "awardName": "再来一次",
- "type": 6,
- "bookId": null
- },
- {
- "awardName": "100成长值",
- "type": 4,
- "bookId": null
- },
- {
- "awardName": "再来一次",
- "type": 6,
- "bookId": null
- },
- {
- "awardName": "100成长值",
- "type": 4,
- "bookId": null
- }
- ],
- "drawNum": 175,
- "endTime": 287798618,
- "awardList": [{
- "id": 77,
- "name": "68元小说",
- "type": 5,
- "img": "http://ods51247g.bkt.clouddn.com/pubres/usercenter/watchaward/prize2.png"
- },
- {
- "id": 78,
- "name": "58看点",
- "type": 1,
- "img": "http://ods51247g.bkt.clouddn.com/pubres/usercenter/watchaward/prize5.png"
- },
- {
- "id": 79,
- "name": "kindle",
- "type": 3,
- "img": "http://ods51247g.bkt.clouddn.com/pubres/usercenter/watchaward/prize1.jpg"
- },
- {
- "id": 81,
- "name": "100成长值",
- "type": 4,
- "img": "http://ods51247g.bkt.clouddn.com/pubres/usercenter/watchaward/grow.png"
- },
- {
- "id": 82,
- "name": "10元话费",
- "type": 2,
- "img": "http://ods51247g.bkt.clouddn.com/pubres/usercenter/watchaward/huafei.jpg"
- },
- {
- "id": 83,
- "name": "100看点",
- "type": 1,
- "img": "http://ods51247g.bkt.clouddn.com/pubres/usercenter/watchaward/prize4.png"
- }
- ]
- },
- "code": 1,
- "msg": "获取列表成功"
- }
- // data结束
- // renderData(_data);
- init();
- var _nameList = [{
- 'id': '123****8282',
- 'type': 1,
- 'name': '《斗魂1大陆》'
- }, {
- 'id': '123****8282',
- 'type': 1,
- 'name': '《斗魂2大陆》'
- }, {
- 'id': '123****8282',
- 'type': 1,
- 'name': '《斗魂3大陆》'
- }, {
- 'id': '123****8282',
- 'type': 1,
- 'name': '《斗魂4大陆》'
- }, {
- 'id': '123****8282',
- 'type': 1,
- 'name': '《斗魂5大陆》'
- }, {
- 'id': '123****8282',
- 'type': 1,
- 'name': '《斗魂6大陆》'
- }, {
- 'id': '123****8282',
- 'type': 1,
- 'name': '《斗魂7大陆》'
- }, {
- 'id': '123****8282',
- 'type': 1,
- 'name': '《斗魂8大陆》'
- }, {
- 'id': '123****8282',
- 'type': 1,
- 'name': '《斗魂9大陆》'
- }, {
- 'id': '123****8282',
- 'type': 1,
- 'name': '《斗魂0大陆》'
- }];
- var _recordList = [{
- 'type': 1,
- 'name': '《斗魂1大陆》',
- 'url': '#1111##'
- }, {
- 'type': 2,
- 'name': '12天VIP会员',
- 'url': '##2222##'
- }, {
- 'type': 3,
- 'name': '100 代金券',
- 'url': ''
- }, {
- 'type': 4,
- 'name': '华为 Nova 7s',
- 'url': '##333##'
- }];
- list_data.nameList = _nameList;
- list_data.recordList = _recordList;
- renderLi();
- } else {
- // 非测试数据时运行
- if (!opub || opub.p < 24) {
- // tipbox('您当前版本太低<br/>请升级到最新版本参与该活动');
- // wifilogdp([602,'opub_'+ (!opub ? 'null' : 'p_' + opub.p)]);
- // return false;
- fnGetPrizeList();
- } else {
- fnGetPrizeList();
- }
- }
- // ios:i001
- // 游戏开始
- // 获取基本信息
- function fnGetPrizeList() {
- $.ajax({
- url: '/api/card/getAwardList',
- type: 'post',
- timeout: 5000,
- // dataType: 'json',
- // contentType: 'application/json',
- data: {
- actId: actId,
- },
- success: function(data) {
- var odata = data.data;
- switch (data.code) {
- case 1:
- // 存储 Banner图和规则
- var storage = window.localStorage;
- storage.fanpaiRule = odata.rule;
- storage.fanpaiImg = odata.img;
- // 渲染图片及消耗看点数量
- // $('.bannerImg').attr('src', odata.img);
- $('.consume_num').html(odata.playAmount);
- var bgColorM = odata.mainColor || '';
- if (bgColorM) {
- $('html,body,#wrap').css('background-color', bgColorM);
- $('.banner .after').css({
- 'background': '-moz-linear-gradient(top, rgba(255,255,255,0) 0%, ' + bgColorM + ' 100%)',
- 'background': '-webkit-linear-gradient(top, rgba(255,255,255,0) 0%,' + bgColorM + ' 100%)',
- 'background': 'linear-gradient(to bottom, rgba(255,255,255,0) 0%,' + bgColorM + ' 100%)'
- })
- }
- renderData(odata); // 渲染奖品展示图和名称
- init(); // 初始化动画效果
- // 改变数据中奖广播
- list_data.nameList = []; // 清空数组
- list_data.nameList = odata.win_list;
- // 改变数据中奖记录
- list_data.recordList = []; // 清空数组
- list_data.recordList = odata.record_award;
- // 渲染Tab 改变数据/中奖记录
- renderLi();
- break;
- default:
- // $('.bannerImg').attr('src', odata.img);
- break;
- }
- },
- error: function() {
- $('#dialog-no').show();
- /*jshint multistr: true */
- $('#dialog-no .win_show').html('<div class="div2">活动过于火爆,请稍候再试</div>\
- <div class="btns">\
- <a href="javascript:;" class="redlongbtn closebtn">朕知道了</a>\
- </div>');
- }
- });
- }
- //获取地址栏参数
- function GetQueryString(name) {
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
- var r = window.location.search.substr(1).match(reg);
- if (r != null) {
- return unescape(r[2]);
- }
- return '';
- }
- //json 字符串 对象 互转 objstr必须是对象或者是对象格式的字符串
- function jsonStr(objStr) {
- if (!objStr) {
- return objStr;
- }
- if (typeof objStr == 'object') {
- return JSON.stringify(objStr);
- } else if (typeof objStr == 'string') {
- return JSON.parse(objStr);
- } else {
- //console.log('objStr:"是一个'+typeof objStr+'"类型 既不是对象也不是对象格式的字符串')
- return objStr;
- }
- }
- // 随机打乱数组
- // function shuffle(arr) {
- // var arr = arr || [];
- // var i = arr.length;
- // while (i) {
- // var j = Math.floor(Math.random() * i--);
- // [arr[j], arr[i]] = [arr[i], arr[j]];
- // }
- // return arr;
- // }
- //url地址多问号修复
- function sHrefReplace(url) {
- var reg = /\s+/g;
- var reg_2 = /\?/g;
- var reg_amp = /amp;/g;
- url = decodeURIComponent(url);
- url = url.replace(reg, '');
- url = url.replace(reg_amp, '');
- url = url.replace(reg_2, '&');
- url = url.replace(/&{2,}/g, '&');
- url = url.replace(/&/, '?');
- return url;
- }
- // tipbox弹层
- function tipbox(str, ms, jump) {
- clearTimeout(tiptime);
- $('.tip_box span').html(str);
- $('.tip_box').show();
- if (ms) {
- tiptime = setTimeout(function() {
- $('.tip_box').hide();
- $('.tip_box span').html('');
- if (jump) {
- // wifilogdp([602,'tip_top_up']);
- // window.location.href="/top_up.html";
- }
- }, ms);
- }
- }
- // 插入 toast
- var toast = function(params) {
- var toastId = document.getElementById("toast");
- if (toastId) {
- toastId.parentNode.removeChild(toastId); // 删除原有的toast
- }
- var el = document.createElement("div");
- el.setAttribute("id", "toast");
- el.innerHTML = params.message;
- document.body.appendChild(el);
- el.classList.add("fadeIn");
- setTimeout(function() {
- el.classList.remove("fadeIn");
- el.classList.add("fadeOut");
- el.addEventListener("animationend", function() {
- el.classList.add("hide");
- });
- }, params.time);
- };
- // 渲染奖品展示图和名称
- function renderData(data) {
- var ndataArr = data.award_list; //随机打乱数组
- console.log(ndataArr);
- var $cards = $(".box li"); //所有卡牌
- for (var i = 0; i < ndataArr.length; i++) {
- var _img = '<img src="' + ndataArr[i].image + '" />';
- var _prizeName = '<p>' + ndataArr[i].show_name + '</p>';
- $cards.eq(i).html(_img + _prizeName);
- }
- }
- // 初始化动画
- function init() {
- bool = false;
- var initTime = 2; // CSS动画时间 0.5秒+0.5秒
- if (isFirst) { // 第一次翻转图片
- isFirst = false;
- var timer_showCard = setInterval(function() {
- $cards.addClass('hide-card');
- removeImg(); // 0.5秒后删除图片
- clearInterval(timer_showCard);
- }, initTime * 1000);
- // 删除图片 1/2 .hide-card 的时间 = 0.5s
- function removeImg() {
- var timer_removeImg = setInterval(function() {
- $cards.addClass('hide-data');
- $cards.find('img').remove();
- $cards.find('p').remove();
- clearInterval(timer_removeImg);
- }, 500);
- }
- } else {
- initTime = 0;
- }
- // 卡牌右下角发牌
- var timer_moveCard = setInterval(function() {
- $cards.css({ //所有卡牌放到右下角
- left: 512 / rem + "rem",
- top: 268 / rem + "rem"
- });
- $cards.removeClass('hide-card');
- clearInterval(timer_moveCard);
- // 0.5秒后发牌
- var timer_cardInit = setInterval(function() {
- cardInit();
- clearInterval(timer_cardInit);
- }, 500);
- //
- }, (initTime + 1) * 1000);
- function cardInit() {
- //卡牌归位动画
- for (var i = 0; i < length; i++) {
- (function(i) {
- var seat = setTimeout(function() {
- $cards.eq(i).css({
- left: initArr[i][0] + "rem",
- top: initArr[i][1] + "rem"
- });
- clearTimeout(seat);
- }, 300 * i);
- })(i);
- }
- // 定时选中卡牌 0为顺序选择 1为随机选择
- // cardActive(1);
- bool = true; //卡牌归位,可以点击
- }
- //生成从minNum到maxNum的随机数
- function randomNum(minNum, maxNum) {
- switch (arguments.length) {
- case 1:
- return parseInt(Math.random() * minNum + 1, 10);
- break;
- case 2:
- return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10);
- break;
- default:
- return 0;
- break;
- }
- }
- //卡牌轮流选中动画 1为随机 0为顺序
- function cardActive(isRandomNum) {
- if (isRandomNum || 1) {
- setTimeout(function() {
- timer = setInterval(function() {
- bool = true; //卡牌归位,可以点击
- $cards.removeClass("active");
- $cards.eq(randomNum(0, index)).addClass("active");
- }, 1000);
- }, 1000);
- } else {
- setTimeout(function() {
- timer = setInterval(function() {
- bool = true; //卡牌归位,可以点击
- $cards.eq(index - 1).removeClass("active");
- index %= 6;
- $cards.eq(index).addClass("active");
- index++;
- }, 1000);
- }, 1000);
- }
- }
- }
- //点击卡牌
- $(".box").on("click", "li", function() {
- if (new Date() - clickTime > 2000 && bool) { //两次点击的间隔不能小于2秒
- clickTime = new Date(); //时间更新
- if (data > 0) {
- var speed = 200; //滑动的速度
- // $('body,html').animate({ scrollTop: 0 }, speed); // 点击的时候回到顶部
- //return false;
- fnLottery($(this));
- } else {
- alert("没有次数了~");
- }
- }
- // window.bookSotre.logClick('fanpai_index', 'dianjikapai', '', '', '');
- });
- // 模拟开奖结果------------------------
- function initFnLottery(_liThis) {
- // $('.dialog_prize_img').attr('src', data.data.img);
- // $('.wintxt').html(_wintxt);
- // $('.red-body h1').html(_h1txt);
- $maskCard.show();
- clearInterval(timer); //清除轮流选中动画
- $cards.removeClass("active"); //清除轮流滚动类名
- _liThis.addClass("open-card"); //添加翻牌动画
- //动画监听
- _liThis.on("animationend", () => {
- _liThis.removeClass("open-card"); //移除翻牌动画
- $cards.css({ //所有卡牌放到右下角
- left: 280 / rem + "rem",
- top: 168 / rem + "rem"
- });
- $maskCard.hide();
- win(_liThis);
- _liThis.off("animationend"); //解绑动画监听
- });
- }
- //中奖信息提示
- // $("#close,.win,.btn").click(function () {
- // clickTime = new Date();//时间更新
- // index = length;//卡牌选中重新从第一张开始
- // init();
- // });
- // 渲染Tab 中奖名单和我的奖品
- function renderLi(dataType) {
- console.log(list_data);
- var _dataType = dataType || '';
- var _html = '';
- // 中奖广播
- if (_dataType == 'tab1' || _dataType == '') {
- var _item = list_data.nameList;
- $('.tab_nav li').removeClass('cur');
- $('.tab_nav li').eq(0).addClass('cur');
- if (_item.length == 0) {
- $('.tab_list').html('');
- // $('.emtpy').show();
- // return; -------------------
- } else {
- $('.empty').hide();
- $('.name-list').show();
- for (var i = 0; i < _item.length; i++) {
- if (i == 10) {
- break;
- }
- _html += '<li>恭喜<span class="pl1">' + _item[i].id + '</span><span class="pl1">抽中《' + _item[i].name + '》奖品</span></li>';
- }
- }
- }
- // 中奖记录
- if (_dataType == 'tab2') {
- var _jtem = list_data.recordList;
- console.log(_jtem);
- $('.tab_nav li').removeClass('cur');
- $('.tab_nav li').eq(1).addClass('cur');
- if (_jtem.length == 0) {
- $('.tab_list').html('');
- $('.empty').show();
- $('.name-list').hide();
- $('.empty').html('你没有奖品赶快去抽奖吧!');
- return;
- } else {
- $('.empty').hide();
- $('.name-list').show();
- for (var j = 0; j < _jtem.length; j++) {
- var _linkTxt = '';
- if(_jtem[j].book_id > 0){
- _linkTxt = '<a class="link_btn go_bookId" href="/index/book/chapter?book_id='+_jtem[j].book_id+'" data-bookId="' + _jtem[j].book_id + '"><span class="txt">去看书</span></a>';
- _html += '<li class="recordList" style="padding-right:2.0rem;"><span class="left">《' + _jtem[j].show_name +'》</span>'+_linkTxt+'</li>';
- }else{
- _linkTxt = '<span class="right"><span class="txt">已到账</span></span>';
- _html += '<li class="recordList" style="padding-right:2.0rem;"><span class="left">' + _jtem[j].show_name +'</span>'+_linkTxt+'</li>';
- }
- }
- }
- }
- $('.name-list').html(_html);
- }
- // 点击Tab时渲染数据
- $('.tab_nav span').click(function() {
- var $this = $(this);
- var data_type = $this.attr('data-type');
- nowTab = data_type;
- renderLi(nowTab);
- if (data_type == 'tab2') {
- // window.bookSotre.logClick('fanpai_index', 'dianjijiangpin', '', '', '');
- }
- // fnGetPrizeList(1); // 点击时进行数据请求,参数:是否为Tab点击
- });
- var $maskRule = $("#mask-rule"), //规则遮罩层
- $mask = $("#mask"), //红包遮罩层
- $winning = $(".winning"), //红包
- $card = $("#card"),
- $close = $("#close");
- //link = false;//判断是否在链接跳转中
- // 获取中奖信息
- var flagDraw = false;
- function fnLottery(_liThis) {
- // if(flagDraw){
- // return;
- // }
- // flagDraw = true;
- cpslog([702, {map:{campaign_status:'cardFlip'}}, 'card_flip_lottery_click']);
- $.ajax({
- url: '/api/card/lottery',
- type: 'post',
- timeout: 6000,
- data: {
- actId: actId,
- },
- success: function(data) {
- // wifilogdp([602,'getdrawsuccess_'+data.code]);
- flagDraw = false;
- console.log(data);
- switch (data.code) {
- case 0:
- //活动未开始
- toast({
- message: "活动未开始,请耐心等待",
- time: 2000
- });
- break;
- case 1:
- //成功
- /*console.log(222);*/
- // 1 看点(代金券) 2 话费 3 实物 4 成长值 5 书籍 6 再来1次 7 谢谢参与 8 vip
- var _wintxt = '<p>' + data.data.awardName + '</p>';
- var _h1txt = '恭喜获奖';
- $('.dialog_prize').removeClass('thanksImg');
- switch (data.data.type) {
- case 1:
- _h1txt = '谢谢参与';
- _wintxt = '<p>好可惜,差点就中了<br>别灰心,幸运女神总会降临的</p>';
- $('.dialog_prize').addClass('thanksImg');
- break;
- case 2:
- _wintxt = '<p>获得一本免费书籍<br>《' + data.data.name + '》</p><p class="p2"></p>';
- break;
- case 3:
- _wintxt = '<p>恭喜您获得了' + data.data.name + '</p><p class="p2">请在VIP个人中心进行查看</p>';
- break;
- case 4:
- _wintxt = '<p>恭喜您获得了' + data.data.kandian + '书币</p><p class="p2">已放入您的账户余额</p>';
- // 写入一条数据
- list_data.recordList.unshift(data.data);
- list_data.nameList.unshift(data.data);
- break;
- case 5:
- _h1txt = '免费再来一次';
- _wintxt = '<p>赶快试试手气吧~</p>';
- // 写入一条数据
- list_data.recordList.unshift(data.data);
- list_data.nameList.unshift(data.data);
- break;
- default:
- _h1txt = '谢谢参与';
- _wintxt = '<p>好可惜,差点就中了<br>别灰心,幸运女神总会降临的</p>';
- $('.dialog_prize').addClass('thanksImg');
- break;
- }
- $('.dialog_prize_img').attr('src', data.data.image);
- $('.wintxt').html(_wintxt);
- $('.red-body h1').html(_h1txt);
- $maskCard.show();
- clearInterval(timer); //清除轮流选中动画
- $cards.removeClass("active"); //清除轮流滚动类名
- _liThis.addClass("open-card"); //添加翻牌动画
- //动画监听
- _liThis.on("animationend", function() {
- _liThis.removeClass("open-card"); //移除翻牌动画
- $cards.css({ //所有卡牌放到右下角
- left: 280 / rem + "rem",
- top: 168 / rem + "rem"
- });
- $maskCard.hide();
- win();
- _liThis.off("animationend"); //解绑动画监听
- });
- //
- // initFnLottery($(this));
- break;
- case 2:
- toast({
- message: "今天抽奖次数用完了,明天再来吧!",
- time: 2000
- });
- break;
- case 3:
- toast({
- message: "很抱歉,当前账户余额不足~",
- time: 2000
- });
- setTimeout(function () {
- window.location.href="/index/recharge/pay?from=wechat&type=2&active_id="+actId;
- },2000)
- break;
- default:
- toast({
- message: "手速太快了!",
- time: 2000
- });
- break;
- }
- },
- error: function() {
- toast({
- message: "很遗憾,抽奖失败了",
- time: 2000
- });
- },
- complete: function(XMLHttpRequest, status) { //请求完成后最终执行参数
-
- if (status == 'timeout') { //超时,status还有success,error等值的情况
- toast({
- message: "很遗憾,抽奖失败了",
- time: 2000
- });
- }
- }
- })
- }
- // 中奖信息
- function win(target) {
- //遮罩层显示
- $mask.show();
- $winning.addClass("reback");
- // setTimeout(function() {
- // $card.addClass("pull");
- // }, 500);
- //中奖信息提示------------------------
- $(".mask-btn").click(() => {
- clickTime = new Date(); //时间更新
- index = length; //卡牌选中重新从第一张开始
- $mask.hide();
- // target.html(`<img src="./images/result-vip.png" alt="" srcset=""><p>7天VIP</p>`)
- init();
- window.location.reload();
- });
- /*$(".win,.btn").click(function () {
- link = true;
- });*/
- }
- // 关闭弹出层
- $("#close,.win,.btn").click(function() {
- clickTime = new Date(); //时间更新
- index = length; //卡牌选中重新从第一张开始
- init();
- $mask.hide();
- $winning.removeClass("reback");
- $card.removeClass("pull");
- // 渲染Tab 改变数据/中奖记录
- alert(222);
- renderLi(nowTab);
- });
- // 关闭dialog弹层
- $('.tip_box_dialog .dialog_tip_close').click(function() {
- $('.tip_box_dialog').hide();
- });
- // 去充值
- $('.tip_box_dialog .recharge').click(function() {
- $('.tip_box_dialog').hide();
- window.bookSotre.bookStoreClick('', '6', '', '');
- window.bookSotre.logClick('fanpai_index', 'dianjichongzhi', '', '', '');
- });
- // 跳转链接IOS-7,安卓-4
- // 打开rule
- $('.rule').click(function() {
- var _json = {
- 'url': window.location.protocol + '//' + window.location.host + '/huodong/fanpai/activity-rules.html'
- };
- if (isiOS) {
- window.bookSotre.bookStoreClick('', '7', _json.url, '');
- } else {
- window.bookSotre.bookStoreClick('', '4', '', JSON.stringify(_json));
- }
- });
- // 领取实物 需要区分客户端
- $('.tab_list').on('click', '.go_getAwardCenterList', function() {
- // /asg/portal/awardcenter/getAwardCenterList.do
- var SEARCH = $(this).attr('data-url');
- if (isiOS) {
- var _url = window.location.protocol + '//' + window.location.host + '/asg/portal/awardcenter/getAwardCenterList.do' + SEARCH
- window.bookSotre.bookStoreClick('', '7', _url, '');
- } else {
- var _json = '';
- if (opub && opub.p >= 32) {
- _json = {
- 'url': window.location.protocol + '//' + window.location.host + '/php/user/awardcenter' + SEARCH
- };
- } else {
- _json = {
- 'url': window.location.protocol + '//' + window.location.host + '/asg/portal/awardcenter/getAwardCenterList.do' + SEARCH
- };
- }
- window.bookSotre.bookStoreClick('', '4', '', JSON.stringify(_json));
- }
- });
- function go_book(){
- // // 领取实物 需要区分客户端
- // $('.go_bookId').onclick() {
- // alert(111);
- // var bookId = $(this).attr('data-bookId');
- // window.location.href="/index/book/chapter?sid="+bookId;
- // });
- $('.go_bookId').click(function () {
- alert(111);
- });
- }
- // go_vip 我的VIP页面
- $('.tab_list').on('click', '.go_vip', function() {
- var iosUrl = '/phpios/vip/viphome';
- var _json = {
- 'url': window.location.protocol + '//' + window.location.host + iosUrl
- };
- if (isiOS) {
- window.bookSotre.bookStoreClick('', '7', _json.url, '');
- } else {
- if (opub.p > 24) {
- window.bookSotre.bookStoreClick('', '32', '', '');
- } else {
- openVip();
- }
- }
- });
- });
- // window.bookSotre.logPv('fanpai_index', '', '');
|