index.html 13.1 KB
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="Author" content="李靖">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    <title>玩游戏赢有货币</title>
    <meta name="viewport"
          content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
    <link rel="stylesheet" type="text/css" href="css/reset.css"/>
    <link rel="stylesheet" type="text/css" href="css/style.css"/>
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/autoSize.js"></script>
    <script type="text/javascript" src="js/style.js"></script>
    <script type="text/javascript" charset="utf-8" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script>
    	$(function() {
    		var uid = null;
    		var clickBoxArr = {};
            var vars = {},
                hash,
                i,
                search = window.location.search,
                hashes = search ? decodeURIComponent(search).slice(1).split('&') : [];
            for (i = 0; i < hashes.length; i++) {
                hash = hashes[i].split('=');
                vars[hash[0]] = hash[1];
            }
            
    		
    		//判定登录
			var isApp = !!vars.app_version || (vars.openrefer === 'app' && vars.uid);//判断是否是APP
		
			
			$.post("/activity/brandDraw/getBrandActList", function(data) {
    			if (!data || data.code != 200) {
    				return;
    			}
    			var arr = data.data;
    			for (var i = 0; i < arr.length; i++) {
                    $(".a-box-ul").append($("<li>").data("boxData", arr[i]).click(function() {
                    	var boxObj = this;
                    	if (!isApp) {
            				var dataRequestUrl = "http://m.yohobuy.com/passport/login/user";
            	            $.getJSON(dataRequestUrl+"?callback=?", function(json) {
            	                    if (json.code === 200) {
            	                        uid=json.data;
            	                        var boxData = $(boxObj).data("boxData");
            	                    	var a = clickBoxArr[boxData.id];
            	                    	if (a) {
            	                    		// 点击过该箱子
            	                    		$("body").append(awaBrand(boxData.brandInfo));
            	                    		return;
            	                    	}
            	                    	clickBoxArr[boxData.id] = 1;
            	                    	$.post("/activity/brandDraw/addBrandActPrize", {
            	                    		uid : uid,
            	                    		boxId : boxData.id
            	                    	}, function(json) {
            	                    		if (!json) {
            	                    			return;
            	                    		}
            	                    		if (json.code != 200) {
            	                    			$("body").append(awaBrand(json.data.brandInfo));
            	                    			return;
            	                    		}
            	                    		$("body").append(awaCover(json.data.prizeRemark));
            	                    	});
            	                    } else {
            	                        var url ='http://m.yohobuy.com/signin.html?refer=' + window.location.href;
            	                        //window.location.href=url;
            	                        if ($("#collocation-link").length <= 0) {
            	                            $("body").append('<a href=\'' + url + '\' style="display:none;" id="collocation-link">' +
            	                                                '<span class="collocation-link"></span>' +
            	                                            '</a>');     
            	                        }
            	                        $(".collocation-link").click();
            	                    }
            	                }
            	            );
            			} else {
            				var Request = new Object();
            				Request = GetRequest();
            				uid = Request['uid'];
            				var url ="";
                             if (!uid){ 
                            	var locationUrl = cutUrl(window.location.href);
                                url = locationUrl + '?app_version=1&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"'
                                        + locationUrl +'","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"N"}}';
                                if ($("#collocation-link").length <= 0) {
                                    $("body").append('<a href=\'' + url + '\' style="display:none;" id="collocation-link">' +
                                                        '<span class="collocation-link"></span>' +
                                                    '</a>');
                                }
                                
                                $(".collocation-link").click();
                            }else{
                            	var boxData = $(boxObj).data("boxData");
                            	var a = clickBoxArr[boxData.id];
                            	if (a) {
                            		// 点击过该箱子
                            		$("body").append(awaBrand(boxData.brandInfo));
                            		return;
                            	}
                            	clickBoxArr[boxData.id] = 1;
                            	$.post("/activity/brandDraw/addBrandActPrize", {
                            		uid : uid,
                            		boxId : boxData.id
                            	}, function(json) {
                            		if (!json) {
                            			return;
                            		}
                            		if (json.code != 200) {
                            			$("body").append(awaBrand(json.data.brandInfo));
                            			return;
                            		}
                            		$("body").append(awaCover(json.data.prizeRemark));
                            	});
                            }
            			}
                    	
                    	
                    	
                    }).append($("<img>").attr({
                    	src : "/activity/" + arr[i].boxImage
                    })));
                }
    		}, "json");
			
			
			//我的奖品
        	$(".check-awa-btn").live("click", function () {
        		
        		if (!isApp) {
    				var dataRequestUrl = "http://m.yohobuy.com/passport/login/user";
    	            $.getJSON(dataRequestUrl+"?callback=?", function(json) {
    	                    if (json.code === 200) {
    	                        uid=json.data;
    	                        $(".awa-list-ul ul").empty();
    	                        $.ajax({
    	                            url: '/activity/brandDraw/getBrandPrizeListByUid?uid=' + uid,
    	                            type: "get",
    	                            contentType: "application/json",
    	                            dataType: 'json',
    	                            success: function (data) {
    	                                if (data.code === 200) {
    	                                    var arr = data.data;
    	                                    $(".awa-list-ul ul").empty();
    	                                    for (var i = 0; i < arr.length; i++) {
    	                                        var _obj = arr[i];
    	                                        if (_obj != null) {
    	                                            $(".awa-list-ul ul").append('<li><span>' + _obj.prizeRemark + '</span><span>' + _obj.createTimeStr + '</span></li>');
    	                                            $(".act-list-ul").append('<a><li>' + _obj.brandInfo + '</li></a>');
    	                                        }
    	                                    }
    	                                } 
    	                            }
    	                        });
    	                    } else {
    	                        var url ='http://m.yohobuy.com/signin.html?refer=' + window.location.href;
    	                        //window.location.href=url;
    	                        if ($("#collocation-link").length <= 0) {
    	                            $("body").append('<a href=\'' + url + '\' style="display:none;" id="collocation-link">' +
    	                                                '<span class="collocation-link"></span>' +
    	                                            '</a>');     
    	                        }
    	                        $(".collocation-link").click();
    	                    }
    	                }
    	            );
    			} else {
    				var Request = new Object();
    				Request = GetRequest();
    				uid = Request['uid'];
                     if (!uid){ 
                    	var locationUrl = cutUrl(window.location.href);
                        var url = locationUrl + '?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"'
                                + locationUrl +'","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"N"}}';
                        if ($("#collocation-link").length <= 0) {
                            $("body").append('<a href=\'' + url + '\' style="display:none;" id="collocation-link">' +
                                                '<span class="collocation-link"></span>' +
                                            '</a>');
                        }
                        $(".collocation-link").click();
                    }else{
                    	$(".awa-list-ul ul").empty();
                        $.ajax({
                            url: '/activity/brandDraw/getBrandPrizeListByUid?uid=' + uid,
                            type: "get",
                            contentType: "application/json",
                            dataType: 'json',
                            success: function (data) {
                                if (data.code === 200) {
                                    var arr = data.data;
                                    $(".awa-list-ul ul").empty();
                                    for (var i = 0; i < arr.length; i++) {
                                        var _obj = arr[i];
                                        if (_obj != null) {
                                            $(".awa-list-ul ul").append('<li><span>' + _obj.prizeRemark + '</span><span>' + _obj.createTimeStr + '</span></li>');
                                            $(".act-list-ul").append('<a><li>' + _obj.brandInfo + '</li></a>');
                                        }
                                    }
                                } 
                            }
                        });
                    }
    			}
        		
        		
        		
        		
                
            });
    	});
        //截取url
        function cutUrl(url) {
            var urlStr = url;
            var urlArr = new Array(); 
            urlArr =  urlStr.split("?");
            url = urlArr[0];
            return url;
        }
    	//获取url的uid
    	function GetRequest() {
		   var url = location.search; //获取url中"?"符后的字串
		   var theRequest = new Object();
		   if (url.indexOf("?") != -1) {
		      var str = url.substr(1);
		      strs = str.split("&");
		      for(var i = 0; i < strs.length; i ++) {
		         theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
		      }
		   }
		   return theRequest;
		}
    </script>
