Authored by 毕凯

Merge branch 'feature/question2.1' into 'gray'

question share tip



See merge request !690
'use strict';
const semver = require('semver');
const questionModel = require('../models/question');
const headerModel = require('../../../doraemon/models/header'); // 头部model
exports.list = (req, res, next) => {
let canShare = false;
if (req.yoho.isApp && req.query.app_version) {
let appVersion = req.query.app_version.split('.');
appVersion = `${appVersion[0]}.${appVersion[1]}.${appVersion[2]}`;
if (semver.lt(appVersion, '5.8.1')) {
canShare = true;
}
}
req.ctx(questionModel).getQuestionList().then(result => {
res.render('question/list', {
title: '调研中心',
... ... @@ -14,6 +27,7 @@ exports.list = (req, res, next) => {
}),
list: result,
isApp: req.yoho.isApp,
canShare: canShare,
localCss: true
});
}).catch(next);
... ...
<div class="qs-list-page">
{{#if list}}
<ul id="qs-list" class="qs-list">
<ul id="qs-list" class="qs-list{{#if canShare}} can-share{{/if}}">
{{#each list}}
<li data-id="{{id}}" data-title="{{title}}" data-desc="{{share.subtitle}}" data-img="{{share.imgUrl}}">{{index}}.{{title}}</li>
{{/each}}
... ...
... ... @@ -196,10 +196,18 @@ let question = {
}
},
saveAnswers: function(info) {
if (!info || !info.length) {
var that = this;
if (this.saving || !info || !info.length) {
return;
}
this.saving = true;
setTimeout(function() {
that.saving = false;
}, 5000);
$.ajax({
type: 'POST',
url: '/3party/questionnaire/submit',
... ... @@ -211,6 +219,7 @@ let question = {
frontAnswers: JSON.stringify(info)
}
}).then(function(data) {
that.saving = false;
if (data.code === 200) {
tipDg.show('调查问卷已成功提交,感谢您的帮助!');
... ...
... ... @@ -99,6 +99,8 @@ tipDialog.init();
let $list = $('#qs-list');
let canShare = $list.hasClass('can-share');
$list.on('click', 'li', function() {
let data = $(this).data();
... ... @@ -110,10 +112,10 @@ $list.on('click', 'li', function() {
if (resData.code === 200) {
jumpQuestionDetail(data);
} else if (resData.code === 206) {
if (yoho && yoho.isApp) {
if (canShare && yoho && yoho.isApp) {
yoho.invokeMethod('go.showShareAlert', {
title: data.title,
link: 'http://m.yohobuy.com/3party/questionnaire/' + data.id,
link: 'https://m.yohobuy.com/3party/questionnaire/' + data.id,
desc: data.desc,
imgUrl: data.img
});
... ...