Showing
4 changed files
with
29 additions
and
4 deletions
1 | 'use strict'; | 1 | 'use strict'; |
2 | 2 | ||
3 | +const semver = require('semver'); | ||
3 | const questionModel = require('../models/question'); | 4 | const questionModel = require('../models/question'); |
4 | const headerModel = require('../../../doraemon/models/header'); // 头部model | 5 | const headerModel = require('../../../doraemon/models/header'); // 头部model |
5 | 6 | ||
6 | exports.list = (req, res, next) => { | 7 | exports.list = (req, res, next) => { |
8 | + let canShare = false; | ||
9 | + | ||
10 | + if (req.yoho.isApp && req.query.app_version) { | ||
11 | + let appVersion = req.query.app_version.split('.'); | ||
12 | + | ||
13 | + appVersion = `${appVersion[0]}.${appVersion[1]}.${appVersion[2]}`; | ||
14 | + | ||
15 | + if (semver.lt(appVersion, '5.8.1')) { | ||
16 | + canShare = true; | ||
17 | + } | ||
18 | + } | ||
19 | + | ||
7 | req.ctx(questionModel).getQuestionList().then(result => { | 20 | req.ctx(questionModel).getQuestionList().then(result => { |
8 | res.render('question/list', { | 21 | res.render('question/list', { |
9 | title: '调研中心', | 22 | title: '调研中心', |
@@ -14,6 +27,7 @@ exports.list = (req, res, next) => { | @@ -14,6 +27,7 @@ exports.list = (req, res, next) => { | ||
14 | }), | 27 | }), |
15 | list: result, | 28 | list: result, |
16 | isApp: req.yoho.isApp, | 29 | isApp: req.yoho.isApp, |
30 | + canShare: canShare, | ||
17 | localCss: true | 31 | localCss: true |
18 | }); | 32 | }); |
19 | }).catch(next); | 33 | }).catch(next); |
1 | <div class="qs-list-page"> | 1 | <div class="qs-list-page"> |
2 | {{#if list}} | 2 | {{#if list}} |
3 | - <ul id="qs-list" class="qs-list"> | 3 | + <ul id="qs-list" class="qs-list{{#if canShare}} can-share{{/if}}"> |
4 | {{#each list}} | 4 | {{#each list}} |
5 | <li data-id="{{id}}" data-title="{{title}}" data-desc="{{share.subtitle}}" data-img="{{share.imgUrl}}">{{index}}.{{title}}</li> | 5 | <li data-id="{{id}}" data-title="{{title}}" data-desc="{{share.subtitle}}" data-img="{{share.imgUrl}}">{{index}}.{{title}}</li> |
6 | {{/each}} | 6 | {{/each}} |
@@ -196,10 +196,18 @@ let question = { | @@ -196,10 +196,18 @@ let question = { | ||
196 | } | 196 | } |
197 | }, | 197 | }, |
198 | saveAnswers: function(info) { | 198 | saveAnswers: function(info) { |
199 | - if (!info || !info.length) { | 199 | + var that = this; |
200 | + | ||
201 | + if (this.saving || !info || !info.length) { | ||
200 | return; | 202 | return; |
201 | } | 203 | } |
202 | 204 | ||
205 | + this.saving = true; | ||
206 | + | ||
207 | + setTimeout(function() { | ||
208 | + that.saving = false; | ||
209 | + }, 5000); | ||
210 | + | ||
203 | $.ajax({ | 211 | $.ajax({ |
204 | type: 'POST', | 212 | type: 'POST', |
205 | url: '/3party/questionnaire/submit', | 213 | url: '/3party/questionnaire/submit', |
@@ -211,6 +219,7 @@ let question = { | @@ -211,6 +219,7 @@ let question = { | ||
211 | frontAnswers: JSON.stringify(info) | 219 | frontAnswers: JSON.stringify(info) |
212 | } | 220 | } |
213 | }).then(function(data) { | 221 | }).then(function(data) { |
222 | + that.saving = false; | ||
214 | if (data.code === 200) { | 223 | if (data.code === 200) { |
215 | tipDg.show('调查问卷已成功提交,感谢您的帮助!'); | 224 | tipDg.show('调查问卷已成功提交,感谢您的帮助!'); |
216 | 225 |
@@ -99,6 +99,8 @@ tipDialog.init(); | @@ -99,6 +99,8 @@ tipDialog.init(); | ||
99 | 99 | ||
100 | let $list = $('#qs-list'); | 100 | let $list = $('#qs-list'); |
101 | 101 | ||
102 | +let canShare = $list.hasClass('can-share'); | ||
103 | + | ||
102 | $list.on('click', 'li', function() { | 104 | $list.on('click', 'li', function() { |
103 | let data = $(this).data(); | 105 | let data = $(this).data(); |
104 | 106 | ||
@@ -110,10 +112,10 @@ $list.on('click', 'li', function() { | @@ -110,10 +112,10 @@ $list.on('click', 'li', function() { | ||
110 | if (resData.code === 200) { | 112 | if (resData.code === 200) { |
111 | jumpQuestionDetail(data); | 113 | jumpQuestionDetail(data); |
112 | } else if (resData.code === 206) { | 114 | } else if (resData.code === 206) { |
113 | - if (yoho && yoho.isApp) { | 115 | + if (canShare && yoho && yoho.isApp) { |
114 | yoho.invokeMethod('go.showShareAlert', { | 116 | yoho.invokeMethod('go.showShareAlert', { |
115 | title: data.title, | 117 | title: data.title, |
116 | - link: 'http://m.yohobuy.com/3party/questionnaire/' + data.id, | 118 | + link: 'https://m.yohobuy.com/3party/questionnaire/' + data.id, |
117 | desc: data.desc, | 119 | desc: data.desc, |
118 | imgUrl: data.img | 120 | imgUrl: data.img |
119 | }); | 121 | }); |
-
Please register or login to post a comment