Authored by 陈轩

save

/* eslint no-unused-vars: ["error", { "args": "none" }]*/
/* eslint-disable no-shadow, camelcase */
'use strict';
const url = require('url');
const moment = require('moment');
const vipDayModel = require('../models/vipDay');
const auth = require('../../passport/models/auth-helper');
... ... @@ -17,7 +18,13 @@ exports.beforeIn = (req, res, next) => {
msg: '请先登录'
});
} else {
return res.redirect('/signin.html');
let jumpTo = new url.Url();
jumpTo.pathname = '/signin.html';
req.yoho.isApp && (jumpTo.search = 'yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"http://m.yohobuy.com/activity/vip-day"}}}');
jumpTo = url.format(jumpTo);
return res.redirect(jumpTo);
}
};
... ... @@ -104,8 +111,13 @@ exports.saveMsg = (req, res, next) => {
.catch(next);
};
// 获取 会员日的 用户留言
exports.fetchMsg = (req, res, next) => {
return res.json();
let uid = req.user.uid;
vipDayModel.queryLeaveWordsList(uid).then(result => {
return res.json(result);
}).catch(next);
};
... ...
... ... @@ -23,6 +23,12 @@ exports.saveMsg = (uid, nick_name, content) => {
});
};
exports.queryLeaveWordsList = (uid) => {
const url = '/activity/UserdayLeaveWordsController/queryLeaveWordsList';
return serviceAPI.get(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/%E6%8B%BC%E6%89%8B%E6%B0%94%E5%A4%A7%E8%BD%AC%E7%9B%98%E6%8A%BD%E5%A5%96.md
... ... @@ -35,6 +41,7 @@ exports.addPrizeLog = (uid, prize_type) => {
});
};
// 查询 中奖纪录
exports.queryPrizeLog = (uid, prize_type) => {
const url = '/activity/UserdayPrizeLogController/queryPrizeLog';
... ...
... ... @@ -15,10 +15,11 @@ module.exports = {
siteUrl: '//m.yohobuy.com',
assetUrl: '//localhost:5001',
domains: {
// api: 'http://devapi.yoho.cn:58078/',
api: 'http://dev-api.yohops.com:9999/',
// service: 'http://devservice.yoho.cn:58077/'
api: 'http://api.yoho.cn/',
service: 'http://service.yoho.cn/',
// api: 'http://api.yoho.cn/',
service: 'http://192.168.102.14:8090',
// service: 'http://service.yoho.cn/',
liveApi: 'http://testapi.live.yohops.com:9999/'
},
subDomains: {
... ...
... ... @@ -12,7 +12,7 @@ var KEY_CODE = {
};
var $punch,
$msgBox, $msgModal, $msg;
$msgRoll, $msgModal, $msg;
var $punchModal;
... ... @@ -22,12 +22,14 @@ var page = {
init: function() {
this.domInit();
this.bindEvents();
this.fetchMsg();
},
domInit: function() {
$punch = $('#js-qiandao');
$punchModal = $('#qiandao-modal');
$msgBox = $('#js-msg-sec');
$msgRoll = $('.vip-day-msg-input');
$msgModal = $('#vipday-msg-input');
$msg = $msgModal.find('.msg-text');
},
... ... @@ -41,10 +43,10 @@ var page = {
$msg.focus();
})
.on('keydown', '.msg-text', function(event) {
event.preventDefault();
if (event.which !== KEY_CODE.ENTER) {
return;
}
event.preventDefault();
var textArea = event.target;
var content = $.trim(textArea.value);
... ... @@ -68,41 +70,90 @@ var page = {
$punchModal.yModal('show');
})
.fail(function() {
tip.show('签到失败 >_<');
});
.fail(function() {
tip.show('签到失败 >_<');
});
},
leaveMsg: function(content) {
$.post('/activity/vip-day/msg/save.json', {
content: content
})
.done(function(res) {
if (res.code !== 200) {
.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('留言失败~稍后再试');
return;
}
});
},
fetchMsg: function() {
$.get('/activity/vip-day/msg/fetch.json')
.done(function(res) {
if (res.code !== 200) {
// TODO return;
return;
}
$msgModal.yModal('hide');
var $frag = $('<ul></ul>'), $fragClone;
if (res.data === 1) {
tip.show('恭喜你~获得一次疯狂大转盘抽奖机会');
setTimeout(function() {
window.location = '/activity/vip-day/crazy-wheel';
}, 2000);
return;
}
$.each(res.data, function(index, msg) {
var li = document.createElement('li');
tip.show('发布成功~');
})
.fail(function() {
tip.show('留言失败~稍后再试');
})
.always();
li.className = '';
li.innerText = msg;
$frag.append(li);
});
}
$fragClone = $frag.clone();
$msgRoll
.append($frag, $frag.clone())
.css({ visibility: 'visible' });
var oneMsgH, onePageH;
$fragClone = $msgRoll.children().eq(1);
oneMsgH = $msgRoll[0].getBoundingClientRect().height - 6;
onePageH = $fragClone[0].offsetTop;
console.log(oneMsgH)
function rolling() {
$msgRoll.animate({
scrollTop: '+='.concat(oneMsgH)
}, 400, function() {
var curT = $msgRoll[0].scrollTop;
if (curT > onePageH) {
$msgRoll[0].scrollTop = curT - $frag[0].getBoundingClientRect().height;
}
setTimeout(rolling, 1000);
});
}
rolling();
})
.fail(function() {
});
}
};
window.$ = $;
... ...
... ... @@ -347,12 +347,25 @@
}
.vip-day-msg-input {
position: relative;
display: block;
width: 100%;
height: 67px;
visibility: hidden;
height: 51PX;
margin-top: 15px;
margin-bottom: 15px;
border: 3PX solid #000;
box-sizing: content-box;
overflow: hidden;
li {
padding-left: 15px;
padding-right: 15px;
height: 51PX;
line-height: 51PX;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
}
/* FLOW Element */
... ...
... ... @@ -106,7 +106,6 @@ $border-radius: 8px;
height: calc((406-4) / 3px);
margin-right: 2px;
margin-bottom: 2px;
/* background-color:rgba(255,255,255,0.8); */
&:nth-child(3n) {
margin-right: 0;
... ... @@ -225,6 +224,7 @@ $border-radius: 8px;
.primary {
font-size: 34px;
}
.award {
color: #d0021b;
}
... ... @@ -237,6 +237,7 @@ $border-radius: 8px;
height: 400px;
overflow: auto;
}
.ymodal-header {
font-size: 38px;
height: 120px;
... ...
... ... @@ -46,9 +46,9 @@
opacity: 0.8;
}
/*-------------------------------------------*\
/* ------------------------------------------- *\
Alert
\*-------------------------------------------*/
\* ------------------------------------------- */
.ymodal-alert {
.ymodal-dialog {
margin-top: 200px;
... ... @@ -76,4 +76,4 @@
width: 100%;
background-color: transparent;
}
}
\ No newline at end of file
}
... ...