</head>
<body>
<input id="shareLink" type="hidden" value="http://service.yoho.cn/activity/brand/enter.html">
<input id="shareDesc" type="hidden" value="YOHO!BUY有货【2016潮流新品节】CRAZY BOX疯狂来袭!拆箱赢好礼,有货币、优惠券、现金券赚不停!">
<input id="shareImg" type="hidden" value="http://feature.yoho.cn/0426SHAREIMG/images/0906.jpg">
<input id="shareTitle" type="hidden" value="每天都有机会获得奖品哦~">
<script type="text/javascript" charset="utf-8" src="/activity/brandVote/YOHOPE/js/wx-share.js"></script>
<div class="a-container c-bg">
    <a class="rule-btn">
        <img src="/activity/brand/images/rule-btn.png"/>
    </a>

    <div class="a-box clearfix">
        <ul class="a-box-ul clearfix"></ul>
        <div class="awa-list-c">
            <a class="close-list-btn">
                <img src="/activity/brand/images/close-list-btn.jpg">
            </a>

            <h1>我的奖品</h1>

            <div class="awa-list-ul">
                <ul></ul>
            </div>
        </div>
        <a class="check-awa-btn">
            <img src="/activity/brand/images/my-awa.png"/>
        </a>
    </div>
    <div class="a-box clearfix">
        <div class="act-list-c">
            <ul class="act-list-ul">
            </ul>
        </div>
        <a class="check-act-btn">查看活动</a>
    </div>
    <a class="hot-awa" href="http://feature.yoho.cn/0906/MAIN/index.html">
        <img src="/activity/brand/images/hot-awa.png"/>
    </a>
</div>
<div class="dia-c">
    <a class="close-btn">
        <img src="/activity/brand/images/close-btn.png"/>
    </a>
    <img src="/activity/brand/images/rule.png"/>
</div>
</body>
</html>