Authored by 毕凯

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

增加中奖记录



See merge request !242
... ... @@ -71,6 +71,21 @@ exports.getOrders = (req, res, next) => {
};
/**
* 获取中奖记录
* @param req
* @param res
* @param next
*/
exports.getRecord = (req, res, next) => {
raffleModel.getRecord({
pageCount: req.query.pageCount,
pageId: req.query.pageId,
}).then(result => {
res.json(result);
}).catch(next);
};
/**
* 入口页
* @param req
* @param res
... ...
... ... @@ -470,12 +470,27 @@ const bind = (params) => {
}, {code: 200});
};
/**
* 获取中奖记录
* @returns {*}
* @private
* @param params
*/
const getRecord = (params) => {
return service.get('/activity/lottery/getLotteryPrizeInfo', {
lotteryId: 20,
pageId: params.pageId,
pageCount: params.pageCount
}, {code: 200});
};
module.exports = {
order,
getOrders,
activity,
lucky,
bind
bind,
getRecord
};
... ...
... ... @@ -91,6 +91,7 @@ router.get('/market/v2', market.v2); // 市场推广活动å‡çº§ç‰ˆï¼Œè‡ªå®šä¹‰ä
router.get('/raffle/activity', raffle.activity); // 微信免单抽奖活动
router.get('/raffle/orders', auth, raffle.order); // 微信免单抽奖活动订单列表
router.get('/raffle/getOrders', raffle.getOrders); // 微信免单抽奖活动获取订单列表数据
router.get('/raffle/getRecord', raffle.getRecord); // 微信免单抽奖活动获取中奖记录
router.get('/raffle/enter', raffle.enter); // 微信免单抽奖活动入口页
router.post('/raffle/lucky', raffle.lucky); // 微信免单抽奖按钮
router.get('/raffle/bind', raffle.bind); // 送有货币
... ...
... ... @@ -12,6 +12,12 @@
<li>{{name}}{{remark}}</li>
{{/ prizes}}
</ul>
<div class="record">
<p>获奖名单:</p>
<div class="record-c">
<div class="record-list"></div>
</div>
</div>
<a class="btn" href="./orders"></a>
<div class="account">{{# mobile}}您已绑定账号:{{.}}{{/ mobile}}</div>
<div class="rule-c">
... ...
... ... @@ -35,7 +35,8 @@ var orderHammer,
reasonSwiper;
var userId = '',
orderCode = '';
orderCode = '',
pageId = 0;
var orderContent = require('activity/raffle/order-content.hbs');
... ... @@ -401,6 +402,69 @@ $(function() {
$(slides[activeIndex]).css('transform', '');
}
});
// 中奖记录
if ($('.record').length > 0) {
var pageCount = 6;
recordInit();
goScroll();
}
// 初始化
function recordInit() {
var recordResult = getRecord();
var $recordList = recordResult.data.lotteryPrize;
var $recordSpan = '';
for (var i = 0; i < $recordList.length; i++) {
$recordSpan = $recordSpan + '<span>' + $recordList[i].userName + '中了' + $recordList[i].prizeName + ':' + $recordList[i].prizeRemark + ';&nbsp</span>';
}
$('.record-list').append($recordSpan);
}
// 获取中奖记录
function getRecord() {
pageId ++;
var recordResult = '';
$.ajax({
type: 'GET',
url: '/activity/raffle/getRecord',
data: {
pageId: pageId,
pageCount: pageCount
},
async: false,
success: function(res) {
if (res.code === 200) {
if (res.data.lotteryPrize.length < pageCount) {
pageId = 0;
}
recordResult = res;
} else {
tip.show('网络断开了~~');
}
},
error: function(res) {
tip.show('网络断开了~~');
}
});
return recordResult;
}
// 滚动
function goScroll() {
var $firstSpan = $('.record-list span:first');
var $recordList = $('.record-list');
$recordList.animate({marginLeft: '-' + $firstSpan.width() + 'px'}, 10000, 'linear',
function() {
$firstSpan.remove();
$recordList.css('margin-left', '0');
if ($recordList.find('span').length < 5) {
recordInit();
}
goScroll();
}
);
}
});
$reaMask.find('.box-cmp').on('touchend', function(e) {
... ...
... ... @@ -7,6 +7,28 @@
background-size: 100% auto;
background-repeat: no-repeat;
.record {
color: #fff;
font-size: 25px;
margin-top: 30px;
p {
text-align: center;
}
.record-c {
width: 600px;
margin: 0 auto;
overflow: hidden;
height: 40px;
line-height: 40px;
}
.record-list {
width: 2000px;
}
}
.logo {
width: 263px;
height: 53px;
... ...