Authored by 陈轩

save

/* eslint no-unused-vars: ["error", { "args": "none" }]*/
/* eslint-disable no-shadow, camelcase */
'use strict';
const vipDayModel = require('../models/vipDay');
const auth = require('../../passport/models/auth-helper');
exports.beforeIn = (req, res, next) => {
if (req.user.uid) {
return next();
}
if (req.xhr) {
return res.json({
msg: '请先登录'
});
} else {
return res.redirect('/signin.html');
}
};
exports.index = (req, res, next) => {
res.locals.module = 'activity';
res.locals.page = 'vipday_entry';
... ... @@ -36,3 +54,43 @@ exports.crazyLuck = (req, res, next) => {
isLuck: true
});
};
/* 会员日签到 */
exports.signin = (req, res, next) => {
res.json({
code: 200
});
};
exports.saveMsg = (req, res, next) => {
// let uid = req.user.uid;
let content = req.body.content;
let uid = 8039759;
return res.json({
code: 200,
data: 1,
});
// auth.profile(uid)
// .then(profile => {
// // 1. get nick_name
// return profile.profile_name;
// })
// .then(nick_name => {
// // 2. save message
// return vipDayModel.saveMsg(uid, nick_name, content);
// })
// .then(result => {
// if (result.code === 200 && result.data === 1) {
// }
// res.json(result);
// })
// .catch(next);
};
exports.fetchMsg = (req, res, next) => {
return res.json();
};
... ...
/* eslint-disable camelcase */
'use strict';
const serviceAPI = global.yoho.ServiceAPI;
// 签到
// doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/%E4%BC%9A%E5%91%98%E6%97%A5%E6%B4%BB%E5%8A%A8/%E4%BC%9A%E5%91%98%E6%97%A5%E7%AD%BE%E5%88%B0.md
exports.signin = (uid)=> {
const url = '/activity/UserdaySigninController/signin';
return serviceAPI.post(url, {uid});
};
// 写留言
// doc: http://git.yoho.cn/yoho-documents/api-interfaces/blob/master/%E4%BC%9A%E5%91%98%E6%97%A5%E6%B4%BB%E5%8A%A8/%E4%BF%9D%E5%AD%98%E7%94%A8%E6%88%B7%E7%95%99%E8%A8%80.md
exports.saveMsg = (uid, nick_name, content) => {
const url = '/activity/UserdayLeaveWordsController/addLeaveWords';
return serviceAPI.post(url, {
uid,
nick_name,
content
});
};
\ No newline at end of file
... ...
... ... @@ -62,9 +62,14 @@ router.get('/invite/getwxinfo', invite.getwxinfo);
router.get('/invite/shareover', invite.shareover);
router.get('/invite/over', invite.over);
// router.use('/vip-day', vipDay.beforeIn);
router.get('/vip-day', vipDay.index);
router.get('/vip-day/crazy-wheel', vipDay.crazyWheel);
router.get('/vip-day/crazy-luck', vipDay.crazyLuck);
router.post('/vip-day/signin.json', vipDay.signin);
router.post('/vip-day/msg/save.json', vipDay.saveMsg);
router.get('/vip-day/msg/fetch.json', vipDay.fetchMsg);
module.exports = router;
... ...
... ... @@ -22,7 +22,9 @@
<img class="play-icon-flag" src="{{imgSrc '/img/activity/vip_day/play-icon-1.png'}}" alt="签到福利">
</li>
<li class="item item-2 pull-right">
<img class="play-icon-flag" src="{{imgSrc '/img/activity/vip_day/play-icon-2.png'}}" alt="拼手气">
<a href="/activity/vip-day/crazy-luck">
<img class="play-icon-flag" src="{{imgSrc '/img/activity/vip_day/play-icon-2.png'}}" alt="拼手气">
</a>
</li>
</ul>
</section>
... ... @@ -34,7 +36,7 @@
</header>
<div class="content text-center">
<p>会员日当天消费的会员将获得<strong>翻倍</strong>VIP积分奖励</p>
<button type="button" class="vip-rocket-privilege">VIP 专享权</button><br>
<button type="button" class="vip-rocket-privilege" data-toggle="ymodal" data-target="#vip-privilege">VIP 专享权</button><br>
<button type="button" class="vip-rocket-buynow">立即买</button>
</div>
</section>
... ... @@ -77,13 +79,13 @@
</section>
{{! section: 欢乐福利加倍区 }}
<section id="" class="vip-day-sec">
<section id="js-msg-sec" class="vip-day-sec">
<header class="header">
<h5 class="title">[ 欢乐福利加倍区 ]</h5>
</header>
<div class="content vip-day-msg">
<div class="clearfix">
<div class="mirror">
<div class="mirror" data-toggle="ymodal" data-target="#vipday-msg-input">
<span>填写留言~</span>
</div>
<p class="label">
... ... @@ -120,3 +122,13 @@
<img src="{{imgSrc 'img/activity/vip_day/qiandao.png'}}">
</div>
</div>
<div class="ymodal" id="vip-privilege">
<div class="vh-center ymodal-dialog" data-dismiss="ymodal">
<img src="{{imgSrc 'img/activity/vip_day/privilege.png'}}" alt="VIP 权益">
</div>
</div>
<div class="ymodal" id="vipday-msg-input">
<textarea class="msg-text" placeholder="写些啥呢~"></textarea>
</div>
... ...
... ... @@ -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.$ = $;
... ...
... ... @@ -38,12 +38,15 @@ Modal.prototype.show = function(relatedTarget) {
if (this._isShown) {
return this;
}
this.$element.trigger('show.yoho.modal', relatedTarget);
this.$element.on('click.dismiss.yoho.modal', Selector.DATA_DISMISS, $.proxy(this.hide, this));
this._isShown = true;
this.$element.show();
this.$element.show().focus();
this.backdrop();
this.$element.trigger('shown.yoho.modal', relatedTarget);
};
Modal.prototype.hide = function(e) {
... ...
... ... @@ -14,7 +14,7 @@ var $tip, tipItime;
var tipHtml = '<div id="yoho-tip" class="yoho-tip"></div>';
// 插入提示HTML
$('.yoho-page').append(tipHtml);
$('body').append(tipHtml);
$tip = $('#yoho-tip');
$tip.on('touchend', function() {
... ...
... ... @@ -367,8 +367,20 @@
height: 545px;
}
#vip-privilege img {
width: 494px;
}
#vipday-msg-input {
.msg-text {
width: 100%;
height: 330px;
}
}
#chit-qcode,
#qiandao-modal {
#qiandao-modal,
#vip-privilege {
.ymodal-dialog {
height: 100%;
}
... ...