wangchuanjin 9 年 前
コミット
fe112f8507

+ 2 - 1
core/src/qfw/active/active.go

@@ -10,7 +10,8 @@ var se util.SimpleEncrypt = util.SimpleEncrypt{Key: "topnet2015topnet2015"}
 
 type Active struct {
 	*xweb.Action
-	flop xweb.Mapper `xweb:"/active/flop/(.*)"`
+	flop     xweb.Mapper `xweb:"/active/flop/(.*)"`
+	flopAjax xweb.Mapper `xweb:"/active/flopAjax"`
 }
 
 //抽奖活动

+ 27 - 16
core/src/qfw/active/flop.go

@@ -17,6 +17,19 @@ import (
 var flopEncrypt util.SimpleEncrypt = util.SimpleEncrypt{Key: "flopActive"}
 
 //翻牌
+func (a *Active) FlopAjax() error {
+	if a.GetSession("flopData") != nil {
+		data := a.GetSession("flopData").(bson.M)
+		if updateCredit(data["s_userid"].(string), util.IntAll(data["i_oldcredit"]), util.IntAll(data["i_newcredit"]), a.Action) {
+			mongodb.Save("flop", data)
+		} else {
+			log.Println("翻牌的时候", data["s_openid"].(string), "的积分修改失败!")
+		}
+	}
+	return nil
+}
+
+//进入翻牌
 func (a *Active) Flop(encryptOpenid string) error {
 	//判断活动是否结束
 	if coreconfig.Flop.IsOver {
@@ -37,12 +50,13 @@ func (a *Active) Flop(encryptOpenid string) error {
 				cardType = util.IntAll((*data)["i_type"])
 				words = (*data)["s_words"].(string)
 				nickName = (*data)["s_nickname"].(string)
+				multiple = util.IntAll((*data)["i_multiple"])
 			}
 		}
 		//分享出去
 		if a.GetSession("userId") == nil || a.GetSession("s_m_openid") == nil || a.GetSession("i_credit") == nil {
 			getFlopData()
-			a.T["shareid"] = coreutil.FindMyShareId("topjy", openid)
+			a.T["shareid"] = coreutil.FindMyShareId("topflop", openid)
 		} else { //可以翻牌
 			s_openid := a.GetSession("s_m_openid").(string)
 			encryptOpenid = flopEncrypt.EncodeString(s_openid)
@@ -55,23 +69,20 @@ func (a *Active) Flop(encryptOpenid string) error {
 				multiple = getMultiple()
 				newCredit = oldCredit * multiple
 				//翻牌类型
-				card := coreconfig.Flop.Cards[rand.New(rand.NewSource(time.Now().UnixNano())).Intn(6)+1]
+				card := coreconfig.Flop.Cards[rand.New(rand.NewSource(time.Now().UnixNano())).Intn(6)]
 				cardType = util.IntAll(card["type"])
 				words = card["words"].(string)
-				if updateCredit(a.GetSession("userId").(string), oldCredit, newCredit, a.Action) {
-					mongodb.Save("flop", bson.M{
-						"s_openid":     s_openid,
-						"i_oldcredit":  oldCredit,
-						"i_newcredit":  newCredit,
-						"l_createdate": time.Now().Unix(),
-						"i_type":       cardType,
-						"s_words":      words,
-						"s_nickname":   nickName,
-						"i_multiple":   multiple,
-					})
-				} else {
-					log.Println("翻牌的时候", s_openid, "的积分修改失败!")
-				}
+				a.SetSession("flopData", bson.M{
+					"s_userid":     a.GetSession("userId").(string),
+					"s_openid":     s_openid,
+					"i_oldcredit":  oldCredit,
+					"i_newcredit":  newCredit,
+					"l_createdate": time.Now().Unix(),
+					"i_type":       cardType,
+					"s_words":      words,
+					"s_nickname":   nickName,
+					"i_multiple":   multiple,
+				})
 				flag = 1
 			} else {
 				getFlopData()

BIN
core/src/web/staticres/images/flop/bubble.png


+ 93 - 66
core/src/web/templates/active/flop.html

@@ -1,6 +1,6 @@
 <html>
 <head>
-<title>企明星-翻牌活动</title>
+<title>猴年翻福牌,翻来好运气</title>
 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
 <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
 <script src="/js/jquery.js"></script>
@@ -54,6 +54,8 @@ body{
 	font-family: tahoma, arial, 'Hiragino Sans GB', 'Microsoft YaHei', 宋体, sans-serif;
 	-webkit-tap-highlight-color: transparent;
 	background-color: #B63845;
+	font-size: 100%;
+	text-align: center;
 }
 img{
 	vertical-align: sub;
@@ -99,7 +101,7 @@ img{
 	left: 50%;
 	margin-left: -145px;
 	display: none;
-	font-size: 14px;
+	font-size:0.875em;
 	font-weight: bold;
 	text-align: center;
 	padding: 5px;
@@ -110,18 +112,18 @@ img{
 	margin-right: 3px;
 }
 .flop-tip>font{
-	font-size: 12px;
+	font-size: 0.75em;
 	font-weight: normal;
 }
 .multiple{
-	font-size: 22px;
+	font-size: 1.375em;
 	text-align: center;
 	position: relative;
 	width: 15px;
 	display: inline-block;
 	vertical-align: top;
 	overflow: hidden;
-	height: 20px;
+	height: 25px;
 }
 .flop-notice{
 	color: #ffa461;
@@ -153,7 +155,7 @@ img{
 	height: 90px;
 	background-color: #ffffff;
 }
-.flop-share>*{
+.flop-share>img{
 	display: inline-block;
 	width: 70px;
 	height: 70px;
@@ -162,10 +164,13 @@ img{
 	margin-top: 10px;
 }
 .flop-share>div{
+	display: inline-block;
 	width: 150px;
-	padding-top: 10px;
 	line-height: 25px;
-	font-size: 14px;
+	font-size: 0.875em;
+	position: relative;
+	top: 50%;
+	margin-top: -25px;
 }
 ul{
 	list-style: none;
@@ -177,6 +182,9 @@ ul{
 	left: 2px;
 	height: 155px;
 }
+.random li{
+	height: 25px;
+}
 </style>
 </head>
 <body>
@@ -206,6 +214,7 @@ ul{
 <div class="flop-tip">
 	恭喜!你的企明星积分翻
 	<span class="multiple">
+	{{if eq .T.flag 1}}
 	<ul class="random">
 		<li>7</li>
 		<li>3</li>
@@ -215,6 +224,9 @@ ul{
 		<li>9</li>
 		<li>2</li>
 	</ul>
+	{{else if eq .T.flag 2}}
+	{{.T.multiple}}
+	{{end}}
 	</span>倍!<br>
 	您的积分已从{{.T.oldCredit}}分涨到{{.T.newCredit}}分。<br>
 	<font>积分明细请到企明星(www.qmx.top)查询!</font>
@@ -222,66 +234,81 @@ ul{
 <script type="text/javascript">
 if({{.T.IsOver}}){
 	alert("活动已经结束!");
-}
-$(function(){
-	var windowWidth = $(window).width();
-	var windowHeight = $(window).height();
-	var defaultWidth = 320;
-	var defaultHeight = 416;
-	var width = 250;
-	var height = 282.4;
-	var top = 120;
-	var noticeTop = 80;
-	if(windowHeight > defaultHeight){
-		top = top / defaultHeight * windowHeight;
-		noticeTop = noticeTop / defaultHeight * windowHeight;
-	}
-	if(windowWidth > defaultWidth && windowHeight > defaultHeight){
-		width = width / defaultWidth * windowWidth;
-		if(width > 350){//最大宽度350
-			width = 350
+}else{
+	$(function(){
+		var windowWidth = $(window).width();
+		var windowHeight = $(window).height();
+		var defaultWidth = 320;
+		var defaultHeight = 416;
+		var width = 250;
+		var height = 282.4;
+		var cardTop = 120;
+		var noticeTop = 80;
+		if(windowWidth > 750){
+			$(".body-bg").css({width: 750,height: windowHeight});
 		}
-		height = width / 625 * 706;
-		$(".cards>img").css({width: width,height: height}).show();
-	}
-	$(".cards").css({"top": top}).show();
-	$(".flop-notice").css({"top": noticeTop});
-	if(windowHeight - $(".cards").height()  - top - $(".flop-tip").height() > 40){
-		$(".flop-tip").css({"line-height": "30px",top: $(".cards").height()+top});
-	}else{
-		$(".flop-tip").css({"top": $(".cards").height()+top-30});
-	}
-	//
-	{{if eq .T.flag 1}}
-		$(".btn").css({"top": $(".cards").height()+top}).show();
-		$(".btn").click(function(){
-			$("#flop-before,.btn").hide();
-			$("#flop-after,.flop-tip,.flop-notice").show();
-			var marginTop = 0;
-			var plus = true;
-			var randomInterval = setInterval(function(){
-				$(".random").css({top : "-22px"});
-				$(".random").append($(".random li:first"));
-			},20);
-			setTimeout(function(){
-				clearInterval(randomInterval);
-				$(".multiple").html({{.T.multiple}});
-			},1000);
-			setTimeout(function(){
-				$(".bubble").fadeIn();
-			},3000);
-			$('.cards').children('img:first').stop().animate({'width':0},100,function(){
-				$(this).hide().next().show();
-				$(this).next().animate({'width':width+'px'},500);
+		if(windowHeight > defaultHeight){
+			cardTop = cardTop / defaultHeight * windowHeight;
+			noticeTop = noticeTop / defaultHeight * windowHeight;
+		}
+		if(windowWidth > defaultWidth && windowHeight > defaultHeight){
+			width = width / defaultWidth * windowWidth;
+			if(width > 350){//最大宽度350
+				width = 350
+			}
+			height = width / 625 * 706;
+			$(".cards>img").css({width: width,height: height});
+		}
+		$(".cards").css({top: cardTop}).show();
+		$(".flop-notice").css({top: noticeTop});
+		var flopTipTop = windowHeight - $(".cards").height()  - cardTop - $(".flop-tip").height();
+		if(flopTipTop > 30 && flopTipTop < 40){
+			$(".flop-tip").css({"line-height": "30px",top: $(".cards").height() + cardTop - 20});
+		}else if(flopTipTop > 40){
+			$(".flop-tip").css({"line-height": "30px",top: $(".cards").height() + cardTop - 10});
+		}else{
+			$(".flop-tip").css({top: $(".cards").height()+cardTop-30});
+		}
+		//
+		{{if eq .T.flag 1}}
+			$(".btn").css({top: $(".cards").height()+cardTop}).show();
+			$(".btn").one("click",function(){
+				//
+				$.post("/active/flopAjax",null,null);
+				$("#flop-before,.btn").hide();
+				$("#flop-after,.flop-tip,.flop-notice").show();
+				var randomInterval = setInterval(function(){
+					$(".random").css({top : "-27px"});
+					$(".random").append($(".random li:first"));
+				},20);
+				setTimeout(function(){
+					clearInterval(randomInterval);
+					$(".multiple").html({{.T.multiple}});
+				},1000);
+				setTimeout(function(){
+					$(".bubble").fadeIn();
+				},3000);
+				$('.cards').children('img:first').stop().animate({'width':0},100,function(){
+					$(this).hide().next().show();
+					$(this).next().animate({'width':width+'px'},500);
+				});
 			});
-		});
-	{{else}}
-		$(".flop-notice").show();
-	{{end}}
-	{{if eq .T.flag 2}}
-		$(".flop-tip").show();
-	{{end}}
-});
+		{{else}}
+			$(".flop-notice").show();
+		{{end}}
+		{{if eq .T.flag 2}}
+			$(".flop-tip").show();
+		{{end}}
+		{{if eq .T.flag 3}}
+			var shareHeight = windowHeight - cardTop - height + 30;
+			if(shareHeight > 110){
+				shareHeight = 110;
+			}
+			$(".flop-share").css({height: shareHeight});
+			$(".flop-share>img").css({width: shareHeight-20,height: shareHeight-20});
+		{{end}}
+	});
+}
 </script>
 </body>
 </html>

+ 4 - 4
core/src/web/templates/common/top.html

@@ -67,7 +67,7 @@ function b_loadTop(){
 				if(hasMsgCount){
 					html += '<a class="b-round-dot"></a>';
 				}
-				html += '</span>'+result.nickName;
+				html += '</span><span>'+result.nickName+'</span>';
 				html += '<div id="head-hideMenu" class="head-hideMenu"><ul>'
 					    	+'<li onclick="window.location.href=\'/member/msgcenter\'"><i class="glyphicon youjian"></i><span>消息中心';
 				if(hasMsgCount){
@@ -78,9 +78,6 @@ function b_loadTop(){
 						+'<li onclick="window.location.href=\'/front/logout\'" class="border-b-0"><i class="glyphicon tuichu"></i>退出</li>';
 						+'</ul></div>';
 				$("#b-loginStatus").addClass("b-logined").html(html)
-				.click(function(){
-					window.location.href = "/member/show/memberindex";
-				})
 				.mouseover(function(){
 					$("#head-hideMenu").show();
 				}).mouseleave(function(){
@@ -91,6 +88,9 @@ function b_loadTop(){
 				}).mouseleave(function(){
 					$(this).hide();
 				});
+				$("#b-loginStatus>span").click(function(){
+					window.location.href = "/member/show/memberindex";
+				});
 				//处理公用底部扫码登录按钮
 				$("#bottom-bar>li:first").addClass("invisible");
 				//处理认证完之后第一次登录弹出提示框