shop-service.js
970 Bytes
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
/**
* Created by TaoHuang on 2016/6/28.
*/
'use strict';
const Promise = require('bluebird');
const co = Promise.coroutine;
const _ = require('lodash');
const Api = require('./shop-api');
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
this.api = new Api(ctx);
}
getShopBannerAsync(shopId) {
return this.api.shopBannerAsync(shopId).then((result) => {
if (result.code === 200) {
return _.includes(result.data.banner, DEFAULT_IMG) ? '' : result.data.banner;
} else {
return null;
}
});
};
queryShopByBrandIdAsync(sid, bid) {
return co(function * () {
let result = yield this.api.queryShopsByBrandId(sid, bid);
if (_.get(result, 'code') !== 200) {
return false;
}
return _.get(result, 'data[0]', {});
}).bind(this)();
}
};