Authored by 李靖

消费详情分页

... ... @@ -88,6 +88,18 @@ exports.history = (req, res, next) => {
}).catch(next);
};
exports.moreHistory = (req, res, next) => {
let params = {
uid: req.user.uid,
page: req.query.page,
shopType: req.query.shopType,
};
req.ctx(storeHomeModel).history(params).then(result => {
res.json(result);
}).catch(next);
};
exports.ewm = (req, res) => {
let responseData = {
module: 'activity',
... ...
... ... @@ -46,7 +46,7 @@ class storeHome extends global.yoho.BaseModel {
uid: params.uid,
shop_type: params.shopType,
page: params.page || 1,
limit: 10
limit: 20
},
param: {
code: 200
... ... @@ -54,29 +54,6 @@ class storeHome extends global.yoho.BaseModel {
};
return this.get(options).then(result => {
result = {
code: 200,
data: {
consume_list: [
{
trade_amount: 224,
trade_date: '2017年08月09日',
trade_title: '摄影消费'
},
{
trade_amount: 40,
trade_date: '2017年08月09日',
trade_title: '摄影消费'
}
],
page: 2,
page_total: 2,
shop_type: 3,
total: 7,
uid: 8050370
},
message: '操作成功'
};
let resu = {
list: []
};
... ...
... ... @@ -289,5 +289,6 @@ router.get('/store-home/green', auth, storeHome.green); // 线下店个人中心
router.get('/store-home/history', auth, storeHome.history); // 线下店个人中心-消费明细
router.get('/store-home/ewm', auth, storeHome.ewm); // 线下店个人中心-二维码
router.get('/store-home/coupon', auth, storeHome.coupon); // 线下店个人中心-优惠卷
router.get('/store-home/moreHistory', auth, storeHome.moreHistory); // 线下店个人中心-更多记录
module.exports = router;
... ...
... ... @@ -11,8 +11,8 @@ const isProduction = process.env.NODE_ENV === 'production';
const isTest = process.env.NODE_ENV === 'test';
const domains = {
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
api: 'http://api-test1.yohops.com:9999/',
service: 'http://service-test1.yohops.com:9999/',
singleApi: 'http://api-test1.yohops.com:9999/',
global: 'http://global-test-soa.yohops.com:9999',
liveApi: 'http://testapi.live.yohops.com:9999/',
... ...
{{# list}}
<li class="item">
<div class="tip">
<p class="name">{{title}}</p>
<p class="time">{{date}}</p>
</div>
<div class="price">¥{{amount}}</div>
</li>
{{/ list}}
\ No newline at end of file
... ...
require('activity/store-home.page.css');
import $ from 'yoho-jquery';
import Page from 'yoho-page';
import historyRender from 'activity/store-home/history.hbs';
class History extends Page {
constructor() {
super();
this.page = 1;
this.loading = false;
this.selector = {
$hisUl: $('.his-ul')
};
this.view = {
historyRender
};
this.init();
}
init() {
$(window).scroll(() => {
window.requestAnimationFrame(this.scrollHandler.bind(this));
});
}
scrollHandler() {
if (($(window).scrollTop() + $(window).height() >= $(document).height() * 0.8)) {
this.doMore();
}
}
doMore() {
if (!this.end && !this.loading) {
this.page++;
this.moreList(this.page);
}
}
moreList() {
this.loading = true;
this.ajax({
url: '/activity/store-home/moreHistory',
data: {
page: this.page,
shopType: window.queryString.shopType
},
}).then(result => {
if (result && result.list.length > 0) {
this.selector.$hisUl.append(this.view.historyRender(result));
this.loading = false;
} else {
this.end = true;
}
}).catch(error => {
console.error(error);
});
}
}
$(() => {
new History();
});
... ...