...
|
...
|
@@ -4,8 +4,16 @@ |
|
|
*/
|
|
|
'use strict';
|
|
|
require('plugin/modal');
|
|
|
var tip = require('plugin/tip');
|
|
|
window.tip = tip;
|
|
|
|
|
|
var KEY_CODE = {
|
|
|
ENTER: 13
|
|
|
};
|
|
|
|
|
|
var $punch,
|
|
|
$msgBox, $msgModal, $msg;
|
|
|
|
|
|
var $punch;
|
|
|
|
|
|
var $punchModal;
|
|
|
|
...
|
...
|
@@ -19,16 +27,81 @@ var page = { |
|
|
domInit: function() {
|
|
|
$punch = $('#js-qiandao');
|
|
|
$punchModal = $('#qiandao-modal');
|
|
|
$msgBox = $('#js-msg-sec');
|
|
|
$msgModal = $('#vipday-msg-input');
|
|
|
$msg = $msgModal.find('.msg-text');
|
|
|
},
|
|
|
|
|
|
bindEvents: function() {
|
|
|
var self = this;
|
|
|
|
|
|
$punch.on('click', $.proxy(this.punchFuli, this));
|
|
|
$msgModal
|
|
|
.on('shown.yoho.modal', function() {
|
|
|
$msg.focus();
|
|
|
})
|
|
|
.on('keydown', '.msg-text', function(event) {
|
|
|
if (event.which !== KEY_CODE.ENTER) {
|
|
|
return;
|
|
|
}
|
|
|
event.preventDefault();
|
|
|
|
|
|
var textArea = event.target;
|
|
|
var content = $.trim(textArea.value);
|
|
|
|
|
|
if (content.length) {
|
|
|
self.leaveMsg(content);
|
|
|
}
|
|
|
})
|
|
|
.on('hiden.yoho.modal', function() {
|
|
|
$msg.val('');
|
|
|
});
|
|
|
},
|
|
|
|
|
|
// 签到福利
|
|
|
punchFuli: function() {
|
|
|
$punchModal.yModal('show');
|
|
|
$.post('/activity/vip-day/signin.json').done(function(res) {
|
|
|
if (res.code !== 200) {
|
|
|
tip.show(res.msg || '非法请求');
|
|
|
}
|
|
|
|
|
|
$punchModal.yModal('show');
|
|
|
})
|
|
|
.fail(function() {
|
|
|
tip.show('请求失败 >_<');
|
|
|
});
|
|
|
},
|
|
|
|
|
|
leaveMsg: function(content) {
|
|
|
$.post('/activity/vip-day/msg/save.json', {
|
|
|
content: content
|
|
|
})
|
|
|
.done(function(res) {
|
|
|
if (res.code !== 200) {
|
|
|
tip.show('留言失败~稍后再试');
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
$msgModal.yModal('hide');
|
|
|
|
|
|
if (res.data === 1) {
|
|
|
tip.show('恭喜你~获得一次疯狂大转盘抽奖机会');
|
|
|
setTimeout(function() {
|
|
|
window.location = '/activity/vip-day/crazy-wheel';
|
|
|
}, 2000);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
tip.show('发布成功~');
|
|
|
})
|
|
|
.fail(function() {
|
|
|
tip.show('留言失败~稍后再试');
|
|
|
})
|
|
|
.always();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
window.$ = $;
|
...
|
...
|
|