Authored by 李靖

消费记录

... ... @@ -67,7 +67,7 @@ exports.green = (req, res, next) => {
}).catch(next);
};
exports.history = (req, res) => {
exports.history = (req, res, next) => {
let responseData = {
module: 'activity',
page: 'store-history',
... ... @@ -78,7 +78,14 @@ exports.history = (req, res) => {
localCss: true,
};
res.render('store-home/history', responseData);
let params = {
uid: req.user.uid,
shopType: req.query.shopType
};
req.ctx(storeHomeModel).history(params).then(result => {
res.render('store-home/history', Object.assign(responseData, result));
}).catch(next);
};
exports.ewm = (req, res) => {
... ...
'use strict';
const camelCase = global.yoho.camelCase;
const _ = require('lodash');
class storeHome extends global.yoho.BaseModel {
constructor(ctx) {
... ... @@ -20,22 +21,83 @@ class storeHome extends global.yoho.BaseModel {
};
return this.get(options).then(result => {
let coffee = result.data.vip_type === 1;
let green = result.data.vip_type === 2;
let photography = result.data.vip_type === 3;
if (_.get(result, 'data')) {
let coffee = result.data.vip_type === 1;
let green = result.data.vip_type === 2;
let photography = result.data.vip_type === 3;
Object.assign(result.data, {
photography: photography,
coffee: coffee,
green: green,
process: this.getProcess(result.data.cousume_amount, result.data.vip_type)
});
Object.assign(result.data, {
photography: photography,
coffee: coffee,
green: green,
process: this.getProcess(result.data.cousume_amount, result.data.vip_type)
});
result = camelCase(result.data);
result = camelCase(result.data);
}
return result;
});
}
history(params) {
let options = {
data: {
method: 'extend.trade.consumelist',
uid: params.uid,
shop_type: params.shopType,
page: params.page || 1,
limit: 10
},
param: {
code: 200
}
};
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: []
};
if (_.get(result, 'data.consume_list')) {
let build = [];
_.forEach(result.data.consume_list, val => {
build.push({
amount: val.trade_amount,
date: val.trade_date,
title: val.trade_title
});
});
resu.list = build;
}
return resu;
});
}
getProcess(amount, type) {
let process = 0;
... ...
<div class="store-home">
<ul class="his-ul">
{{# list}}
<li class="item">
<div class="tip">
<p class="name">咖啡消费</p>
<p class="time">2017年7月7日</p>
<p class="name">{{title}}</p>
<p class="time">{{date}}</p>
</div>
<div class="price">¥34</div>
</li>
<li class="item">
<div class="tip">
<p class="name">咖啡消费</p>
<p class="time">2017年7月7日</p>
</div>
<div class="price">¥34</div>
</li>
<li class="item">
<div class="tip">
<p class="name">咖啡消费</p>
<p class="time">2017年7月7日</p>
</div>
<div class="price">¥34</div>
</li>
<li class="item">
<div class="tip">
<p class="name">咖啡消费</p>
<p class="time">2017年7月7日</p>
</div>
<div class="price">¥34</div>
<div class="price">¥{{amount}}</div>
</li>
{{/ list}}
</ul>
</div>
\ No newline at end of file
... ...
... ... @@ -23,7 +23,7 @@
<ul class="info-list">
<li>
<div class="left">消费金额</div>
<a class="right" href="//m.yohobuy.com/activity/store-home/history">¥{{cousumeAmount}}
<a class="right" href="//m.yohobuy.com/activity/store-home/history?shopType={{vipType}}">¥{{cousumeAmount}}
<span class="iconfont">&#xe604;</span>
</a>
</li>
... ...
... ... @@ -351,6 +351,7 @@ input::-webkit-calendar-picker-indicator {
.name {
font-size: 26px;
line-height: 50px;
height: 50px;
}
.time {
... ...