Authored by lea guo

发现好货

const FindGoods = require('../models/find-goods');
const _ = require('lodash');
const stringProcess = require('../../../utils/string-process');
exports.index = function(req, res, next) {
let qcdn = _.get(req.app.locals, 'wap.qcloud_cdn');
const {page = 1} = req.query || {};
req.ctx(FindGoods).findGoods({page}).then((result)=> {
if (!result) {
return next();
}
const title = stringProcess.paramsFilter(req.query.title) || '发现好货';
const shareId = _.parseInt(stringProcess.paramsFilter(req.query.share_id));
// 唤起 APP 的路径
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"}}`;
const jsSdk = global.yoho.config.jsSdk;
console.log('---------result---------', result);
res.render('find-goods/index', {
module: 'activity',
page: 'find-goods',
title: title,
content: result.data,
isFeature: true,
wechatShare: true,
localCss: true,
loadJs: [{
src: qcdn ? jsSdk.replace(/\/\/cdn.yoho.cn/gi, '//qcdn.yoho.cn') : jsSdk
}]
});
}).then().catch(next);
};
... ...
/**
* 发现好货商品列表
*/
module.exports = class FindGoods extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
/**
*
* @param {*} {uid, page, limit}
*/
findGoods(params) {
console.log('----------find goods api----------');
return this.get({
data: Object.assign({
method: 'app.grass.findGrassGoods'
}, params)
});
}
};
... ...
... ... @@ -78,6 +78,8 @@ const yoluckBack = require(`${cRoot}/yoluck-back`);
const group = require(`${cRoot}/group`);
// 发现好货
const FindGoods = require('./controllers/find-goods');
// routers
... ... @@ -136,15 +138,22 @@ router.get('/raffle/enter', raffle.enter); // 微信免单抽奖活动入口页
router.post('/raffle/lucky', raffle.lucky); // 微信免单抽奖按钮
router.get('/raffle/bind', raffle.bind); // 送有货币
router.get(/\/invite\/share_([\d]+)_([\d]+)_([\d]+).html/, invite.checkType, invite.share);
router.get(
/\/invite\/share_([\d]+)_([\d]+)_([\d]+).html/,
invite.checkType,
invite.share,
);
router.get('/invite/sendRegCodeToMobile', invite.sendRegCodeToMobile);
router.get('/invite/checkOldUserCoupon', invite.checkOldUserCoupon);
router.get('/invite/validRegCode', invite.validRegCode);
router.get('/invite/register', invite.register);
router.get('/invite/receiveCoupons', invite.receiveCoupons);
router.get(/\/invite\/mycoupons_([\d]+)_([\d]+)_([\d]+)_([\d]+).html/,
invite.checkType, invite.myCoupons); // 好友领取完优惠券的页面
router.get(
/\/invite\/mycoupons_([\d]+)_([\d]+)_([\d]+)_([\d]+).html/,
invite.checkType,
invite.myCoupons,
); // 好友领取完优惠券的页面
router.get('/invite/getwxinfo', invite.getwxinfo);
router.get('/invite/shareover', invite.shareover);
router.get('/invite/over', invite.over);
... ... @@ -153,9 +162,21 @@ router.get('/vip-day', vipDay.index);
// 涉嫌博彩,要求下线 180129
// router.get('/vip-day/crazy-wheel', vipDay.beforeIn, vipDay.crazyWheel);
router.post('/vip-day/crazy-wheel/award.json', vipDay.beforeIn, vipDay.wheelResult);
router.post('/vip-day/crazy-luck/award.json', vipDay.beforeIn, vipDay.luckResult);
router.get('/vip-day/crazy-luck/award-list.json', vipDay.beforeIn, vipDay.luckResultCollect);
router.post(
'/vip-day/crazy-wheel/award.json',
vipDay.beforeIn,
vipDay.wheelResult,
);
router.post(
'/vip-day/crazy-luck/award.json',
vipDay.beforeIn,
vipDay.luckResult,
);
router.get(
'/vip-day/crazy-luck/award-list.json',
vipDay.beforeIn,
vipDay.luckResultCollect,
);
// 涉嫌博彩,要求下线 180129
// router.get('/vip-day/crazy-luck', vipDay.beforeIn, vipDay.crazyLuck);
... ... @@ -180,14 +201,30 @@ router.get('/vip-day1028', vipDay1028.index);
// 涉嫌博彩,要求下线 180129
// router.get('/vip-day1028/crazy-wheel', vipDay1028.beforeIn, vipDay1028.crazyWheel);
router.post('/vip-day1028/crazy-wheel/award.json', vipDay1028.beforeIn, vipDay1028.wheelResult);
router.post('/vip-day1028/crazy-luck/award.json', vipDay1028.beforeIn, vipDay1028.luckResult);
router.get('/vip-day1028/crazy-luck/award-list.json', vipDay1028.beforeIn, vipDay1028.luckResultCollect);
router.post(
'/vip-day1028/crazy-wheel/award.json',
vipDay1028.beforeIn,
vipDay1028.wheelResult,
);
router.post(
'/vip-day1028/crazy-luck/award.json',
vipDay1028.beforeIn,
vipDay1028.luckResult,
);
router.get(
'/vip-day1028/crazy-luck/award-list.json',
vipDay1028.beforeIn,
vipDay1028.luckResultCollect,
);
// 涉嫌博彩,要求下线 180129
// router.get('/vip-day1028/crazy-luck', vipDay1028.beforeIn, vipDay1028.crazyLuck);
router.post('/vip-day1028/signin.json', vipDay1028.beforeIn, vipDay1028.signin);
router.post('/vip-day1028/isStudent', vipDay1028.beforeIn, vipDay1028.checkIsStudent);
router.post(
'/vip-day1028/isStudent',
vipDay1028.beforeIn,
vipDay1028.checkIsStudent,
);
// 阿里云广告
router.get('/ali-cloud-bottom', aliCloud.aliCloudbo);
... ... @@ -327,14 +364,38 @@ router.get('/free-mail/list', auth, freeMail.freeMailList); // 免邮券列表
router.get('/free-mail/verify', auth, freeMail.receiveVerify); // 免邮券领取验证
router.get('/free-mail/verifyCoupon', auth, freeMail.receiveCoupon); // 免邮券领取
router.get('/store-home/photography', disableBFCache, storeHome.storeAuth, storeHome.photography); // 线下店个人中心-摄影
router.get('/store-home/coffee', disableBFCache, storeHome.storeAuth, storeHome.coffee); // 线下店个人中心-咖啡
router.get('/store-home/green', disableBFCache, storeHome.storeAuth, storeHome.green); // 线下店个人中心-绿植
router.get('/store-home/gallery', disableBFCache, storeHome.storeAuth, storeHome.gallery); // 线下店个人中心-画廊
router.get(
'/store-home/photography',
disableBFCache,
storeHome.storeAuth,
storeHome.photography,
); // 线下店个人中心-摄影
router.get(
'/store-home/coffee',
disableBFCache,
storeHome.storeAuth,
storeHome.coffee,
); // 线下店个人中心-咖啡
router.get(
'/store-home/green',
disableBFCache,
storeHome.storeAuth,
storeHome.green,
); // 线下店个人中心-绿植
router.get(
'/store-home/gallery',
disableBFCache,
storeHome.storeAuth,
storeHome.gallery,
); // 线下店个人中心-画廊
router.get('/store-home/history', storeHome.storeAuth, storeHome.history); // 线下店个人中心-消费明细
router.get('/store-home/ewm', storeHome.storeAuth, storeHome.ewm); // 线下店个人中心-二维码
router.get('/store-home/coupon', storeHome.storeAuth, storeHome.coupon); // 线下店个人中心-优惠券
router.get('/store-home/moreHistory', storeHome.storeAuth, storeHome.moreHistory); // 线下店个人中心-更多记录
router.get(
'/store-home/moreHistory',
storeHome.storeAuth,
storeHome.moreHistory,
); // 线下店个人中心-更多记录
router.get('/store-home/modify', storeHome.storeAuth, storeHome.modify); // 线下店个人中心-修改宝宝信息
router.get('/coupon-list', auth, couponList.index); // 优惠券领取页
... ... @@ -375,12 +436,23 @@ function swtichYoLuck(newMiddleware, oldMiddleware) {
// yoluck
router.get('/yoluck/index.html', swtichYoLuck(yoluck.index, yoluckBack.index));
router.get('/yoluck/mylist.html', auth, swtichYoLuck(yoluck.index, yoluckBack.index));
router.get(
'/yoluck/mylist.html',
auth,
swtichYoLuck(yoluck.index, yoluckBack.index),
);
router.get('/yoluck/next', swtichYoLuck(yoluck.nextPage, yoluckBack.nextPage));
router.get('/yoluck/:id.html', swtichYoLuck(yoluck.detail, yoluckBack.detail));
router.post('/yoluck/:id.html', auth, swtichYoLuck(yoluck.getCode, yoluckBack.getCode));
router.post('/yoluck/detail/mylist.html', swtichYoLuck(yoluck.getActivityCodeList, yoluckBack.getActivityCodeList));
router.post(
'/yoluck/:id.html',
auth,
swtichYoLuck(yoluck.getCode, yoluckBack.getCode),
);
router.post(
'/yoluck/detail/mylist.html',
swtichYoLuck(yoluck.getActivityCodeList, yoluckBack.getActivityCodeList),
);
// 拼团
// router.get('/group', group.index); // 拼团首页
... ... @@ -399,4 +471,7 @@ router.get('/group/delOrder', auth, group.delOrder); // 删除拼团订单
router.get('/group/cancelOrder', auth, group.cancelOrder); // 取消拼团订单
router.get('/group/loadOrder', auth, group.loadOrder); // 加载拼团列表
// 发现好货
router.get('/find/goods', FindGoods.index);
module.exports = router;
... ...
<div class="find-goods-wrapper">
发现好货
{{log content}}
{{#unless content.detailList}}
<div class="empty">
暂无数据
</div>
{{else}}
{{#content.detailList}}
{{> find-goods/item-info}}
{{/content.detailList}}
{{/unless}}
</div>
\ No newline at end of file
... ...
<div class="item-wrapper">
<div class="author-info">
<img class="avatar-img" src="{{image2 authorHeadIco w=30 h=30}}" alt="" />
<span class="avatar-name">{{authorName}}</span>
</div>
<a class="item-info">
<img src="{{image2 findGood.productImage w=120 h=120}}" alt="" />
<div class="item-detail">
<div>
<div class="item-name">{{findGood.productName}}</div>
<div class="item-desc">{{content}}</div>
</div>
<div class="action-tip">
<span class="action-name">SHOP NOW</span>
<span class="action-icon"></span>
</div>
</div>
</a>
</div>
\ No newline at end of file
... ...
// const $ = require('yoho-jquery');
// const lazyLoad = require('js/plugin/lazyload');
require('scss/activity/find-goods.page.scss');
... ...
.item-wrapper {
padding: 48px 30px 54px 30px;
border-bottom: 1px solid #e0e0e0;
&:last-child {
border-bottom: 0;
}
.author-info {
display: flex;
align-items: center;
.avatar-img {
border-radius: 50%;
}
.avatar-name {
font-size: 24px;
color: rgba(153, 153, 153, 0.85);
letter-spacing: 0.08px;
line-height: 13px;
padding-left: 16px;
}
}
.item-info {
display: flex;
margin-top: 30px;
max-height: 240px;
overflow: hidden;
.item-detail {
display: flex;
flex-direction: column;
flex: 1;
margin-left: 38px;
justify-content: space-between;
.item-name {
font-size: 28px;
letter-spacing: 0.18px;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
max-height: 92px;
}
.item-desc {
font-size: 22px;
color: #b0b0b0;
letter-spacing: 0;
max-height: 64px;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
overflow: hidden;
-webkit-box-orient: vertical;
margin-top: 10px;
}
.action-tip {
font-size: 24px;
letter-spacing: 0.16px;
display: flex;
align-items: center;
.action-icon {
display: inline-block;
width: 32px;
height: 32px;
background: url("img/activity/find-goods-more@3x.png");
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
}
}
}
}
... ...
module.exports = {
context: './js',
regx: ['activity/feature.page.js']
regx: ['activity/feature.page.js', 'activity/find-goods.page.js']
};
... ...