Authored by 郝肖肖

'ctx-fix'

const api = global.yoho.API;
const _ = require('lodash');
const helpers = global.yoho.helpers;
const utils = '../../../utils';
const productProcess = require(`${utils}/product-process`);
const service = global.yoho.ServiceAPI;
const serviceAPI = global.yoho.ServiceAPI;
const co = require('bluebird').coroutine;
module.exports = class extends global.yoho.BaseModel {
... ... @@ -15,11 +14,14 @@ module.exports = class extends global.yoho.BaseModel {
* 我的邀请码页
*/
_getPromotionData(uid, isApp) {
return api.get('', {
return this.get({
data: {
method: 'app.invitecode.my',
uid: uid
}, {
},
param: {
code: 200
}
}).then((result) => {
if (result && result.code === 200 && result.data) {
... ... @@ -39,11 +41,16 @@ module.exports = class extends global.yoho.BaseModel {
* 资源位
*/
_getTrendPop(contentCode) {
return service.get('operations/api/v5/resource/get', {
return this.get({
api: serviceAPI,
url: 'operations/api/v5/resource/get',
data: {
content_code: contentCode,
}, {
},
param: {
code: 200,
cache: true
}
}).then(result => {
if (result && result.code === 200 && result.data) {
return result.data[0];
... ... @@ -54,7 +61,7 @@ module.exports = class extends global.yoho.BaseModel {
}
promotionData(uid, isApp, contentCode) {
return api.all([this._getPromotionData(uid, isApp), this._getTrendPop(contentCode)]).then(result => {
return Promise.all([this._getPromotionData(uid, isApp), this._getTrendPop(contentCode)]).then(result => {
let friendPromotionData = {};
friendPromotionData = Object.assign(friendPromotionData, result[0]);
... ... @@ -68,11 +75,13 @@ module.exports = class extends global.yoho.BaseModel {
* 奖励列表页
*/
rewardList(uid, page, limit, isApp) {
return api.get('', {
return this.get({
data: {
method: 'app.invitecode.history',
uid: uid,
page: page,
limit: limit
}
}).then((result) => {
if (result && result.code === 200 && result.data) {
... ... @@ -110,10 +119,12 @@ module.exports = class extends global.yoho.BaseModel {
* 奖励详情页
*/
rewardDeatil(uid, firstOrderUid) {
return api.get('', {
return this.get({
data: {
method: 'app.invitecode.detail',
uid: uid,
firstOrderUid: firstOrderUid
}
}).then((result) => {
if (result && result.code === 200) {
... ... @@ -130,13 +141,12 @@ module.exports = class extends global.yoho.BaseModel {
* 设置我的潮流口令
*/
setTrendWord(uid, trendWord) {
return api.get('', {
return this.get({
data: {
method: 'app.trendword.update',
uid: uid,
trendWord: trendWord
}).then((result) => {
return result;
}
});
}
... ... @@ -144,11 +154,13 @@ module.exports = class extends global.yoho.BaseModel {
* 好友邀请商品
*/
_hotGoods(yhChannel, limit, page) {
return api.get('', {
return this.get({
data: {
method: 'app.search.top',
yh_channel: yhChannel,
page: page,
limit: limit
}
}).then((result) => {
if (result && result.code === 200) {
... ... @@ -163,19 +175,20 @@ module.exports = class extends global.yoho.BaseModel {
* 好友邀请信息
*/
inviteUserInfo(inviteCode) {
return api.get('', {
return this.get({
data: {
method: 'app.invitecode.userinfo',
inviteCode: inviteCode
}).then((result) => {
return result;
}
});
}
_getProductList(skns) {
return api.get('', {
return this.get({
data: {
method: 'app.search.li',
query: skns
}
}).then((result) => {
if (result && result.code === 200) {
return result.data;
... ... @@ -199,9 +212,12 @@ module.exports = class extends global.yoho.BaseModel {
if (!token) {
return Promise.resolve({});
}
return api.get('', {
return this.get({
data: {
method: 'app.SpaceOrders.getProductList',
order_token: token
}
}).then((result) => {
let self = this;
... ... @@ -247,7 +263,7 @@ module.exports = class extends global.yoho.BaseModel {
* 好友邀请页
*/
friendInvite(inciteCode, yhChannel, limit, page, contentCode, token) {
return api.all([
return Promise.all([
this.inviteUserInfo(inciteCode),
this._hotGoods(yhChannel, limit, page),
this._getTrendPop(contentCode),
... ... @@ -272,11 +288,14 @@ module.exports = class extends global.yoho.BaseModel {
}
reloadQrcode(uid) {
return api.get('', {
return this.get({
data: {
method: 'app.invitecode.my',
uid: uid
}, {
},
param: {
code: 200
}
}).then((result) => {
if (result && result.code === 200 && result.data) {
... ...
'use strict';
const _ = require('lodash');
const api = global.yoho.API;
const helpers = global.yoho.helpers;
const _getProductBySkns = function(productObj, extraParams) {
return api.get('', {
return this.get({
data: {
productSkn: productObj.defaultSkns,
method: 'h5.product.batch'
}, {
},
param: {
cache: true
}
}).then((result) => {
productObj.defaultPros = [];
if (result && result.data && result.data.product_list && result.code === 200) {
... ... @@ -40,9 +42,11 @@ const _getProductBySkns = function(productObj, extraParams) {
* 获取店铺组店铺数据
*/
const _getShopGroup = (shopRawData) => {
return api.get('', {
return this.get({
data: {
method: 'app.shops.batchGetShops',
shop_ids: shopRawData.defaultShopIds
}
}).then(result => {
let renderData = _.get(result, 'data', []);
... ... @@ -72,16 +76,25 @@ class featureModel extends global.yoho.BaseModel {
let shopGroups = [];
if (params.type === 'preview') { // 开发/预览模式
data = yield api.get('', {
data = yield this.get({
data: {
method: 'app.activity.template.ignoreCache',
activity_id: params.code
},
param: {
cache: true
}
});
} else {
data = yield api.get('', { // 生产模式
// 生产模式
data = yield this.get({
data: {
method: 'app.activity.template',
activity_id: params.code
}, {
},
param: {
cache: true
}
});
}
if (!data) {
... ...
... ... @@ -118,10 +118,6 @@ exports.getGoods = cate => {
}
});
// console.log(data.goods1.length)
// console.log(data.goods2.length)
// console.log(data.goods3.length)
return {
code: 200,
data
... ...
... ... @@ -107,10 +107,6 @@ exports.getGoods = cate => {
}
});
// console.log(data.goods1.length)
// console.log(data.goods2.length)
// console.log(data.goods3.length)
return {
code: 200,
data
... ...
... ... @@ -5,7 +5,6 @@
*/
'use strict';
const serviceAPI = global.yoho.ServiceAPI;
const api = global.yoho.API;
const _ = require('lodash');
const helpers = global.yoho.helpers;
... ... @@ -74,8 +73,13 @@ class DetailModel extends global.yoho.BaseModel {
_getLeftNav(choosed) {
choosed = choosed || 'all';
return serviceAPI.get('operations/api/v6/category/getCategory', {}, {
return this.get({
api: serviceAPI,
url: 'operations/api/v6/category/getCategory',
data: {},
param: {
cache: true
}
}).then(result => {
if (result && result.code === 200) {
... ... @@ -85,8 +89,10 @@ class DetailModel extends global.yoho.BaseModel {
}
_getShareData(id) {
return serviceAPI.get('guang/api/v6/share/guang', {
id: id
return this.get({
api: serviceAPI,
url: 'guang/api/v6/share/guang',
data: {id: id}
}).then(result => {
if (result && result.code === 200) {
... ... @@ -100,10 +106,13 @@ class DetailModel extends global.yoho.BaseModel {
* @param {*} articleId
*/
_getArticle(articleId) {
return serviceAPI.get(`${URI_PACKAGE_ARTICLE}getArticle`, {
article_id: articleId
}, {
return this.get({
api: serviceAPI,
url: `${URI_PACKAGE_ARTICLE}getArticle`,
data: {article_id: articleId},
param: {
cache: true
}
});
}
... ... @@ -112,10 +121,13 @@ class DetailModel extends global.yoho.BaseModel {
* @param {*} authorId
*/
_getAuthor(authorId) {
return serviceAPI.get(`${URI_PACKAGE_AUTHOR}getAuthor`, {
author_id: authorId
}, {
return this.get({
api: serviceAPI,
url: `${URI_PACKAGE_AUTHOR}getAuthor`,
data: {author_id: authorId},
param: {
cache: true
}
});
}
... ... @@ -124,10 +136,13 @@ class DetailModel extends global.yoho.BaseModel {
* @param {*} articleId
*/
_getArticleContent(articleId) {
return serviceAPI.get(`${URI_PACKAGE_ARTICLE}getArticleContent`, {
article_id: articleId
}, {
return this.get({
api: serviceAPI,
url: `${URI_PACKAGE_ARTICLE}getArticleContent`,
data: {article_id: articleId},
param: {
cache: true
}
});
}
... ... @@ -136,10 +151,13 @@ class DetailModel extends global.yoho.BaseModel {
* @param {*} articleId
*/
_getBrand(articleId) {
return serviceAPI.get(`${URI_PACKAGE_ARTICLE}getBrand`, {
article_id: articleId
}, {
return this.get({
api: serviceAPI,
url: `${URI_PACKAGE_ARTICLE}getBrand`,
data: {article_id: articleId},
param: {
cache: true
}
});
}
... ... @@ -149,13 +167,18 @@ class DetailModel extends global.yoho.BaseModel {
* @param {*} tag
*/
_getOtherArticle(articleId, tag) {
return serviceAPI.get(`${URI_PACKAGE_ARTICLE}getOtherArticle`, {
return this.get({
api: serviceAPI,
url: `${URI_PACKAGE_ARTICLE}getOtherArticle`,
data: {
article_id: articleId,
tags: tag,
offset: 0,
limit: 3
}, {
},
param: {
cache: true
}
});
}
... ... @@ -163,10 +186,12 @@ class DetailModel extends global.yoho.BaseModel {
* APP 获取微信模块
*/
_getSingleTemplateWechat() {
return api.get('', {
return this.get({
data: {
method: 'app.resources.getSingleTemplate',
module: 'wechat',
key: 'guang_detail_wechat'
}
});
}
... ... @@ -319,13 +344,16 @@ class DetailModel extends global.yoho.BaseModel {
* @return {[object]}
*/
intro(id) {
let param = {
return this.get({
api: serviceAPI,
url: `${URI_PACKAGE_ARTICLE}getArticleContent`,
data: {
article_id: id,
client_type: 'h5'
};
return serviceAPI.get(`${URI_PACKAGE_ARTICLE}getArticleContent`, param, {
},
param: {
cache: true
}
});
}
... ... @@ -335,15 +363,15 @@ class DetailModel extends global.yoho.BaseModel {
* @return {[type]}
*/
productInfoBySkns(sknString) {
// 调用搜索接口
let param = {
return this.get({
data: {
method: 'h5.product.batch',
productSkn: sknString,
order: 's_t_desc'
};
return api.get('', param, {
},
param: {
cache: true
}
}).then(result => {
return _.get(result, 'data.product_list', []);
});
... ...