index.html 9.01 KB
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base target="_blank" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>YO'HOPE</title>

<style type="text/css">
body, h1, h2, h3, h4, h5, h6, hr, p, blockquote, dl, dt, dd, ul, ol, li, pre, form, fieldset, legend, button, input, textarea, th, td {
    margin:0;
    padding:0;
}
img{
    border: 0 none;
    vertical-align: top;
}

.wrap{ width:1000px; margin:0 auto; overflow:hidden; position: relative; }
.wrap img{
    width: 100%;
}
*:focus{outline:none;}

.left_wrap,.right_wrap{
    width: 500px;
    height: 646px;
    position: relative;
    overflow: hidden;
    float: left;
}
.vote{
    width: 184px;
    height: 41px;
    background: url("images/click_off.jpg") 0 0 no-repeat;
    background-size: 100%;
    position: absolute;
    right: 49px;
    top: 555px;
    cursor: pointer;
}

.vote_click{
    background: url("images/click_on.jpg") 0 0 no-repeat;
    background-size: 100%;
}

.vote_button{
    width: 436px;
    height: 80px;
    background: url("images/vote.jpg") 0 0 no-repeat;
    margin-top: 27px;
    /*text-align: center;*/
    cursor: pointer;
}
.diaCover-p{
    position: fixed;
    background: black;
    top: 50px;
    font-size: 15px;
    left: 50%;
    height: 40px;
    width: 400px;
    margin-left: -200px;
    color: white;
    text-align: center;
    line-height: 40px;
    border-radius: 10px;
    opacity: 0.8;
}
</style>
</head>

<body>
<div style="height:216px; background:url(images/bg_01.jpg) no-repeat center center; width:100%; margin:0 auto;"></div>
<div style="height:234px; background:url(images/bg_02.jpg) no-repeat center center; width:100%; margin:0 auto;"></div>

<div style="height:190px; background:url(images/bg_03.jpg) no-repeat center center; width:100%; margin:0 auto;"></div>

<div style="height:50px; background:url(images/bg_04.jpg) no-repeat center center; width:100%; margin:0 auto; cursor: pointer;" class="detail_click"></div>

<div style="height:266px; background:url(images/bg_05.jpg) no-repeat center center; width:100%; margin:0 auto; display: none;" class="detail"></div>

<div style="height:646px; background:url(images/bg_06.jpg) no-repeat center center; width:100%; margin:0 auto;">
    <div class="wrap">
        <div class="left_wrap">
            <div id="1" class="vote"></div>
            <img src="images/blank.png" height="646" border="0" usemap="#Map" />
        </div>
        <div class="right_wrap">
            <div id="2" class="vote"></div>
            <img src="images/blank.png" height="646" border="0" usemap="#Map" />
        </div>
    </div>
</div>

<div style="height:646px; background:url(images/bg_07.jpg) no-repeat center center; width:100%; margin:0 auto;">
    <div class="wrap">
        <div id="3" class="left_wrap">
            <div class="vote"></div>
            <img src="images/blank.png" height="646" border="0" usemap="#Map" />
        </div>
        <div id="4" class="right_wrap">
            <div class="vote"></div>
            <img src="images/blank.png" height="646" border="0" usemap="#Map" />
        </div>
    </div>
</div>

<div style="height:646px; background:url(images/bg_08.jpg) no-repeat center center; width:100%; margin:0 auto;">
    <div class="wrap">
        <div class="left_wrap">
            <div id="5" class="vote"></div>
            <img src="images/blank.png" height="646" border="0" usemap="#Map" />
        </div>
        <div class="right_wrap">
            <div id="6" class="vote"></div>
            <img src="images/blank.png" height="646" border="0" usemap="#Map" />
        </div>
    </div>
</div>

<div style="height:646px; background:url(images/bg_09.jpg) no-repeat center center; width:100%; margin:0 auto;">
    <div class="wrap">
        <div class="left_wrap">
            <div id="7" class="vote"></div>
            <img src="images/blank.png" height="646" border="0" usemap="#Map" />
        </div>
        <div class="right_wrap">
            <div id="8" class="vote"></div>
            <img src="images/blank.png" height="646" border="0" usemap="#Map" />
        </div>
    </div>
</div>

<div style="height:646px; background:url(images/bg_10.jpg) no-repeat center center; width:100%; margin:0 auto;">
    <div class="wrap">
        <div class="left_wrap">
            <div id="9" class="vote"></div>
            <img src="images/blank.png" height="646" border="0" usemap="#Map" />
        </div>
        <div class="right_wrap">
            <div id="10" class="vote"></div>
            <img src="images/blank.png" height="646" border="0" usemap="#Map" />
        </div>
    </div>
