Authored by lea guo

发现好货

@@ -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 };
@@ -473,5 +473,6 @@ router.get('/group/loadOrder', auth, group.loadOrder); // 加载拼团列表 @@ -473,5 +473,6 @@ router.get('/group/loadOrder', auth, group.loadOrder); // 加载拼团列表
473 473
474 // 发现好货 474 // 发现好货
475 router.get('/find/goods', FindGoods.index); 475 router.get('/find/goods', FindGoods.index);
  476 +router.get('/find/goods/more', FindGoods.fetchMore);
476 477
477 module.exports = router; 478 module.exports = router;
1 <div class="find-goods-wrapper"> 1 <div class="find-goods-wrapper">
2 - 发现好货  
3 - {{log content}}  
4 {{#unless content.detailList}} 2 {{#unless content.detailList}}
5 <div class="empty"> 3 <div class="empty">
6 暂无数据 4 暂无数据
  1 +{{#content.detailList}}
  2 + {{> find-goods/item-info}}
  3 +{{/content.detailList}}
1 <div class="item-wrapper"> 1 <div class="item-wrapper">
2 - <div class="author-info"> 2 + <a class="author-info">
3 <img class="avatar-img" src="{{image2 authorHeadIco w=30 h=30}}" alt="" /> 3 <img class="avatar-img" src="{{image2 authorHeadIco w=30 h=30}}" alt="" />
4 <span class="avatar-name">{{authorName}}</span> 4 <span class="avatar-name">{{authorName}}</span>
5 - </div> 5 + </a>
6 <a class="item-info"> 6 <a class="item-info">
7 <img src="{{image2 findGood.productImage w=120 h=120}}" alt="" /> 7 <img src="{{image2 findGood.productImage w=120 h=120}}" alt="" />
8 <div class="item-detail"> 8 <div class="item-detail">
1 -.item-wrapper { 1 +.find-goods-wrapper {
  2 + height: 100vh;
  3 + overflow-x: hidden;
  4 + overflow-y: auto;
  5 +
  6 + .empty {
  7 + height: 100%;
  8 + display: flex;
  9 + align-items: center;
  10 + justify-content: center;
  11 + }
  12 +
  13 + .item-wrapper {
2 padding: 48px 30px 54px 30px; 14 padding: 48px 30px 54px 30px;
3 border-bottom: 1px solid #e0e0e0; 15 border-bottom: 1px solid #e0e0e0;
4 16
@@ -65,6 +77,7 @@ @@ -65,6 +77,7 @@
65 letter-spacing: 0.16px; 77 letter-spacing: 0.16px;
66 display: flex; 78 display: flex;
67 align-items: center; 79 align-items: center;
  80 + }
68 81
69 .action-icon { 82 .action-icon {
70 display: inline-block; 83 display: inline-block;