Authored by zhangxiaoru

yohocoin

'use strict';
const headerModel = require('../../../doraemon/models/header'); // 头部model
const index = (req, res) => {
res.render('coupons', {
module: 'home',
page: 'coupons',
pageHeader: headerModel.setNav({
navTitle: '优惠券'
}),
title: '优惠券',
pageFooter: true,
});
};
const couponData = (req, res) => {
};
module.exports = {
index,
couponData
};
... ...
... ... @@ -92,21 +92,28 @@ exports.record = (req, res) => {
};
exports.recordContent = (req, res, next) => {
let uid = req.user.uid || 6228593; // TODO
let uid = req.user.uid;
let udid = req.user.udid;
let page = req.query.page || 1;
let limit = 10;
let limit = 30;
indexModel.recordContent(uid, udid, page, limit).then((result) => {
res.render('browse-record-content', result);
if (result.browseRecord && result.browseRecord.length === 0) {
res.json(false);
} else {
res.render('browse-record-content', Object.assign({
layout: false
}, result));
}
}).catch(next);
};
exports.delRecord = (req, res, next) => {
let uid = req.user.uid || 6228593; // TODO
let uid = req.user.uid;
let skn = req.user.skn || 0;
... ...
... ... @@ -154,47 +154,49 @@ const recordContent = (uid, udid, page, limit) => {
return api.get('', {
method: 'app.browse.product',
uid: uid || 6228593, // TODO
uid: uid,
limit: limit,
page: page
}, {code: 200}).then((result) => {
let resu = {
browseRecord: []
};
let resu = {};
if (result && result.code === 200) {
let list = result;
// 不能再查到结果了
if (page > 1 && list === []) {
if (!result || page === '1' && result.data.total === 0) {
resu.walkwayUrl = helpers.urlFormat('/product/new');
resu.noRecord = true;
}
if (result.data.total === 0) {
resu.total = 0;
return resu;
}
_.forEach(list.data.product_list, function(val) {
let obj = {
productList: []
if (list.data && list.data.product_list) {
resu = {
browseRecord: []
};
obj = _.assign(obj, {
product_name: val.product_name,
product_skn: val.product_skn,
storage: val.storage,
image: val.image,
link: '/product/show_' + val.product_skn + '.html',
sales_price: val.sales_price,
market_price: (val.market_price - val.sales_price) > 0 ? val.market_price : false,
invalidGoods: val.status === 0
_.forEach(list.data.product_list, function(val) {
let obj = {
productList: []
};
obj = _.assign(obj, {
product_name: val.product_name,
product_skn: val.product_skn,
storage: val.storage,
image: val.image,
link: '/product/show_' + val.product_skn + '.html',
sales_price: val.sales_price,
market_price: (val.market_price - val.sales_price) > 0 ? val.market_price : false,
invalidGoods: val.status === 0
});
resu.browseRecord.push(obj);
});
}
resu.browseRecord.push(obj);
});
return resu;
}
});
... ...
... ... @@ -17,6 +17,7 @@ const favorite = require(`${cRoot}/favorite`);
const orderController = require(`${cRoot}/order`);
const orderDetailController = require(`${cRoot}/orderDetail`);
const currencyController = require(`${cRoot}/myCurrency`);
const coupons = require(`${cRoot}/coupons`);
// const myDetail = require(`${cRoot}/myDetail);
... ... @@ -63,4 +64,8 @@ router.get('/favBrand', favorite.favfavBrand);
// 取消收藏
router.post('/favoriteDel', favorite.favoriteDelete);
// 优惠券
router.get('/coupons', coupons.index);
router.post('/couponData', coupons.couponData);
module.exports = router;
... ...
<div class="yoho-page my-coupon-page">
<div class="employ">
<span class="active">未使用</span>
<span>已使用</span>
</div>
<div id="employ" class="coupon-list"></div>
</div>
\ No newline at end of file
... ...
... ... @@ -45,9 +45,8 @@ function moreRecord(cb) {
page: page + 1
},
success: function(data) {
if (data === ' ') {
if (!data) {
end = true;
$more.addClass('hide');
$noMore.removeClass('hide');
} else {
... ...
var $ = require('yoho-jquery'),
Hammer = require('yoho-hammer'),
ellipsis = require('yoho-mlellipsis'),
loading = require('../plugin/loading');
var employ,
statu = 0,
page = 1;
ellipsis.init();
function couponAJAX(statu, page) {
return;
loading.showLoadingMask();
$.ajax({
type: 'POST',
url: '/home/couponData',
dataType: 'html',
data: {
status: statu,
page: page
},
success: function(data) {
$('#employ').append(data);
window.rePosFooter();
loading.hideLoadingMask();
}
});
}
$('.yoho-footer').css('border-top', '1px solid #e0e0e0');
$('.employ span').each(function(index) {
employ = new Hammer($('.employ span')[index]);
employ.on('tap', function(e) {
$('.employ span').removeClass('active').eq(index).addClass('active');
$('#employ').html(' ');
statu = index;
page = 1;
couponAJAX(statu, page);
window.rePosFooter();
});
});
function scrollHandler() {
if ($(window).scrollTop() + $(window).height() > $('body').height() - 100) {
page++;
couponAJAX(statu, page);
return;
}
}
$(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
});
couponAJAX(statu, page);
... ...
... ... @@ -2,3 +2,4 @@
@import "favorite";
@import "address/index";
@import "favorite";
@import "coupons";
... ...
... ... @@ -35,7 +35,7 @@
.sale-price {
color: #f00;
&.original-price {
color: #000;
}
... ... @@ -80,13 +80,13 @@
background: #fff;
text-align: center;
top: 50%;
margin-top: -220px;
margin-top: 200px;
width: 100%;
.icon {
width: 196px;
height: 207px;
background: resolve('me/no-record.png') no-repeat;
background: resolve("me/no-record.png") no-repeat;
background-size: 100%;
margin: 0 auto;
}
... ...
... ... @@ -2,7 +2,6 @@
@import "vip-grade";
@import "order";
@import "order-detail";
@import "coupons";
@import "personal-details";
@import "yoho-coin";
@import "fav";
... ...