Index.js
4.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
'use strict';
const Promise = require('bluebird');
const co = Promise.coroutine;
class IndexModel extends global.mClass {
getPendingOrderCount($uid) {
let options = {
method: 'web.SpaceOrders.getPendingOrderCount',
uid: $uid
};
return this.API.get('', options);
}
infoNum($uid, $udid) {
let options = {
method: 'app.home.getInfoNum',
uid: $uid,
udid: $udid
};
return this.API.get('', options);
}
notCommentRecordCount($uid) {
let options = {
method: 'show.notCommentRecordCount',
uid: $uid
};
return this.API.get('', options);
}
getInfoNumData($uid, $udid) {
var that = this;
let $result = [
{href: this.helpers.urlFormat('/home/orders'), name: '待处理订单', 'count': 0},
{href: this.helpers.urlFormat('/home/message'), name: '未读消息', 'count': 0},
{href: this.helpers.urlFormat('/home/comment'), name: '待评论商品', 'count': 0}
];
return co(function * () {
let $getPendingOrderCount = yield that.getPendingOrderCount($uid);// 待处理订单
let $infoNumData = yield that.infoNum($uid, $udid); // 未读消息
let $notCommentRecordCount = yield that.notCommentRecordCount($uid);// 待评论商品
$result[0]['count'] = $getPendingOrderCount.data.count ? $getPendingOrderCount.data.count : 0;
$result[1]['count'] = $infoNumData.data.inbox_total ? $infoNumData.data.inbox_total : 0;
$result[2]['count'] = $notCommentRecordCount.data ? $notCommentRecordCount.data : 0;
return $result;
})();
}
getFooterBanner($code) {
$code = $code || '20110609-152143';
}
// getBrandListUrl(){
// return this.SearchAPI.get('/yohosearch/brand/list.json', {},{cache:true});
// }
// getProductUrl($condition, $type = ''){
// let $orderMaps={
// s_t_desc:'shelve_time:desc',
// s_t_asc:'shelve_time:asc',
// s_p_asc:'sales_price:asc',
// s_p_desc:'sales_price:desc',
// p_d_desc:'discount:desc',
// p_d_asc:'discount:asc',
// skn_desc:'product_skn:desc',
// skn_asc:'product_skn:asc',
// activities_desc:'activities.order_by:desc',
// activities_asc:'activities.order_by:asc',
// s_n_asc:'sales_num:asc',
// s_n_desc:'sales_num:desc',
// activities_id_desc:'activities.activity_id:desc',
// activities_id_asc:'activities.activity_id:asc',
// brand_desc:'brand_weight:desc'
// }
// $param={
// status:1,
// sales:'Y',
// outlets:2,
// stocknumber:1,
// attribute_not:2
// };
// if(!$condition.order){
// $param.order=$orderMaps.s_t_desc;
// }else{
// $param.order=$orderMaps[$condition.order]?$orderMaps[$condition.order]:'';
// }
// if(!$condition.page){
// $param.page=1;
// }
// if(!$condition.viewNum){
// $param.viewNum=$condition.viewNum;
// }else if(!$condition.limit){
// $param.viewNum=60;
// }else{
// $param.viewNum=$condition.limit;
// delete $condition.limit;
// }
// if(!$condition){
// $param += $condition;
// }
// return this.SearchAPI.get($type, $param,{cache:true});
// }
// formatFavBrand($brandInfo, $i = 10){
// $hotBrands=[];
// if($brandInfo){
// $brandInfo.forEach(function($value){
// if ($value.is_hot && $value.is_hot == 'Y') {
// $hotBrands.push({
// 'href' : Helpers::url('', '', $value['brand_domain']),
// 'logo' : Images::getSourceUrl($value['brand_ico'], 'brandLogo'),
// 'name' : $value.brand_name,
// });
// }
// });
// }
// return $hotBrands;
// }
// homeData(){
// let that=this;
// return co(function * (){
// let $result = {};
// let $url={};
// $url.fav_brand =yield that.getBrandListUrl();
// $url.new=yield that.getProductUrl({new:'Y',viewNum:10});
// console.log($url);
// return $url;
// // $result.brand=$data.fav_brand&&!$data.fav_brand?
// }();
// }
}
module.exports = IndexModel;