|
@@ -2,17 +2,21 @@ const FindGoods = require('../models/find-goods'); |
|
@@ -2,17 +2,21 @@ const FindGoods = require('../models/find-goods'); |
2
|
const _ = require('lodash');
|
2
|
const _ = require('lodash');
|
3
|
const stringProcess = require('../../../utils/string-process');
|
3
|
const stringProcess = require('../../../utils/string-process');
|
4
|
|
4
|
|
5
|
-
|
|
|
6
|
exports.index = function(req, res, next) {
|
5
|
exports.index = function(req, res, next) {
|
7
|
let qcdn = _.get(req.app.locals, 'wap.qcloud_cdn');
|
6
|
let qcdn = _.get(req.app.locals, 'wap.qcloud_cdn');
|
8
|
- const {page = 1} = req.query || {};
|
7
|
+ const { page = 1 } = req.query || {};
|
9
|
|
8
|
|
10
|
- req.ctx(FindGoods).findGoods({page}).then((result)=> {
|
9
|
+ req.ctx(FindGoods)
|
|
|
10
|
+ .findGoods({ page, limit: 5 })
|
|
|
11
|
+ .then(result => {
|
11
|
if (!result) {
|
12
|
if (!result) {
|
12
|
return next();
|
13
|
return next();
|
13
|
}
|
14
|
}
|
14
|
- const title = stringProcess.paramsFilter(req.query.title) || '发现好货';
|
|
|
15
|
- const shareId = _.parseInt(stringProcess.paramsFilter(req.query.share_id));
|
15
|
+ const title =
|
|
|
16
|
+ stringProcess.paramsFilter(req.query.title) || '发现好货';
|
|
|
17
|
+ const shareId = _.parseInt(
|
|
|
18
|
+ stringProcess.paramsFilter(req.query.share_id),
|
|
|
19
|
+ );
|
16
|
|
20
|
|
17
|
// 唤起 APP 的路径
|
21
|
// 唤起 APP 的路径
|
18
|
res.locals.appPath = `yohobuy://yohobuy.com/goapp?openby:yohobuy={"action":"go.h5","params":{"param":{"share_id":"${shareId}","title":"${title}"},"share":"/operations/api/v5/webshare/getShare","shareparam":{"share_id":"${shareId}"},"title":"${title}","url":"https://activity.yoho.cn/activity/find/goods.html"}}`;
|
22
|
res.locals.appPath = `yohobuy://yohobuy.com/goapp?openby:yohobuy={"action":"go.h5","params":{"param":{"share_id":"${shareId}","title":"${title}"},"share":"/operations/api/v5/webshare/getShare","shareparam":{"share_id":"${shareId}"},"title":"${title}","url":"https://activity.yoho.cn/activity/find/goods.html"}}`;
|
|
@@ -20,6 +24,7 @@ exports.index = function(req, res, next) { |
|
@@ -20,6 +24,7 @@ exports.index = function(req, res, next) { |
20
|
const jsSdk = global.yoho.config.jsSdk;
|
24
|
const jsSdk = global.yoho.config.jsSdk;
|
21
|
|
25
|
|
22
|
console.log('---------result---------', result);
|
26
|
console.log('---------result---------', result);
|
|
|
27
|
+
|
23
|
res.render('find-goods/index', {
|
28
|
res.render('find-goods/index', {
|
24
|
module: 'activity',
|
29
|
module: 'activity',
|
25
|
page: 'find-goods',
|
30
|
page: 'find-goods',
|
|
@@ -28,9 +33,34 @@ exports.index = function(req, res, next) { |
|
@@ -28,9 +33,34 @@ exports.index = function(req, res, next) { |
28
|
isFeature: true,
|
33
|
isFeature: true,
|
29
|
wechatShare: true,
|
34
|
wechatShare: true,
|
30
|
localCss: true,
|
35
|
localCss: true,
|
31
|
- loadJs: [{
|
|
|
32
|
- src: qcdn ? jsSdk.replace(/\/\/cdn.yoho.cn/gi, '//qcdn.yoho.cn') : jsSdk
|
|
|
33
|
- }]
|
36
|
+ loadJs: [
|
|
|
37
|
+ {
|
|
|
38
|
+ src: qcdn ?
|
|
|
39
|
+ jsSdk.replace(
|
|
|
40
|
+ /\/\/cdn.yoho.cn/gi,
|
|
|
41
|
+ '//qcdn.yoho.cn',
|
|
|
42
|
+ ) :
|
|
|
43
|
+ jsSdk,
|
|
|
44
|
+ },
|
|
|
45
|
+ ],
|
|
|
46
|
+ });
|
|
|
47
|
+ })
|
|
|
48
|
+ .catch(next);
|
|
|
49
|
+};
|
|
|
50
|
+
|
|
|
51
|
+exports.fetchMore = function(req, res, next) {
|
|
|
52
|
+ const { page = 1 } = req.query || {};
|
|
|
53
|
+
|
|
|
54
|
+ req.ctx(FindGoods)
|
|
|
55
|
+ .findGoods({ page })
|
|
|
56
|
+ .then(result => {
|
|
|
57
|
+ if (!result) {
|
|
|
58
|
+ return next();
|
|
|
59
|
+ }
|
|
|
60
|
+
|
|
|
61
|
+ res.render('find-goods/item-list', {
|
|
|
62
|
+ content: result.data
|
34
|
});
|
63
|
});
|
35
|
- }).then().catch(next);
|
64
|
+ })
|
|
|
65
|
+ .catch(next);
|
36
|
}; |
66
|
}; |