var test = null,//定时器 hasSuccess = 0, progressWidth = 20,//进度的百分比 time = '',//抽奖次数 // cid = '1002', imei = '352936095523931', androidId = '6c735b635fe943c852e8392152f20ac8', version = '1.5.4', secretkey = '3d0e4b94e04b8dcca1cedb9c33051173', goldCount = '', gameId = '', hasHide = false, emptyPosition = '';//空位置 cid='',imei='',androidId='',version='',secretkey='3d0e4b94e04b8dcca1cedb9c33051173',goldCount='',gameId='',hasHide=false,emptyPosition='',//空位置 question_id = -1, result = '', hasMove = false; $().ready(function () { getToken(); adSize();//添加广告位 // 先获取次数 // 答对之后根据接口获取金豆数 }) // 广告 function adSize(){ taskObj.onLayoutAdSize(851,350,260,34) } function showRule() { $(".mask").show(); $(".rule_content").show(); $("body").attr("style","overflow:hidden"); } $("button").on("click", function () { $(".mask").hide(); $(".rule_content").hide(); }) $(".mask").on("click", function () { $(".active li").removeClass("animate"); $(".active li").removeClass("rotate"); $(".active li").removeClass("scale"); $(".mask").hide(); }) $(".active li").on("click", function () { $(".all").show(); $(".rule").attr("style", "z-index:0"); $(".active").attr("style", "z-index:2"); $(this).siblings().hide(); $(this).show(); $(".mask").show(); $(this).addClass("animate"); var that = this setTimeout(function () { $(that).addClass("rotate"); }, 1500) setTimeout(function () { $(that).addClass("scale"); hasMove = true; }, 4000); setTimeout(function () { result = Math.floor(Math.random() * 10) + 1; try { // 切换底部广告 taskObj.checkAd(350,260); }catch(e) { } // 跳转 if (result >6) { hasSuccess = 0; question_id = 1; $(".active li").removeClass("animate"); $(".active li").removeClass("rotate"); $(".active li").removeClass("scale"); $(".mask").hide(); $(".active li").show(); hasMove = false $(".all").hide(); $(".rule").attr("style", "z-index:2"); $(".active").attr("style", "z-index:0"); initGold(); window.location.href=lastHref()+"/moveAgainUpload.html" }else if(result>3&&result<=6){ hasSuccess = 0; question_id = 1; $(".active li").removeClass("animate"); $(".active li").removeClass("rotate"); $(".active li").removeClass("scale"); $(".mask").hide(); $(".active li").show(); hasMove = false $(".all").hide(); $(".rule").attr("style", "z-index:2"); $(".active").attr("style", "z-index:0"); initGold(); taskObj.h5_adStart(); } else { question_id = 1; hasSuccess = 1; $(".active li").removeClass("animate"); $(".active li").removeClass("rotate"); $(".active li").removeClass("scale"); $(".mask").hide(); $(".active li").show(); hasMove = false $(".all").hide(); $(".rule").attr("style", "z-index:2"); $(".active").attr("style", "z-index:0"); getGold(); } // 广告 // if (result <7) { // hasSuccess = 0; // question_id = 1; // $(".active li").removeClass("animate"); // $(".active li").removeClass("rotate"); // $(".active li").removeClass("scale"); // $(".mask").hide(); // $(".active li").show(); // hasMove = false // $(".all").hide(); // $(".rule").attr("style", "z-index:2"); // $(".active").attr("style", "z-index:0"); // initGold(); // taskObj.h5_adStart(); // } else { // question_id = 1; // hasSuccess = 1; // $(".active li").removeClass("animate"); // $(".active li").removeClass("rotate"); // $(".active li").removeClass("scale"); // $(".mask").hide(); // $(".active li").show(); // hasMove = false // $(".all").hide(); // $(".rule").attr("style", "z-index:2"); // $(".active").attr("style", "z-index:0"); // getGold(); // } }, 6700) }) function getToken() { try { var data = JSON.parse(taskObj.jsGetToken()); cid = data.cid, imei = data.imei, androidId = data.androidId, version = data.version, token = data.token // 获取金币 initGold(); } catch (e) { token = 'e094ced38ef917b5219bd5a4f79c261011855563' initGold(); } } $(".all").on("click", function () { if (hasMove) { $(".active li").removeClass("animate"); $(".active li").removeClass("rotate"); $(".active li").removeClass("scale"); $(".mask").hide(); $(".active li").show(); hasMove = false $(".all").hide(); $(".rule").attr("style", "z-index:2"); $(".active").attr("style", "z-index:0"); taskObj.h5_adStart(); } }) function getLast() { var test = window.location.pathname; var newTest = test.split("/") var test1 = newTest[newTest.length - 1]; return window.location.host + test.replace("/" + test1, ""); } function parseQueryString(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i = 0; i < vars.length; i++) { var pair = vars[i].split("="); if (pair[0] == variable) { return pair[1]; } } return (false); } function lastHref() { var test = window.location.pathname; var newTest = test.split("/") var test1 = newTest[newTest.length - 1]; return window.location.origin + test.replace("/" + test1, "") } $(".back").on("click", function () { if (hasSuccess) { var target = lastHref() + "/taskList.html?id=" + parseQueryString("id") taskObj.h5_back(target) } else { var target = lastHref() + "/taskList.html?id=-1" taskObj.h5_back(target) } }) // 金币初始化 function initGold() { // hasSuccess=0 var time1 = new Date().getTime(); var arr = ["hasSuccess=0", "question_id=" + question_id, "type=" + parseQueryString("id"), "time=" + time1] var sign = arr.join("&") sign = md5(sign + secretkey) $.ajax({ type: 'post', url: '/api/V3/getUserAdvertStatus', headers: { token: token, cid: cid,//渠道号暂时写死 imei: imei, time: time1, sign: sign, androidId: androidId, }, data: { type: parseQueryString("id"), hasSuccess: 0, question_id: question_id }, success: function (res) { var res = JSON.parse(res) if (res && res.res.success == 1) { $(".lastTime span").text(res.res.residualCount+"次"); coin = res.res.coin } else { showMsg(res.message) } }, error: function () { showMsg('网络错误,请稍后再试!') } }) } // 领取金币 function getGold(type, id) { hasSuccess = 1 var time1 = new Date().getTime(); var arr = ["question_id=" + (id ? id : '-1'), "type=" + parseQueryString("id"), "time=" + time1] var sign = arr.join("&") sign = md5(sign + secretkey) $.ajax({ type: 'post', url: '/api/V3/getAdvertCoin', headers: { token: token, cid: cid,//渠道号暂时写死 imei: imei, time: time1, sign: sign, androidId: androidId, version: version, }, data: { type: parseQueryString("id"), // hasSuccess: hasSuccess, question_id: id ? id : '-1' }, success: function (res) { var res = JSON.parse(res) if (res && res.code == 0) { $(".lastTime span").text(res.res.residualCount+"次"); taskObj.game_done(Number(parseQueryString("id")),Number(res.res.coin),true,Number(-1)); if (type) { $(type).hide(); $(type).parent().find(".active").show(); } if (hasSuccess != 1) { initGold() } } else { showMsg(res.res.msg) } }, error: function () { showMsg('网络错误,请稍后再试!') } }) }