123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- 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('网络错误,请稍后再试!')
- }
- })
- }
|