Authored by 郭成尧

Merge branch 'feature/raffle' into 'release/5.4'

测试bug

1.验证微信端,才能点击抽奖按钮
2.uid在node端获取
3.修改title

See merge request !139
... ... @@ -15,7 +15,7 @@ exports.activity = (req, res, next) => {
uid: req.user.uid
}).then((result) => {
res.render('raffle/activity', Object.assign(result, {
title: 'Yoho!Buy 有货',
title: '免单抽奖',
width750: true,
localCss: true
}));
... ... @@ -98,7 +98,7 @@ exports.enter = (req, res) => {
exports.lucky = (req, res, next) => {
raffleModel.lucky({
lotteryId: req.body.lotteryId,
userId: req.body.userId,
userId: req.user.uid,
orderCode: req.body.orderCode
}).then(result => {
res.json(result);
... ...
... ... @@ -3,7 +3,7 @@
<div class="logo"></div>
<div class="title">
{{# lottery}}
<p>{{name}}</p>
<p>{{{name}}}</p>
{{/ lottery}}
</div>
<div class="kind"></div>
... ... @@ -19,7 +19,7 @@
<div class="rule-list-c">
<ul>
{{# lottery}}
<li>{{remark}}</li>
<li>{{{remark}}}</li>
{{/ lottery}}
</ul>
</div>
... ...
... ... @@ -202,59 +202,63 @@ orderHammer.on('tap', function(e) {
$reaMask.data('orderId', id);
if ($cur.closest('.raffle-btn').length > 0) {
userId = $cur.closest('.raffle-btn').attr('data-uid');
orderCode = $cur.closest('.raffle-btn').attr('data-code');
$.ajax({
type: 'POST',
url: '/activity/raffle/lucky',
data: {
lotteryId: 20,
userId: userId,
orderCode: orderCode
},
success: function(data) {
var luck = data.data.orderLotteryCode;
var $diaMain = $('.dia-main');
switch(luck){
case 0:
break;
case 1:
lucky(data);
break;
case 2:
unlucky();
break;
case 3:
tip.show('用户抽奖不能多个客户端一起抽奖');
break;
case 4:
unlucky();
break;
}
// 中奖
function lucky(data) {
var message = data.data.orderLotteryMessage;
var bgPic = data.data.prize.image;
$('.lucky').show();
$('.dia-c').show();
$diaMain.find('p').show();
var dia_h = $diaMain.height() / 2;
$diaMain.css('margin-top', '-' + dia_h + 'px');
$diaMain.find('.message').text(message);
$diaMain.find('.lucky').css("background-image","url(" + bgPic + ")");
}
// 未中奖
function unlucky() {
$('.unlucky').show();
$('.dia-c').show();
var dia_h = $diaMain.height() / 2;
$diaMain.css('margin-top', '-' + dia_h + 'px');
if (isWeiXin()) {
userId = $cur.closest('.raffle-btn').attr('data-uid');
orderCode = $cur.closest('.raffle-btn').attr('data-code');
$.ajax({
type: 'POST',
url: '/activity/raffle/lucky',
data: {
lotteryId: 20,
orderCode: orderCode
},
success: function(data) {
var luck = data.data.orderLotteryCode;
var $diaMain = $('.dia-main');
switch(luck){
case 0:
break;
case 1:
lucky(data);
break;
case 2:
unlucky();
break;
case 3:
tip.show('用户抽奖不能多个客户端一起抽奖');
break;
case 4:
unlucky();
break;
}
// 中奖
function lucky(data) {
var message = data.data.orderLotteryMessage;
var bgPic = data.data.prize.image;
$('.lucky').show();
$('.dia-c').show();
$diaMain.find('p').show();
var dia_h = $diaMain.height() / 2;
$diaMain.css('margin-top', '-' + dia_h + 'px');
$diaMain.find('.message').text(message);
$diaMain.find('.lucky').css("background-image","url(" + bgPic + ")");
}
// 未中奖
function unlucky() {
$('.unlucky').show();
$('.dia-c').show();
var dia_h = $diaMain.height() / 2;
$diaMain.css('margin-top', '-' + dia_h + 'px');
}
},
error: function(data) {
tip.show(data.message);
}
},
error: function(data) {
tip.show(data.message);
}
});
});
} else {
tip.show('请在微信端打开,才能参加抽奖');
}
}
if ($cur.closest('.del').length > 0) {
... ... @@ -447,4 +451,14 @@ $('.dia-c .close').on('click', function() {
$('.dia-main a').on('click', function () {
window.location.href = '//m.yohobuy.com/activity/raffle/orders'
});
\ No newline at end of file
});
// 判断是否是微信
function isWeiXin(){
var ua = window.navigator.userAgent.toLowerCase();
if(ua.match(/MicroMessenger/i) == 'micromessenger'){
return true;
} else {
return false;
}
}
\ No newline at end of file
... ...