|
|
'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;
|
|
|
|
...
|
...
|
|