Authored by 杨延青

Merge branch 'hotfix/question2.2' into 'gray'

Hotfix/question2.2

question source

See merge request !149
... ... @@ -8,6 +8,11 @@ const getQuestionnaire = (req, res) => {
res.redirect(helpers.urlFormat(`/3party/questionnaire/${id}`, null, 'm'));
};
const getQuestionList = (req, res) => {
res.redirect(helpers.urlFormat('/3party/questionnaire', null, 'm'));
};
module.exports = {
getQuestionnaire
getQuestionnaire,
getQuestionList
};
... ...
... ... @@ -32,4 +32,5 @@ router.get('/material/getRecommendlist', auth, materialController.getRecommendli
router.get('/activate-count', auth, activate.index);
router.get('/activate-count/getList', auth, activate.getList);
router.get('/questionnaire/:id', auth, questionnaire.getQuestionnaire);
router.get('/questionnaire', auth, questionnaire.getQuestionList);
module.exports = router;
... ...
/**
* suggestFeedBack model
* @author: gxh<xuhui.ge@yoho.cn>
* @date: 2017/04/06
*/
'use strict';
const service = global.yoho.ServiceAPI;
const URL_ACTIVITY_QUESTION = '/activity/question/';
/**
* 获取用户信息
* @param uid
* @return string
*/
const feedBackApi = (uid) => {
return service.get(URL_ACTIVITY_QUESTION + 'questionList', {uid: uid});
};
module.exports = {
feedBackApi
};
... ... @@ -5,32 +5,27 @@
*/
'use strict';
const api = require('./suggestFeedBack-api');
const helpers = global.yoho.helpers;
const api = require('./getBanner');
const _ = require('lodash');
const suggestFeedBack = (uid) => {
const QUESTION_CODE = '1337a9f26f3972060bb2a2ca3aba81fd';
return api.feedBackApi(uid).then((result) => {
let suggestData = [];
const suggestFeedBack = () => {
return api.getResource(QUESTION_CODE).then(result => {
if (result.code === 200) {
let data = _.dropWhile(_.get(result, 'data', []), o => {
return o.template_name !== 'single_image'; // 取一张图资源位
});
let list = [];
if (result && result.code === 200 && _.get(result, 'data.rows')) {
_.forEach(data, value => {
list.push(_.get(value, 'data[0]', ''));
});
if (_.get(result, 'data.rows')) {
_.forEach(_.get(result, 'data.rows', []), it => {
let item = {
description: it.description,
title: it.title,
id: it.id,
url: helpers.urlFormat(`/3party/questionnaire/${it.id}`, null)
};
suggestData.push(item);
});
}
result.data = _.compact(list);
}
return suggestData;
return result;
});
};
... ...
... ... @@ -9,16 +9,12 @@
{{#if suggestData}}
{{#each suggestData}}
<li key="{{@index}}" {{#unless @first}}class="hide"{{/unless}}>
<form class="feed-back-form" action="#">
<p class="description">{{description}}</p>
<p>{{title}}</p>
<div>
<a class="feed-back-btn button" href="{{url}}">我要参与</a>
</div>
</form>
<a href="{{url}}" class="img-item">
<img src="{{image2 src w=330 h=130}}">
</a>
</li>
{{/each}}
{{else}}
{{else}}
<li>
<p class="feed-back-none">调研问卷时间未开始,有货君正在生成调研问卷,<br/>
请您先逛一逛,稍后再来~~
... ...
... ... @@ -90,7 +90,9 @@ function actionhomeFootChange() {
return $.getJSON('//www.yohobuy.com/common/suggestfeedback?callback=?', param,
function(suggestData) {
$feedBackBox.html(suggestFeedBackHbs({suggestData: suggestData}));
if (suggestData.code === 200 && suggestData.data.length) {
$feedBackBox.html(suggestFeedBackHbs({suggestData: suggestData.data}));
}
}
);
}
... ...
... ... @@ -140,6 +140,17 @@
margin: 5px 0 0;
resize: none;
}
.img-item {
display: block;
width: 100%;
height: 130px;
img {
width: 100%;
height: 100%;
}
}
}
.vote-item p {
... ...