</div>

<div style="height:646px; background:url(images/bg_11.jpg) no-repeat center center; width:100%; margin:0 auto;">
    <div class="wrap">
        <div class="left_wrap">
            <div id="11" class="vote"></div>
            <img src="images/blank.png" height="646" border="0" usemap="#Map" />
        </div>
        <div class="right_wrap">
            <div id="12" class="vote"></div>
            <img src="images/blank.png" height="646" border="0" usemap="#Map" />
        </div>
    </div>
</div>

<div style="height:646px; background:url(images/bg_12.jpg) no-repeat center center; width:100%; margin:0 auto;">
    <div class="wrap">
        <div class="left_wrap">
            <div id="13" class="vote"></div>
            <img src="images/blank.png" height="646" border="0" usemap="#Map" />
        </div>
        <div class="right_wrap">
            <div id="14" class="vote"></div>
            <img src="images/blank.png" height="646" border="0" usemap="#Map" />
        </div>
    </div>
</div>

<div style="height:167px; width: 100%; background:#ffffff;text-align: center;">
    <input type="button" class="vote_button" />
</div>
<script type="text/javascript" src="http://cdn.yoho.cn/huodong/libs/jquery.min.js"></script>
<script>
	var dataRequestUrl="http://m.yohobuy.com/passport/login/user";
	var nums = 0;
	var setOut = "";
	var votedNum = 0;
	
	function diaCover(msg) {
        clearTimeout(setOut);
        $(".diaCover-p").remove();
        $("body").append("<div class='diaCover-p'>" + msg + "</div>");
        setOut = setTimeout("$('.diaCover-p').remove();",3000);
    }
	
	$(function () {
		$.getJSON(dataRequestUrl+"?callback=?", function(json) {
			if (json.code != 200) {
				return;
			}
			if (!json.data) {
				return;
			}
			$.post("/activity/ActVoteResultController/getActVoteNumByUid", {
				uid : json.data
			}, function(data) {
				if (!data || data.code != 200) {
					return;
				}
				votedNum = data.data ? data.data.length : 0;
				$(data.data).each(function(index, item) {
					$("div[id='"+ item.voteItemId +"']").addClass("vote_click");
				});
			}, "json");
		});
		
		//活动细则
	    $('.detail_click').click(function(){
	        if($(this).hasClass('isclick')){
	            $('.detail').slideUp(500);
	            $(this).css("background-image", "url(images/bg_04.jpg)");
	            $(this).removeClass('isclick');
	        }else{
	            $('.detail').slideDown(500);
	            $(this).css("background-image","url(images/bg_044.jpg)");
	            $(this).addClass('isclick');
	        }
	    });
		
		$(".vote").click(function() {
			if ($(this).hasClass("vote_click")) {
				$(this).removeClass("vote_click");
				nums--;
			} else {
				$(this).addClass("vote_click");
				nums++;
			}
		});
		
		$('.vote_button').click(function(){
			if (votedNum > 0) {
				diaCover("您已经投过票");
				return;
			}
			$.getJSON(dataRequestUrl+"?callback=?", function(json) {
				if (json.code != 200) {
					diaCover("请先登录!!!");
                    window.location.href = "https://www.yohobuy.com/signin.html?refer=" + window.location.href;
					return;
				}
				if (!json.data) {
					diaCover("请先登录!!!");
                    window.location.href = "https://www.yohobuy.com/signin.html?refer=" + window.location.href;
					return;
				}
				var itemIds = [];
				var voted = $(".vote_click");
				if (!voted || voted.length == 0) {
					diaCover("您还没有投票");
					return;
				}
				if (voted.length > 3) {
					diaCover("每人最多投三张票");
					return;
				}
				$(voted).each(function(index, item) {
					itemIds.push({
						uid : json.data,
						voteItemId : $(item).attr("id")
					});
				});
				$.post("/activity/ActVoteResultController/addActVoteResult", {
					uid : json.data,
					itemIds : JSON.stringify(itemIds)
				}, function(data) {
					if (!data || data.code != 200) {
						diaCover(data.message);
						return;
					} else {
						diaCover("投票成功");
					}
				}, "json");
			});
		});
		
	});
	
	//统计点击量
    (function(w, d, s, j, f) {
        var a = d.createElement(s);
        var m = d.getElementsByTagName(s)[0];

        w.YohoAcquisitionObject = f;

        w[f] = function() {
            w[f].p = arguments;
        };

        a.async = 1;
        a.src = j;
        m.parentNode.insertBefore(a,m);
    })(window, document, 'script', 'http://cdn.yoho.cn/yas-jssdk/1.0.17/yas.js', '_yas');
</script>
</body>
</html>