Authored by 陈轩

fix 拼手气 coin显示逻辑

... ... @@ -103,6 +103,7 @@ exports.crazyLuck = (req, res, next) => {
pageStyle: 'vip-day game',
isLuck: true,
coin: coins && coins.data && (coins.data.total > 9999 ? (coins.data.total / 10000).toFixed(2) + '万' : coins.data.total),
coinNum: (coins && coins.data && coins.data.total) || 0,
joinNum: joinNum && joinNum.data || 0,
});
})().catch(next);
... ... @@ -198,7 +199,11 @@ exports.luckResult = (req, res, next) => {
// 得出 中奖结果
let result = yield vipDayModel.addPrizeLog(uid, prize_type);
Object.assign(result, { coin: coin - cost });
if (result.code !== 200) {
return result;
}
Object.assign(result, { coin: coin - cost + result.data });
return result;
});
... ...
... ... @@ -41,5 +41,6 @@
</div>
<script>
var coin = {{coinNum}};
var joinNum = {{joinNum}};
</script>
... ...
... ... @@ -19,6 +19,7 @@ var Game = function(elem, config) {
// 注入
this.awards = null;
this.success = $.noop;
this.onstart = $.noop;
$.extend(this, config);
... ... @@ -38,6 +39,7 @@ Game.prototype.bindEvents = function() {
}
self.canPlay = false;
self.onstart();
self.getResult()
.done(function(res) {
var awardIndex;
... ...
... ... @@ -49,6 +49,7 @@ function getAwards($container) {
$(function() {
var gCoin = window.coin;
var $coin = $('#my-coin');
var $awardsModal = $('#js-awards');
var $playerNum = $('#player-num');
... ... @@ -65,12 +66,20 @@ $(function() {
$playerNum.text(window.joinNum);
}
function setCoins(count) {
$coin.text(coinNumReadable(count));
}
setInterval(function() {
var up = Math.floor(Math.random() * 5);
upPlayers(up);
}, 5000);
game.onstart = function() {
setCoins(gCoin - 20);
};
game.success = function(score, coin) {
var content = score === 0 ? '很遗憾您没有中奖,继续加油哦~' : '<p class="primary">恭喜你获得<span class="award">' + score + '</span>个有货币,请到【我的奖品】中查收</p>';
... ... @@ -79,7 +88,7 @@ $(function() {
content: content
});
$coin.text(coinNumReadable(coin));
setCoins(gCoin = coin);
upPlayers(1);
};
... ...