Authored by zhangxiaoru

优惠详情页数据

... ... @@ -17,24 +17,37 @@ exports.index = (req, res, next) => {
}).catch(next);
};
exports.detail = (req, res) => {
// let uid = req.user.uid;
res.render('share-buy/share-detail', {
localCss: true,
width750: true,
title: '分享购',
page: 'share-detail'
});
exports.detail = (req, res, next) => {
let uid = req.user.uid,
param = {
counum: req.query.counum,
couponType: req.query.couponType,
detailDes: req.query.detailDes,
couponId: 12301 // req.query.couponId;
};
req.ctx(shareBuyModel).shareDetail(uid, param).then(data => {
res.render('share-buy/share-detail', {
localCss: true,
width750: true,
title: '分享购',
page: 'share-detail',
detailData: data
});
}).catch(next);
};
exports.myRebeat = (req, res) => {
// let uid = req.user.uid;
// req.ctx(shareBuyModel).myRebeat(uid).then(data => {
res.render('share-buy/my-rebeat', {
localCss: true,
width750: true,
title: '我的返利收益',
page: 'my-rebeat'
});
// }).catch(next);
};
... ...
const api = global.yoho.API;
const _ = require('lodash');
const helpers = global.yoho.helpers;
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
/**
* 首页数据
*/
shareIndex(activityId) {
return api.all([this._CouponInfo(activityId), this._redeatList()]).then(result => {
... ... @@ -15,13 +19,27 @@ module.exports = class extends global.yoho.BaseModel {
if (result[0] && result[0].data && result[0].data.userCouponBoList) {
_.forEach(result[0].data.userCouponBoList, function(val) {
if (val.sortNames) {
val.couponDescribe = '限' + val.sortNames + '使用';
val.detailDes = '限品类: ' + val.sortNames;
} else if (val.brandNames) {
val.couponDescribe = '限' + val.brandNames + '使用';
val.detailDes = '限品牌: ' + val.brandNames;
} else if (val.shareCoupon === '全场通用') {
val.couponDescribe = '任意商品使用';
val.detailDes = val.shareCoupon;
} else if (val.shopNames) {
val.couponDescribe = '限' + val.shopNames + '使用';
val.detailDes = val.shareCoupon;
}
val.detailUrl = helpers.urlFormat('/activity/share-buy/detail', {
counum: val.couponValue,
couponType: val.shareCouponType,
detailDes: val.detailDes,
couponId: val.couponId
});
});
indexData.userCouponBoList = result[0].data.userCouponBoList;
... ... @@ -49,7 +67,9 @@ module.exports = class extends global.yoho.BaseModel {
}, {
code: 200
}).then((result) => {
return result;
if (result && result.code === 200 && result.data) {
return result;
}
});
}
... ... @@ -60,9 +80,62 @@ module.exports = class extends global.yoho.BaseModel {
return api.get('', {
method: 'app.yohocoinrebeat.lastedlist'
}, {
code: 200,
cache: true
}).then((result) => {
if (result && result.code === 200 && result.data) {
return result;
}
});
}
/**
* 优惠详情页数据
*/
shareDetail(uid, param) {
return api.get('', {
method: 'app.activity.getActivityCouponCode',
uid: uid,
coupon_id: param.couponId
}, {
code: 200
}).then((result) => {
return result;
if (result && result.code === 200 && result.data) {
result.data = _.assign(result.data, param);
result.data.moreUrl = helpers.urlFormat('', {
coupon_code: result.data.couponCode,
coupon_id: param.couponId,
title: '优惠活动商品'
}, 'list');
return result.data;
} else {
return {};
}
});
}
/**
* 我的返利页数据
*/
// myRebeat(uid) {
// return api.get('', {
// method: 'app.yohocoinrebeat.detail',
// uid: uid
// }, {
// code: 200
// }).then((result) => {
// if (result && result.code === 200 && result.data) {
// return result.data;
// } else {
// return {};
// }
// });
// }
};
... ...
... ... @@ -241,7 +241,7 @@ router.get('/app-downloads', appDownloads.index);
router.get('/couponSend', couponFloor.couponSend); // 获取优惠券
router.get('/share-buy', shareBuy.index); // 分享购首页
router.get('/share-buy/detail', shareBuy.detail); // 分享购详情页
router.get('/share-buy/my-rebeat', shareBuy.myRebeat); // 我的返利
router.get('/share-buy/detail', auth, shareBuy.detail); // 分享购详情页
router.get('/share-buy/my-rebeat', auth, shareBuy.myRebeat); // 我的返利
module.exports = router;
... ...
... ... @@ -12,7 +12,7 @@
<p class="coupon-type">{{shareCouponType}}</p>
</div>
<div class="coupon-right">
<span>立即参与</span>
<a href="{{detailUrl}}">立即参与</a>
<p class="coupon-mold">{{shareCoupon}}</p>
<p class="coupon-limit">{{couponDescribe}}</p>
</div>
... ...
<div class="share-detail-page">
{{# detailData}}
<div class="coupon-detail">
<div class="countdown">
<div class="title">距离活动时间还剩:</div>
<div class="activity-time">
<div class="activity-time" data-id="{{expiredTime}}">
<span></span>
<span></span>
<span></span>
... ... @@ -14,22 +15,22 @@
</div>
</div>
<div class="coupon-info">
<div class="coupon-info" data-id="{{couponId}}">
<div class="info-top">
<div class="coupon-money">
<i class="iconfont"></i>
<span>50</span>
<span>{{counum}}</span>
</div>
<span class="coupon-code">fhewlfhwefh</span>
<span class="coupon-code">{{couponCode}}</span>
<span class="copy">复制</span>
<p class="share-way">(券码可直接分享给好友)
<span class="coupon-type">现金券<span>
<span class="coupon-type">{{couponType}}<span>
</p>
</div>
<div class="info-bottom">
<span class="share-coupon">全场通用</span>
<span class="share-coupon">{{detailDes}}</span>
<span class="coupon-tip">特列商品(秒杀、限定、境外、预售等)暂不支持使用优惠券。</span>
<span class="validity">有效期</span>
<span class="validity">有效期: {{couponValidity}}</span>
</div>
<p class="use-way">
... ... @@ -43,7 +44,10 @@
<div class="commodity">
<p class="title">
<span>优惠券可适用于以下产品</span>
<span class="more">更多商品<i class="iconfont">&#xe614;</i></span>
<a class="more" href="{{moreUrl}}">更多商品<i class="iconfont">&#xe614;</i></a>
</p>
<div class="goods-container"></div>
</div>
{{/ detailData}}
</div>
... ...
... ... @@ -3,7 +3,12 @@
let $ = require('yoho-jquery');
let $activityTime = $('.activity-time'),
endTime = $activityTime ? $activityTime.data('time-s') : '';
endTime = $activityTime ? $activityTime.data('time-s') : '',
$container = $('.goods-container');
let winH = $(window).height(),
page = 1,
onloading = false; // 是否正在加载商品数据
let params = {
anHour: 3600, // 1小时=?秒
... ... @@ -13,6 +18,8 @@ let params = {
endTime: [endTime] // 时间差数组
};
let noResultHbs = require('product/search/no-result-new.hbs');
require('activity/share-detail.page.css');
function division(time) {
... ... @@ -73,18 +80,59 @@ function startCountDown(p) {
}, 1000);
}
$.ajax({
type: 'GET',
url: '/product/sale/discount/getTime',
data: {
id: 3919
},
success: function(data) {
if (data) {
startCountDown({
endTime: [data]
});
}
if ($activityTime.data('id')) {
startCountDown({
endTime: [$activityTime.data('id')]
});
}
function productData() {
if (!onloading) {
onloading = true;
$.ajax({
type: 'GET',
url: location.protocol + '//m.yohobuy.com/product/search/search',
data: {
coupon_id: $('.coupon-info').data('id'),
type: 'default',
order: 0,
page: page,
noLazy: true
},
xhrFields: {
withCredentials: true
},
success: function(data) {
if (data === '' || (data.list && data.list.length <= 0)) {
$container.html(noResultHbs());
} else {
$container.append(data);
}
onloading = false;
}
});
}
page = page + 1;
}
function scrollHandler() {
// 当scroll到1/2$goodsContainer高度后继续请求下一页数据
if ($(window).scrollTop() + winH >
$(document).height() - 0.5 * $container.height()) {
productData();
}
}
$(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
});
$(function() {
productData();
});
... ...
... ... @@ -60,12 +60,12 @@
i {
display: inline-block;
width: 90px;
height: 27px;
height: 29px;
background-color: #b0b0b0;
color: #fff;
font-size: 22px;
font-size: 18px;
border-radius: 10px;
line-height: 27px;
line-height: 29px;
text-align: center;
}
... ...
... ... @@ -66,7 +66,7 @@
line-height: 40px;
}
span {
a {
float: right;
margin: 55px 35px 0 0;
display: block;
... ...
... ... @@ -68,6 +68,7 @@
line-height: 40px;
text-align: center;
border-radius: 5px;
margin-left: 5px;
}
.share-way {
... ...
@import "share-buy/share-detail";
@import "common/good";
... ...