Authored by 毕凯

Merge branch 'feature/contextMod'

... ... @@ -93,6 +93,8 @@ let calcSignature = Promise.coroutine(function* (data) {
const str = `jsapi_ticket=${data.ticket}&noncestr=${data.nonceStr}&timestamp=${data.timestamp}&url=${data.url}`;
data.signature = sha1(str);
delete data.secret; // 一定要注意 密钥绝对不能返回到前端!!!
return data;
});
... ...
... ... @@ -6,8 +6,6 @@
'use strict';
var api = global.yoho.API;
const service = global.yoho.ServiceAPI;
const helpers = global.yoho.helpers;
// const utils = '../../../utils';
... ... @@ -34,23 +32,29 @@ module.exports = class extends global.yoho.BaseModel {
* 获取频道接口
*/
_packageAd(params) {
return service.get('/operations/api/v5/resource/get', {
content_code: params.contentCode,
gender: 1,
limit: 1000,
page: 1
}, {
cache: true
return this.get({
url: '/operations/api/v5/resource/get',
data: {
content_code: params.contentCode,
gender: 1,
limit: 1000,
page: 1
},
api: global.yoho.ServiceAPI,
param: {
cache: true
}
});
}
_packageList(channel) {
return api.get('', {
method: 'app.brand.allBrandList',
yh_channel: channel
}, {
cache: true,
code: 200
return this.get({
data: {method: 'app.brand.allBrandList', yh_channel: channel},
api: global.yoho.API,
param: {
cache: true,
code: 200
}
});
}
... ... @@ -240,13 +244,16 @@ module.exports = class extends global.yoho.BaseModel {
* @return array
*/
getBrandForSearch(channel) {
return api.get('', {
method: 'app.brand.allBrandList',
yh_channel: channel || 1
}, {
cache: true,
code: 200
return this.get({
data: {
method: 'app.brand.allBrandList',
yh_channel: channel || 1
},
api: global.yoho.API,
param: {
cache: true,
code: 200
}
}).then(result => {
return result;
... ... @@ -261,13 +268,14 @@ module.exports = class extends global.yoho.BaseModel {
* @return array
*/
branchSearchHistory(params) {
return api.get('', {
method: 'app.search.hotBrandRecords',
uid: params.uid,
records: params.records || ''
}, {
code: 200
return this.get({
data: {
method: 'app.search.hotBrandRecords',
uid: params.uid,
records: params.records || ''
},
api: global.yoho.API,
param: {code: 200}
}).then(result => {
return result;
... ... @@ -277,14 +285,14 @@ module.exports = class extends global.yoho.BaseModel {
addSearchHistory(param) {
return api.get('', {
method: 'app.search.hotBrandRecords',
uid: param.uid,
records: param.records
}, {
code: 200
return this.get({
data: {
method: 'app.search.hotBrandRecords',
uid: param.uid,
records: param.records
},
api: global.yoho.API,
param: {code: 200}
});
}
... ... @@ -294,12 +302,13 @@ module.exports = class extends global.yoho.BaseModel {
* @return array
*/
branchSearchHot() {
return api.get('', {
method: 'app.search.hotBrands'
}, {
cache: true,
code: 200
return this.get({
data: {method: 'app.search.hotBrands'},
api: global.yoho.API,
param: {
cache: true,
code: 200
}
}).then(result => {
return result;
... ... @@ -314,7 +323,7 @@ module.exports = class extends global.yoho.BaseModel {
* @return array
*/
branchSearch(params) {
return api.all([
return Promise.all([
this.getBrandForSearch(params.channel),
... ... @@ -410,12 +419,13 @@ module.exports = class extends global.yoho.BaseModel {
delBrandSearchHistory(param) {
return api.get('', {
method: 'app.search.clearHotBrandRecords',
uid: param.uid
}, {
code: 200
return this.get({
data: {
method: 'app.search.clearHotBrandRecords',
uid: param.uid
},
api: global.yoho.API,
param: {code: 200}
}).then(result => {
return result;
... ...
... ... @@ -5,7 +5,6 @@
*/
'use strict';
const _ = require('lodash');
const api = global.yoho.API;
const helpers = global.yoho.helpers;
const utils = require('../../../utils');
... ... @@ -71,10 +70,10 @@ module.exports = class extends global.yoho.BaseModel {
}
getCateData(channel) {
return api.get('', {
method: 'app.sort.get'
}, {
cache: true
return this.get({
data: {method: 'app.sort.get'},
api: global.yoho.API,
param: {cache: true}
}).then((result) => {
if (!result || !result.code || result.code !== 200 || !result.data) {
... ...
... ... @@ -7,12 +7,9 @@
const utils = '../../../utils';
const contentCodeConfig = require('../../../config/content-code');
const _ = require('lodash');
const api = global.yoho.ServiceAPI;
const API = global.yoho.API;
const logger = global.yoho.logger;
const resourcesProcess = require(`${utils}/resources-process`);
/**
* 性别数据
* @type {Object}
... ... @@ -134,8 +131,11 @@ module.exports = class extends global.yoho.BaseModel {
params.new_device = true;
return api.get('operations/api/v5/resource/home', params, {
cache: true
return this.get({
url: 'operations/api/v5/resource/home',
data: params,
api: global.yoho.ServiceAPI,
param: {cache: true}
}).then(result => {
if (result && result.code === 200 && result.data && result.data.list) {
for (let item of result.data.list) {
... ... @@ -159,8 +159,10 @@ module.exports = class extends global.yoho.BaseModel {
_getLeftNav(choosed) {
choosed = choosed || 'all';
return api.get('operations/api/v6/category/getCategory', {}, {
cache: true
return this.get({
url: 'operations/api/v6/category/getCategory',
api: global.yoho.ServiceAPI,
param: {cache: true}
}).then(result => {
// console.log(result)
if (result && result.code === 200) {
... ... @@ -188,10 +190,12 @@ module.exports = class extends global.yoho.BaseModel {
delete params.gender;
}
return API.get('', _.assign({
method: 'app.search.getTerms'
}, params), {
cache: true
return this.get({
data: _.assign({
method: 'app.search.getTerms'
}, params),
api: global.yoho.API,
param: {cache: true}
}).then((result) => {
if (result && result.code === 200) {
return result.data;
... ... @@ -207,8 +211,10 @@ module.exports = class extends global.yoho.BaseModel {
* @return {[type]}
*/
_getChannelList() {
return api.get('operations/api/v5/entrance/getEntrance', {}, {
cache: true
return this.get({
url: 'operations/api/v5/entrance/getEntrance',
api: global.yoho.ServiceAPI,
param: {cache: true}
}).then((result) => {
if (result && result.code === 200) {
const list = {};
... ... @@ -253,10 +259,11 @@ module.exports = class extends global.yoho.BaseModel {
* @return {[type]}
*/
_getChannelBg() {
return api.get('operations/api/v5/resource/get', {
content_code: contentCode.index
}, {
cache: true
return this.get({
url: 'operations/api/v5/resource/get',
data: {content_code: contentCode.index},
api: global.yoho.ServiceAPI,
param: {cache: true}
}).then(result => {
if (result && result.code === 200) {
return result.data.length && result.data[0] && result.data[0].data && result.data[0].data.list[0];
... ... @@ -308,10 +315,11 @@ module.exports = class extends global.yoho.BaseModel {
gender = gender || 'boys';
if (gender === 'boys' || gender === 'girls') {
return api.get('operations/api/v5/resource/get', {
content_code: bottomBannerCode[gender] // eslint-disable-line
}, {
cache: true
return this.get({
url: 'operations/api/v5/resource/get',
data: {content_code: bottomBannerCode[gender]}, // eslint-disable-line
api: global.yoho.ServiceAPI,
param: {cache: true}
});
}
return Promise.resolve({
... ... @@ -325,10 +333,13 @@ module.exports = class extends global.yoho.BaseModel {
* 获取店铺推荐收藏和人数
*/
shopRecom(params) {
return API.get('', {
method: 'app.shops.floorNewInfo',
shop_ids: params.shopIds,
uid: params.uid,
return this.get({
data: {
method: 'app.shops.floorNewInfo',
shop_ids: params.shopIds,
uid: params.uid,
},
api: global.yoho.API
});
}
};
... ...
... ... @@ -7,7 +7,6 @@
'use strict';
const utils = '../../../utils';
const resourcesProcess = require(`${utils}/resources-process`);
const service = global.yoho.ServiceAPI;
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
... ... @@ -15,8 +14,9 @@ module.exports = class extends global.yoho.BaseModel {
}
getResourceData(code) {
return service.get('operations/api/v5/resource/get', {
content_code: code
return this.get({
url: 'operations/api/v5/resource/get',
data: {content_code: code},
}, {
cache: true,
code: 200
... ...
'use strict';
const api = global.yoho.API;
const serviceAPI = global.yoho.ServiceAPI;
const _ = require('lodash');
const helpers = global.yoho.helpers;
... ... @@ -104,11 +102,13 @@ module.exports = class extends global.yoho.BaseModel {
_getChannelData(params) {
let gender = params - 1 || 0;
return api.get('', {
method: 'app.blk.getAllChannels'
}, {
cache: true,
code: 200
return this.get({
data: {method: 'app.blk.getAllChannels'},
api: global.yoho.API,
param: {
cache: true,
code: 200
}
}).then(result => {
let channel = [];
... ... @@ -135,11 +135,14 @@ module.exports = class extends global.yoho.BaseModel {
if (!contentCode) {
return [];
}
return serviceAPI.get('operations/api/v5/resource/get', {
content_code: contentCode
}, {
cache: true,
code: 200
return this.get({
url: 'operations/api/v5/resource/get',
data: {content_code: contentCode},
api: global.yoho.ServiceAPI,
param: {
cache: true,
code: 200
}
}).then(result => {
return result && result.data ? result.data : [];
});
... ... @@ -148,13 +151,16 @@ module.exports = class extends global.yoho.BaseModel {
_getBrandListOriginData(channel) {
let finalResult = {};
return api.get('', {
method: 'app.brand.newBrandList',
yh_channel: yhChannel[channel].channel,
app_type: 1
}, {
code: 200,
cache: true
return this.get({
data: {
method: 'app.brand.newBrandList',
yh_channel: yhChannel[channel].channel,
app_type: 1
},
params: {
code: 200,
cache: true
}
}).then(result => {
if (result.data && result.data.all_list) {
return Object.assign(finalResult, this.handleBrandList(result.data.all_list));
... ... @@ -218,11 +224,14 @@ module.exports = class extends global.yoho.BaseModel {
}
_getCateData(channel, appType) {
return api.get('', {
method: 'app.sort.get',
app_type: 1
}, {
cache: true
return this.get({
data: {
method: 'app.sort.get',
app_type: 1
},
param: {
cache: true
}
}).then((result) => {
if (!result.code || result.code !== 200 || !result.data) {
return [];
... ...
... ... @@ -4,7 +4,6 @@
* @date: 2016/09/07
*/
'use strict';
const api = global.yoho.API;
module.exports = class extends global.yoho.BaseModel {
... ... @@ -33,6 +32,9 @@ module.exports = class extends global.yoho.BaseModel {
param.fav_id = id;
param.method = 'app.favorite.cancel';
}
return api.post('', param);
return this.post({
data: param,
api: global.yoho.API
});
}
};
... ...
... ... @@ -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,9 +73,12 @@ class DetailModel extends global.yoho.BaseModel {
_getLeftNav(choosed) {
choosed = choosed || 'all';
return serviceAPI.get('operations/api/v6/category/getCategory', {}, {
cache: true
return this.get({
api: serviceAPI,
url: 'operations/api/v6/category/getCategory',
param: {
cache: true
}
}).then(result => {
if (result && result.code === 200) {
... ... @@ -86,8 +88,12 @@ 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) {
... ... @@ -101,10 +107,15 @@ class DetailModel extends global.yoho.BaseModel {
* @param {*} articleId
*/
_getArticle(articleId) {
return serviceAPI.get(`${URI_PACKAGE_ARTICLE}getArticle`, {
article_id: articleId
}, {
cache: true
return this.get({
api: serviceAPI,
url: `${URI_PACKAGE_ARTICLE}getArticle`,
data: {
article_id: articleId
},
param: {
cache: true
}
});
}
... ... @@ -113,10 +124,15 @@ class DetailModel extends global.yoho.BaseModel {
* @param {*} authorId
*/
_getAuthor(authorId) {
return serviceAPI.get(`${URI_PACKAGE_AUTHOR}getAuthor`, {
author_id: authorId
}, {
cache: true
return this.get({
api: serviceAPI,
url: `${URI_PACKAGE_AUTHOR}getAuthor`,
data: {
author_id: authorId
},
param: {
cache: true
}
});
}
... ... @@ -125,10 +141,15 @@ class DetailModel extends global.yoho.BaseModel {
* @param {*} articleId
*/
_getArticleContent(articleId) {
return serviceAPI.get(`${URI_PACKAGE_ARTICLE}getArticleContent`, {
article_id: articleId
}, {
cache: true
return this.get({
api: serviceAPI,
url: `${URI_PACKAGE_ARTICLE}getArticleContent`,
data: {
article_id: articleId
},
param: {
cache: true
}
});
}
... ... @@ -137,10 +158,15 @@ class DetailModel extends global.yoho.BaseModel {
* @param {*} articleId
*/
_getBrand(articleId) {
return serviceAPI.get(`${URI_PACKAGE_ARTICLE}getBrand`, {
article_id: articleId
}, {
cache: true
return this.get({
api: serviceAPI,
url: `${URI_PACKAGE_ARTICLE}getBrand`,
data: {
article_id: articleId
},
param: {
cache: true
}
});
}
... ... @@ -150,13 +176,18 @@ class DetailModel extends global.yoho.BaseModel {
* @param {*} tag
*/
_getOtherArticle(articleId, tag) {
return serviceAPI.get(`${URI_PACKAGE_ARTICLE}getOtherArticle`, {
article_id: articleId,
tags: tag,
offset: 0,
limit: 3
}, {
cache: true
return this.get({
api: serviceAPI,
url: `${URI_PACKAGE_ARTICLE}getOtherArticle`,
data: {
article_id: articleId,
tags: tag,
offset: 0,
limit: 3
},
param: {
cache: true
}
});
}
... ... @@ -164,10 +195,12 @@ class DetailModel extends global.yoho.BaseModel {
* APP 获取微信模块
*/
_getSingleTemplateWechat() {
return api.get('', {
method: 'app.resources.getSingleTemplate',
module: 'wechat',
key: 'guang_detail_wechat'
return this.get({
data: {
method: 'app.resources.getSingleTemplate',
module: 'wechat',
key: 'guang_detail_wechat'
}
});
}
... ... @@ -320,13 +353,16 @@ class DetailModel extends global.yoho.BaseModel {
* @return {[object]}
*/
intro(id) {
let param = {
article_id: id,
client_type: 'h5'
};
return serviceAPI.get(`${URI_PACKAGE_ARTICLE}getArticleContent`, param, {
cache: true
return this.get({
api: serviceAPI,
url: `${URI_PACKAGE_ARTICLE}getArticleContent`,
data: {
article_id: id,
client_type: 'h5'
},
param: {
cache: true
}
});
}
... ... @@ -338,16 +374,16 @@ class DetailModel extends global.yoho.BaseModel {
productInfoBySkns(sknString) {
let limit = sknString && sknString.split(',').length;
// 调用搜索接口
let param = {
method: 'app.search.recomandLi',
query: sknString,
order: 's_t_desc',
limit: limit || 1
};
return api.get('', param, {
cache: true
return this.get({
data: {
method: 'app.search.recomandLi',
query: sknString,
order: 's_t_desc',
limit: limit || 1
},
param: {
cache: true
}
}).then(result => {
return _.get(result, 'data.product_list', []);
});
... ... @@ -357,11 +393,15 @@ class DetailModel extends global.yoho.BaseModel {
* 获取文章评论列表
*/
comments(params) {
return serviceAPI.get(`${URI_PACKAGE_COMMENTS}getList`, {
article_id: params.article_id,
page: params.page,
limit: params.limit || 20,
udid: params.udid
return this.get({
api: serviceAPI,
url: `${URI_PACKAGE_COMMENTS}getList`,
data: {
article_id: params.article_id,
page: params.page,
limit: params.limit || 20,
udid: params.udid
}
}).then(result => {
return _.get(result, 'data.list', []);
});
... ... @@ -372,11 +412,15 @@ class DetailModel extends global.yoho.BaseModel {
* @param {*} params
*/
commentsTotal(params) {
return serviceAPI.get(`${URI_PACKAGE_COMMENTS}getList`, {
article_id: params.article_id,
page: 1,
limit: 1,
udid: params.udid
return this.get({
api: serviceAPI,
url: `${URI_PACKAGE_COMMENTS}getList`,
data: {
article_id: params.article_id,
page: 1,
limit: 1,
udid: params.udid
}
}).then(result => {
return _.get(result, 'data.total', 0);
});
... ... @@ -387,10 +431,14 @@ class DetailModel extends global.yoho.BaseModel {
* @param {*} params
*/
getArticlePraiseAndFavor(params) {
return serviceAPI.get(`${URI_PACKAGE_PRAISE}getArticlePraiseAndFavor`, {
uid: params.uid,
id: params.id,
udid: params.udid
return this.get({
api: serviceAPI,
url: `${URI_PACKAGE_PRAISE}getArticlePraiseAndFavor`,
data: {
uid: params.uid,
id: params.id,
udid: params.udid
}
}).then(result => {
return _.get(result, 'data', {});
});
... ...
... ... @@ -22,10 +22,15 @@ class IndexModel extends global.yoho.BaseModel {
* @return {[object]}
*/
getAuthor(id) {
return serviceAPI.get('guang/service/v1/author/getAuthor', {
author_id: id
}, {
cache: true
return this.get({
api: serviceAPI,
url: 'guang/service/v1/author/getAuthor',
data: {
author_id: id
},
param: {
cache: true
}
}).then((result) => {
if (result && result.code === 200) {
return result;
... ... @@ -50,19 +55,22 @@ class IndexModel extends global.yoho.BaseModel {
* @return {[array]}
*/
getArticleList(gender, sortId, uid, udid, page, tag, authorId, limit, useCache) {
let param = {
page: page || 1,
uid: uid || 0,
udid: udid || '',
gender: gender || '',
sort_id: sortId,
tag: tag,
author_id: authorId,
limit: 4
};
return serviceAPI.get('guang/api/v2/article/getList', param, {
cache: useCache
return this.get({
api: serviceAPI,
url: 'guang/api/v2/article/getList',
data: {
page: page || 1,
uid: uid || 0,
udid: udid || '',
gender: gender || '',
sort_id: sortId,
tag: tag,
author_id: authorId,
limit: 4
},
param: {
cache: useCache
}
}).then((result) => {
if (result && result.code === 200) {
return result;
... ... @@ -305,7 +313,11 @@ class IndexModel extends global.yoho.BaseModel {
});
}
return serviceAPI.get('guang/api/v6/article/getSimpleArticleList', params);
return this.get({
api: serviceAPI,
url: 'guang/api/v6/article/getSimpleArticleList',
data: params
});
}
/**
... ... @@ -315,10 +327,14 @@ class IndexModel extends global.yoho.BaseModel {
*/
getDynamicDataById(id, uid, udid) {
return serviceAPI.get('guang/api/v6/article/getArticlePraiseAndFavor', {
id: id,
uid: uid,
udid: udid
return this.get({
api: serviceAPI,
url: 'guang/api/v6/article/getArticlePraiseAndFavor',
data: {
id: id,
uid: uid,
udid: udid
}
});
}
... ... @@ -327,8 +343,12 @@ class IndexModel extends global.yoho.BaseModel {
* @param {*} params
*/
_getTopArticles(params) {
return serviceAPI.get('guang/api/v6/article/getTopList', {
gender: params.gender
return this.get({
api: serviceAPI,
url: 'guang/api/v6/article/getTopList',
data: {
gender: params.gender
}
});
}
... ... @@ -336,11 +356,13 @@ class IndexModel extends global.yoho.BaseModel {
* 逛分类
*/
_category() {
return serviceAPI.get('/guang/api/v1/category/get', {
}, {
cache: true,
code: 200
return this.get({
api: serviceAPI,
url: '/guang/api/v1/category/get',
param: {
cache: true,
code: 200
}
});
}
... ... @@ -348,24 +370,23 @@ class IndexModel extends global.yoho.BaseModel {
* 逛内容列表
*/
_article(param) {
return serviceAPI.get('/guang/api/v2/article/getList', {
gender: param.gender,
page: param.page || 1,
uid: param.uid,
udid: param.udid,
sort_id: param.type || 0,
tag: param.tag ? param.tag : null,
limit: 4
// author_id: param.authorId ? param.authorId : null,
// limit: param.limit ? param.limit : null
}, {
cache: true,
code: 200
return this.get({
api: serviceAPI,
url: '/guang/api/v2/article/getList',
data: {
gender: param.gender,
page: param.page || 1,
uid: param.uid,
udid: param.udid,
sort_id: param.type || 0,
tag: param.tag ? param.tag : null,
limit: 4
}, param: {
cache: true,
code: 200
}
}).then(result => {
return result;
});
}
}
... ...
... ... @@ -4,8 +4,6 @@
* @date: 2016/09/07
*/
'use strict';
const serviceAPI = global.yoho.ServiceAPI;
const api = global.yoho.API;
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
... ... @@ -26,9 +24,17 @@ module.exports = class extends global.yoho.BaseModel {
};
if (opt === 'cancel') {
return serviceAPI.get('guang/api/v2/praise/cancel', param);
return this.get({
url: 'guang/api/v2/praise/cancel',
data: param,
api: global.yoho.ServiceAPI
});
} else {
return serviceAPI.get('guang/api/v2/praise/setPraise', param);
return this.get({
url: 'guang/api/v2/praise/setPraise',
data: param,
api: global.yoho.ServiceAPI
});
}
}
... ... @@ -46,9 +52,17 @@ module.exports = class extends global.yoho.BaseModel {
};
if (opt === 'cancel') {
return serviceAPI.get('guang/api/v1/favorite/cancelFavorite', param);
return this.get({
url: 'guang/api/v1/favorite/cancelFavorite',
data: param,
api: global.yoho.ServiceAPI
});
} else {
return serviceAPI.get('guang/api/v1/favorite/setFavorite', param);
return this.get({
url: 'guang/api/v1/favorite/setFavorite',
data: param,
api: global.yoho.ServiceAPI
});
}
}
... ... @@ -73,9 +87,17 @@ module.exports = class extends global.yoho.BaseModel {
if (opt === 'ok') {
return api.get('app.favorite.add', param);
return this.get({
url: 'app.favorite.add',
data: param,
api: global.yoho.API
});
} else {
return api.get('app.favorite.cancel', param);
return this.get({
url: 'app.favorite.cancel',
data: param,
api: global.yoho.API
});
}
}
};
... ...
'use strict';
const api = global.yoho.API;
const serviceAPI = global.yoho.ServiceAPI;
const _ = require('lodash');
const productProcess = require('../../../utils/product-process');
... ... @@ -16,11 +14,13 @@ module.exports = class extends global.yoho.BaseModel {
getAllChannels(params) {
let gender = params.gender - 1 || 0;
return api.get('', {
method: 'app.blk.getAllChannels',
app_type: params.app_type
}, {
cache: true
return this.get({
data: {
method: 'app.blk.getAllChannels',
app_type: params.app_type
},
api: global.yoho.API,
param: {cache: true}
}).then(result => {
let data = {channel: []};
... ... @@ -54,14 +54,16 @@ module.exports = class extends global.yoho.BaseModel {
*/
getProductBatch(param, options) {
param.productSkn = _.isArray(param.productSkn) ? param.productSkn : [param.productSkn];
return api.get('', {
method: 'h5.product.batch',
productSkn: param.productSkn.join(','),
yh_channel: param.yh_channel,
page: param.page,
limit: param.limit
}, {
cache: true
return this.get({
data: {
method: 'h5.product.batch',
productSkn: param.productSkn.join(','),
yh_channel: param.yh_channel,
page: param.page,
limit: param.limit
},
api: global.yoho.API,
param: {cache: true}
}).then(result => {
let data = {};
... ... @@ -82,9 +84,12 @@ module.exports = class extends global.yoho.BaseModel {
* @return {[array]}
*/
getFashionPrefer(params) {
return api.get('', Object.assign({
method: 'h5.product.fashionPrefer'
}, params));
return this.get({
data: Object.assign({
method: 'h5.product.fashionPrefer'
}, params),
api: global.yoho.API
});
}
/**
... ... @@ -98,8 +103,11 @@ module.exports = class extends global.yoho.BaseModel {
if (options.isApp) {
params.platform = 'iphone';
}
return serviceAPI.get('operations/api/v5/resource/get', params, {
cache: true
return this.get({
url: 'operations/api/v5/resource/get',
data: params,
api: global.yoho.ServiceAPI,
param: {cache: true}
}).then(result => {
let data = {
goods: {},
... ... @@ -180,7 +188,7 @@ module.exports = class extends global.yoho.BaseModel {
}
getResourcesData(params, options) {
return api.all([
return Promise.all([
this.getResources(params, options),
this.getFashionPrefer(params)
]).then(result => {
... ...
'use strict';
const productNameProcess = require(`${global.utils}/product-name-process`);
const api = global.yoho.API;
const serviceAPI = global.yoho.ServiceAPI;
const _ = require('lodash');
const logger = global.yoho.logger;
const helpers = global.yoho.helpers;
... ... @@ -65,7 +63,12 @@ module.exports = class extends global.yoho.BaseModel {
param.is_recommend = isRecommend;
}
return serviceAPI.get('guang/api/v3/plustar/getlist', param, {cache: true}).then((result) => {
return this.get({
url: 'guang/api/v3/plustar/getlist',
data: param,
api: global.yoho.ServiceAPI,
param: {cache: true}
}).then((result) => {
if (result && result.code === 200) {
return this.formaData(result.data.data.list[0].data, gender);
} else {
... ... @@ -125,14 +128,18 @@ module.exports = class extends global.yoho.BaseModel {
// 新品到着
getNewProduct(brandId, gender, url, isApp) {
return api.get('', {
method: 'app.search.li',
brand: brandId,
gender: gender,
limit: 6,
order: 's_t_desc',
page: 1
}, {cache: true}).then((result) => {
return this.get({
data: {
method: 'app.search.li',
brand: brandId,
gender: gender,
limit: 6,
order: 's_t_desc',
page: 1
},
api: global.yoho.API,
param: {cache: true}
}).then((result) => {
if (result && result.code === 200) {
... ... @@ -235,11 +242,15 @@ module.exports = class extends global.yoho.BaseModel {
// 相关资讯--不能加cache,否则点赞有缓存.
getRelatedEditorial(brandId, uid, udid, isApp) {
return serviceAPI.get('guang/service/v1/article/getArticleByBrand', {
brand_id: brandId,
uid: uid,
udid: udid,
limit: 3
return this.get({
url: 'guang/service/v1/article/getArticleByBrand',
data: {
brand_id: brandId,
uid: uid,
udid: udid,
limit: 3
},
api: global.yoho.ServiceAPI
}).then((result) => {
if (result && result.code === 200) {
... ... @@ -280,7 +291,11 @@ module.exports = class extends global.yoho.BaseModel {
param.uid = uid;
}
return serviceAPI.get('shops/service/v1/favorite/getUidBrandFav', param).then((result) => {
return this.get({
url: 'shops/service/v1/favorite/getUidBrandFav',
data: param,
api: global.yoho.ServiceAPI
}).then((result) => {
if (result && result.code === 200) {
... ... @@ -298,9 +313,14 @@ module.exports = class extends global.yoho.BaseModel {
// 品牌详情
getDetailData(id, uid, udid, gender, isApp) {
return serviceAPI.get('guang/api/v1/plustar/getbrandinfo', {
id: id
}, {cache: true}).then((result) => {
return this.get({
url: 'guang/api/v1/plustar/getbrandinfo',
data: {
id: id
},
api: global.yoho.ServiceAPI,
param: {cache: true}
}).then((result) => {
if (result && result.code === 200) {
let list = result.data || [];
let jumpToApp;
... ...
... ... @@ -10,8 +10,6 @@ const resourcesProcess = require(`${utils}/resources-process`);
const logger = global.yoho.logger;
const helpers = global.yoho.helpers;
const _ = require('lodash');
const serviceAPI = global.yoho.ServiceAPI;
const api = global.yoho.API;
const contentCode = contentCodeConfig.guang;
... ... @@ -26,11 +24,16 @@ module.exports = class extends global.yoho.BaseModel {
* @return {[array]}
*/
_getResources(page) {
return serviceAPI.get('operations/api/v5/resource/get', {
content_code: contentCode[page],
platform: 'iphone'
}, {
cache: true
return this.get({
url: 'operations/api/v5/resource/get',
data: {
content_code: contentCode[page],
platform: 'iphone'
},
api: global.yoho.ServiceAPI,
param: {
cache: true
}
}).then((result) => {
if (result && result.code === 200) {
return resourcesProcess(result.data);
... ... @@ -165,11 +168,15 @@ module.exports = class extends global.yoho.BaseModel {
* 星潮首页
*/
getIndexData() {
return api.get('', {
method: 'app.starClass.index',
code: '8adc27fcf5676f356602889afcfd2a8e'
}, {
cache: true
return this.get({
data: {
method: 'app.starClass.index',
code: '8adc27fcf5676f356602889afcfd2a8e'
},
api: global.yoho.API,
param: {
cache: true
}
}).then((result) => {
if (result && result.code === 200) {
return this._processIndexData(result);
... ... @@ -184,14 +191,18 @@ module.exports = class extends global.yoho.BaseModel {
* 明星专题
*/
getDetailData(params, uid) {
return api.get('', {
method: 'app.starClass.lastTagArticle',
tag: params.tag,
page: params.page || 1,
size: 10,
uid: uid
}, {
cache: true
return this.get({
data: {
method: 'app.starClass.lastTagArticle',
tag: params.tag,
page: params.page || 1,
size: 10,
uid: uid
},
api: global.yoho.API,
param: {
cache: true
}
}).then((result) => {
if (result && result.code === 200) {
if (params.page > result.data.totalPage) {
... ... @@ -237,11 +248,16 @@ module.exports = class extends global.yoho.BaseModel {
* 星搭配
*/
getCollocationListData(params, uid) {
return serviceAPI.get('guang/api/v5/article/getStarClassroomArticleList', Object.assign({
limit: '20',
uid: uid
}, params), {
cache: true
return this.get({
url: 'guang/api/v5/article/getStarClassroomArticleList',
data: Object.assign({
limit: '20',
uid: uid
}, params),
api: global.yoho.ServiceAPI,
param: {
cache: true
}
}).then((result) => {
if (result && result.code === 200) {
return this._processGuangData(result.data.list.artList);
... ... @@ -260,11 +276,14 @@ module.exports = class extends global.yoho.BaseModel {
});
}
return api.get('', {
method: params.type === 'del' ? 'app.sns.cancelFavorBackCount' : 'app.sns.setFavorBackCount',
client_type: 'h5',
article_id: params.articleId,
uid: uid
return this.get({
data: {
method: params.type === 'del' ? 'app.sns.cancelFavorBackCount' : 'app.sns.setFavorBackCount',
client_type: 'h5',
article_id: params.articleId,
uid: uid
},
api: global.yoho.API
});
}
};
... ...
... ... @@ -21,10 +21,14 @@ module.exports = class extends global.yoho.BaseModel {
* @param params
*/
_getAddressData(params) {
return api.get('', {
method: 'app.address.gethidden',
uid: params.uid
}, {code: 200});
return this.get({
data: {
method: 'app.address.gethidden',
uid: params.uid
},
api: global.yoho.API,
param: {code: 200}
});
}
/**
... ... @@ -34,10 +38,14 @@ module.exports = class extends global.yoho.BaseModel {
* @private
*/
_getThrAddressData(params) {
return api.get('', {
method: 'app.address.getlist',
uid: params.uid
}, {code: 200, cache: true});
return this.get({
data: {
method: 'app.address.getlist',
uid: params.uid
},
api: global.yoho.API,
param: {code: 200, cache: true}
});
}
/**
... ... @@ -46,16 +54,19 @@ module.exports = class extends global.yoho.BaseModel {
* @private
*/
_saveAddressData(params) {
return api.get('', {
method: params.id ? 'app.address.update' : 'app.address.add',
id: params.id,
address: params.address,
area_code: params.area_code,
consignee: params.consignee,
email: params.email,
mobile: params.mobile,
zip_code: params.zip_code,
uid: params.uid
return this.get({
data: {
method: params.id ? 'app.address.update' : 'app.address.add',
id: params.id,
address: params.address,
area_code: params.area_code,
consignee: params.consignee,
email: params.email,
mobile: params.mobile,
zip_code: params.zip_code,
uid: params.uid
},
api: global.yoho.API
});
}
... ... @@ -65,10 +76,13 @@ module.exports = class extends global.yoho.BaseModel {
* @private
*/
_setDefaultAddress(params) {
return api.get('', {
method: 'app.address.setdefault',
uid: params.id,
id: params.id
return this.get({
data: {
method: 'app.address.setdefault',
uid: params.id,
id: params.id
},
api: global.yoho.API
});
}
... ... @@ -78,10 +92,13 @@ module.exports = class extends global.yoho.BaseModel {
* @private
*/
_delAddressData(params) {
return api.get('', {
method: 'app.address.del',
id: params.id,
uid: params.uid
return this.get({
data: {
method: 'app.address.del',
id: params.id,
uid: params.uid
},
api: global.yoho.API
});
}
... ... @@ -201,10 +218,14 @@ module.exports = class extends global.yoho.BaseModel {
* 新版地址选择获取地址
*/
newGetAddress(params) {
return api.get('', {
method: 'app.address.provinces',
id: params.id || '0'
}, {code: 200, cache: true}).then(result => {
return this.get({
data: {
method: 'app.address.provinces',
id: params.id || '0'
},
api: global.yoho.API,
param: {code: 200, cache: true}
}).then(result => {
return result && result.data;
});
}
... ... @@ -214,11 +235,14 @@ module.exports = class extends global.yoho.BaseModel {
* @param params
*/
chooseAddress(orderCode, addressId, uid) {
return api.get('', {
method: 'app.SpaceOrders.updateDeliveryAddress',
uid: uid,
order_code: orderCode,
address_id: crypto.decrypt(null, addressId)
return this.get({
data: {
method: 'app.SpaceOrders.updateDeliveryAddress',
uid: uid,
order_code: orderCode,
address_id: crypto.decrypt(null, addressId)
},
api: global.yoho.API
}).then((result) => {
return result;
});
... ...
// 优惠券 by acgpiano
'use strict';
const api = global.yoho.API;
const helpers = global.yoho.helpers;
class couponsModel extends global.yoho.BaseModel {
... ... @@ -10,7 +9,7 @@ class couponsModel extends global.yoho.BaseModel {
}
couponData(params) {
return api.get('', params).then(result => {
return this.get({data: params}).then(result => {
if (result && result.data && result.data.couponList) {
let status0 = params.status === 0;
... ...
... ... @@ -7,9 +7,6 @@
'use strict';
const logger = global.yoho.logger;
const api = global.yoho.API;
// const serviceAPI = global.yoho.ServiceAPI;
const camelCase = global.yoho.camelCase;
const _ = require('lodash');
const config = global.yoho.config;
... ... @@ -22,12 +19,12 @@ class favoriteIndexModel extends global.yoho.BaseModel {
favProduct(uid, page, limit) {
return api.get('', {
return this.get({data: {
method: 'app.favorite.product',
uid: uid,
page: page,
limit: limit
}).then((result) => {
}}).then((result) => {
let resu = {
hasFavProduct: []
... ... @@ -123,12 +120,12 @@ class favoriteIndexModel extends global.yoho.BaseModel {
}
favfavBrand(uid, page, limit) {
return api.get('', {
return this.get({data: {
method: 'app.favorite.brand',
uid: uid,
page: page,
limit: limit
}).then((result) => {
}}).then((result) => {
let resu = {
hasFavBrand: []
... ... @@ -203,12 +200,12 @@ class favoriteIndexModel extends global.yoho.BaseModel {
favoriteDelete(uid, type, favId) {
return api.get('', {
return this.get({data: {
method: 'app.favorite.cancel',
uid: uid,
type: type,
fav_id: favId
});
}});
}
index(uid, page, limit, isbrand) {
... ...
'use strict';
const api = global.yoho.API;
const helpers = global.yoho.helpers;
const _ = require('lodash');
const moment = require('moment');
... ... @@ -90,7 +89,7 @@ module.exports = class extends global.yoho.BaseModel {
index(param) {
if (param.uid) {
return api.all([
return Promise.all([
this.getGradeGrade(param.uid, param.channel),
this.getGradeUser(param.uid, param.channel),
this.getGrowthVip(param.uid)
... ... @@ -200,7 +199,7 @@ module.exports = class extends global.yoho.BaseModel {
}
grow(param) {
return api.all([
return Promise.all([
this.getGrowthVip(param.uid),
this.getHis(param)
]).then((result) => {
... ... @@ -258,7 +257,7 @@ module.exports = class extends global.yoho.BaseModel {
}
getHisAjax(param) {
return api.all([
return Promise.all([
this.getHis(param)
]).then((result) => {
let resu = {
... ...
... ... @@ -8,11 +8,9 @@
'use strict';
const api = global.yoho.API;
const singleAPI = global.yoho.SingleAPI;
const helpers = global.yoho.helpers;
const _ = require('lodash');
const crypto = global.yoho.crypto;
const service = global.yoho.ServiceAPI;
const utils = '../../../utils';
const resourcesProcess = require(`${utils}/resources-process`);
... ... @@ -26,11 +24,13 @@ module.exports = class extends global.yoho.BaseModel {
*/
_userData(params) {
if (params.uid) {
return api.get('', {
method: 'app.passport.profile',
uid: params.uid
}, {
code: 200
return this.get({
data: {
method: 'app.passport.profile',
uid: params.uid
},
api: global.yoho.API,
param: {code: 200}
});
} else {
return Promise.resolve({});
... ... @@ -41,10 +41,10 @@ module.exports = class extends global.yoho.BaseModel {
* 获取个人中心公告有关数据
*/
_noticeData() {
return api.get('', {
method: 'app.resources.getNotices'
}, {
code: 200
return this.get({
data: {method: 'app.resources.getNotices'},
api: global.yoho.API,
param: {code: 200}
});
}
... ... @@ -55,11 +55,14 @@ module.exports = class extends global.yoho.BaseModel {
*/
_favoriteData(params) {
if (params.uid) {
return singleAPI.get('favorite', {
method: 'app.favorite.getFavoriteCount',
uid: params.uid
}, {
code: 200
return this.get({
url: 'favorite',
data: {
method: 'app.favorite.getFavoriteCount',
uid: params.uid
},
api: global.yoho.SingleAPI,
param: {code: 200}
});
} else {
return false;
... ... @@ -71,12 +74,14 @@ module.exports = class extends global.yoho.BaseModel {
*/
_infoNum(params) {
if (params.uid) {
return api.get('', {
method: 'app.home.getInfoNum',
uid: params.uid,
udid: params.udid
}, {
code: 200
return this.get({
data: {
method: 'app.home.getInfoNum',
uid: params.uid,
udid: params.udid
},
api: global.yoho.API,
param: {code: 200}
});
} else {
return false;
... ... @@ -89,11 +94,13 @@ module.exports = class extends global.yoho.BaseModel {
*/
_getAddressData(params) {
if (params.uid) {
return api.get('', {
method: 'app.address.gethidden',
uid: params.uid
}, {
code: 200
return this.get({
data: {
method: 'app.address.gethidden',
uid: params.uid
},
api: global.yoho.API,
param: {code: 200}
});
} else {
return false;
... ... @@ -102,8 +109,12 @@ module.exports = class extends global.yoho.BaseModel {
// 资源位
_getRes() {
return service.get('/operations/api/v5/resource/home', {
content_code: '5d05d443a557783b1489d328c127e9bf',
return this.get({
url: '/operations/api/v5/resource/home',
data: {
content_code: '5d05d443a557783b1489d328c127e9bf',
},
api: global.yoho.ServiceAPI
}).then(result => {
if (result && result.code === 200 && result.data && result.data.list) {
for (let item of result.data.list) {
... ... @@ -121,11 +132,13 @@ module.exports = class extends global.yoho.BaseModel {
// 潮流口令
_getCode(uid) {
if (uid) {
return api.get('', {
method: 'app.invitecode.my',
uid: uid
}, {
code: 200
return this.get({
data: {
method: 'app.invitecode.my',
uid: uid
},
api: global.yoho.API,
param: {code: 200}
});
} else {
return Promise.resolve({});
... ... @@ -133,8 +146,12 @@ module.exports = class extends global.yoho.BaseModel {
}
_getTrendPop(contentCode) {
return service.get('operations/api/v5/resource/get', {
content_code: contentCode,
return this.get({
url: 'operations/api/v5/resource/get',
data: {
content_code: contentCode,
},
api: global.yoho.ServiceAPI
}).then(result => {
if (result && result.code === 200 && result.data) {
return result.data[0];
... ... @@ -237,11 +254,13 @@ module.exports = class extends global.yoho.BaseModel {
}
_detailInfo(uid) {
return api.get('', {
method: 'app.passport.profile',
uid: uid
}, {
code: 200
return this.get({
data: {
method: 'app.passport.profile',
uid: uid
},
api: global.yoho.API,
param: {code: 200}
});
}
... ... @@ -278,13 +297,15 @@ module.exports = class extends global.yoho.BaseModel {
*/
recordContent(uid, udid, page, limit) {
if (uid) {
return api.get('', {
method: 'app.browse.product',
uid: uid,
limit: limit,
page: page
}, {
code: 200
return this.get({
data: {
method: 'app.browse.product',
uid: uid,
limit: limit,
page: page
},
api: global.yoho.API,
param: {code: 200}
}).then((result) => {
let resu = {};
... ... @@ -338,10 +359,13 @@ module.exports = class extends global.yoho.BaseModel {
* @param params
*/
delRecord(uid, skn) {
return api.get('', {
method: 'app.browse.delete',
uid: uid,
skn: skn
return this.get({
data: {
method: 'app.browse.delete',
uid: uid,
skn: skn
},
api: global.yoho.API
});
}
... ... @@ -350,22 +374,30 @@ module.exports = class extends global.yoho.BaseModel {
* @param params
*/
getGradeGrade(uid, channel) {
return api.get('', {
method: 'app.passport.vip',
uid: uid,
channel: channel || 1
}, {
code: 200
return this.get({
data: {
method: 'app.passport.vip',
uid: uid,
channel: channel || 1
},
api: global.yoho.API,
param: {
code: 200
}
});
}
getGradeUser(uid, channel) {
return api.get('', {
method: 'app.passport.profile',
uid: uid,
channel: channel || 1
}, {
code: 200
return this.get({
data: {
method: 'app.passport.profile',
uid: uid,
channel: channel || 1
},
api: global.yoho.API,
param: {
code: 200
}
});
}
... ... @@ -474,12 +506,16 @@ module.exports = class extends global.yoho.BaseModel {
*/
getPreferential(params) {
return api.get('', {
method: 'app.passport.getPrivilege',
uid: params.uid,
channel: params.channel || 1
}, {
code: 200
return this.get({
data: {
method: 'app.passport.getPrivilege',
uid: params.uid,
channel: params.channel || 1
},
api: global.yoho.API,
param: {
code: 200
}
}).then((result) => {
let obj = {};
... ...
... ... @@ -2,7 +2,6 @@
'use strict';
const moment = require('moment');
const api = global.yoho.API;
const helpers = global.yoho.helpers;
// 格式化时间
... ... @@ -55,11 +54,11 @@ class messageModel extends global.yoho.BaseModel {
// 获取生日信息
_getBirthCouponById(uid) {
return api.get('', {
return this.get({data: {
method: 'app.promotion.queryBirthCoupon',
uid: uid,
couponType: 4,
}).then(result => {
}}).then(result => {
if (result && result.data) {
let final = {
ticket: []
... ... @@ -155,14 +154,13 @@ class messageModel extends global.yoho.BaseModel {
// 获取列表或详情
getList(params) {
return api.get('', {
return this.get({data: {
method: 'app.inbox.getlist',
page: params.page || 1,
size: params.size || 10,
uid: params.uid,
}).then(result => {
}}).then(result => {
if (params.msgid) {
// 绕的一比
return this._detail(result, params.msgid);
} else {
return this._list(result);
... ... @@ -172,11 +170,11 @@ class messageModel extends global.yoho.BaseModel {
// 删除消息
delMsg(params) {
return api.get('', {
return this.get({data: {
method: 'app.inbox.delmessage',
uid: params.uid,
id: params.msgid,
}).then(result => {
}}).then(result => {
if (result && result.code === 200) {
return {
code: 200
... ... @@ -192,11 +190,11 @@ class messageModel extends global.yoho.BaseModel {
// 领取优惠券
pickCoupon(params) {
return api.get('', {
return this.get({data: {
method: 'app.promotion.getCoupon',
uid: params.uid,
couponId: params.couponId,
}).then(result => {
}}).then(result => {
if (result && result.code === 200) {
return {
code: 200
... ...
'use strict';
const serviceAPI = global.yoho.ServiceAPI;
const api = global.yoho.API;
const _ = require('lodash');
const logger = global.yoho.logger;
... ... @@ -11,10 +9,10 @@ class myCurrencyModel extends global.yoho.BaseModel {
}
_yohoCoin(uid) {
return api.get('', {
return this.get({data: {
method: 'app.yoho.yohocoin',
uid: uid
}).then((result) => {
}}).then((result) => {
let data = [];
if (result && result.code === 200) {
... ... @@ -28,12 +26,18 @@ class myCurrencyModel extends global.yoho.BaseModel {
}
bannerData(contentCode) {
return serviceAPI.get('operations/api/v5/resource/get', {
content_code: contentCode
}, {
cache: true
}).then((result) => {
let options = {
url: 'operations/api/v5/resource/get',
data: {
content_code: contentCode
},
param: {
cache: true
},
api: global.yoho.ServiceAPI
};
return this.get(options).then((result) => {
if (result && result.code === 200) {
... ... @@ -60,12 +64,12 @@ class myCurrencyModel extends global.yoho.BaseModel {
}
currencyDetail(uid, page, limit) {
return api.get('', {
return this.get({data: {
method: 'app.yohocoin.lists',
uid: uid,
page: page,
limit: limit
}).then((result) => {
}}).then((result) => {
let data = [];
if (result && result.code === 200) {
... ...
'use strict';
const api = global.yoho.API;
const crypto = global.yoho.crypto;
const PASSWORD = 'yoho9646yoho9646';
... ... @@ -19,10 +18,10 @@ class qrcodeModel extends global.yoho.BaseModel {
uid = params.token;
}
return api.get('', {
return this.get({data: {
method: 'app.twoDimen.getCode',
uid: uid,
}).then(result => {
uid: uid
}}).then(result => {
return (result && result.data && result.data.code) || '';
});
}
... ...
'use strict';
const api = global.yoho.API;
const helpers = global.yoho.helpers;
const _ = require('lodash');
... ... @@ -99,15 +98,19 @@ module.exports = class extends global.yoho.BaseModel {
* @param params
*/
_getOrderData(params) {
return api.get('', {
method: 'app.SpaceOrders.get',
type: params.type,
page: params.page,
limit: params.limit,
gender: params.gender,
yh_channel: params.yh_channel,
uid: params.uid
}, {code: 200});
return this.get({
data: {
method: 'app.SpaceOrders.get',
type: params.type,
page: params.page,
limit: params.limit,
gender: params.gender,
yh_channel: params.yh_channel,
uid: params.uid
},
api: global.yoho.API,
param: {code: 200}
});
}
/**
... ... @@ -248,11 +251,12 @@ module.exports = class extends global.yoho.BaseModel {
navs: this._getNavs(params.type)
};
return api.get('', _.assign({
method: 'app.SpaceOrders.closeReasons'
}, params), {
cache: true,
code: 200
return this.get({
data: _.assign({
method: 'app.SpaceOrders.closeReasons'
}, params),
api: global.yoho.API,
param: {cache: true, code: 200}
}).then(result => {
if (result && result.data) {
... ... @@ -267,9 +271,11 @@ module.exports = class extends global.yoho.BaseModel {
* 申请退款原因
*/
refundReason() {
return api.get('', {
method: 'app.SpaceOrders.refundApplyReasons'
}, {code: 200, cache: true}).then(result => {
return this.get({
data: {method: 'app.SpaceOrders.refundApplyReasons'},
api: global.yoho.API,
param: {code: 200, cache: true}
}).then(result => {
return _.get(result, 'data', []);
});
}
... ... @@ -324,10 +330,13 @@ module.exports = class extends global.yoho.BaseModel {
* 确认收货确认订单接口
*/
sure(params) {
return api.get('', {
method: 'app.SpaceOrders.confirm',
order_code: params.order_code,
uid: params.uid
return this.get({
data: {
method: 'app.SpaceOrders.confirm',
order_code: params.order_code,
uid: params.uid
},
api: global.yoho.API
});
}
};
... ...
'use strict';
const api = global.yoho.API;
const serviceApi = global.yoho.ServiceAPI;
const _ = require('lodash');
// const config = global.yoho.config;
... ... @@ -20,10 +16,10 @@ module.exports = class extends global.yoho.BaseModel {
}
closeReasons() {
return api.get('', {
method: 'app.SpaceOrders.closeReasons'
}, {
cache: true
return this.get({
data: {method: 'app.SpaceOrders.closeReasons'},
api: global.yoho.API,
param: {cache: true}
}).then((result) => {
if (result && result.code === 200) {
return result.data;
... ... @@ -157,10 +153,13 @@ module.exports = class extends global.yoho.BaseModel {
return Promise.resolve({});
}
return api.get('', {
method: 'app.SpaceOrders.detail',
uid: uid,
order_code: orderCode
return this.get({
data: {
method: 'app.SpaceOrders.detail',
uid: uid,
order_code: orderCode
},
api: global.yoho.API
}).then(result => {
if (result && result.code === 200) {
let orderDetail = camelCase(result.data);
... ... @@ -297,19 +296,25 @@ module.exports = class extends global.yoho.BaseModel {
// 删除订单
delOrder(orderCode, uid) {
return api.get('', {
method: 'app.SpaceOrders.delOrderByCode',
uid: uid,
order_code: orderCode
return this.get({
data: {
method: 'app.SpaceOrders.delOrderByCode',
uid: uid,
order_code: orderCode
},
api: global.yoho.API
});
}
// 再次购买
readdData(orderCode, uid) {
return api.get('', {
method: 'app.Shopping.readd',
uid: uid,
order_code: orderCode
return this.get({
data: {
method: 'app.Shopping.readd',
uid: uid,
order_code: orderCode
},
api: global.yoho.API
}).then((result) => {
if (result && result.code === 200) {
result.message = '商品已重新加入购物车';
... ... @@ -327,14 +332,17 @@ module.exports = class extends global.yoho.BaseModel {
// 取消订单
cancelOrder(orderCode, uid, reasonId, gender, channel, reason) {
return api.get('', {
method: 'app.SpaceOrders.close',
uid: uid,
order_code: orderCode,
reasonId: reasonId,
reasons: reason,
gender: gender,
yh_channel: channel
return this.get({
data: {
method: 'app.SpaceOrders.close',
uid: uid,
order_code: orderCode,
reasonId: reasonId,
reasons: reason,
gender: gender,
yh_channel: channel
},
api: global.yoho.API
});
}
... ... @@ -342,12 +350,15 @@ module.exports = class extends global.yoho.BaseModel {
* 申请退款
*/
refundApply(params) {
return api.get('', {
method: 'app.SpaceOrders.refundApply',
uid: params.uid,
order_code: params.orderCode,
reason_id: params.reasonId,
reason: params.reason
return this.get({
data: {
method: 'app.SpaceOrders.refundApply',
uid: params.uid,
order_code: params.orderCode,
reason_id: params.reasonId,
reason: params.reason
},
api: global.yoho.API
});
}
... ... @@ -378,16 +389,22 @@ module.exports = class extends global.yoho.BaseModel {
});
}
return api.get('', finalParams);
return this.get({
data: finalParams,
api: global.yoho.API
});
}
/**
* 获取物流详情页banner
*/
_getLogisterBanner() {
return serviceApi.get('operations/api/v5/resource/get', {
content_code: CODE_LOGISTIC_BANNER
}, {code: 200});
return this.get({
url: 'operations/api/v5/resource/get',
data: {content_code: CODE_LOGISTIC_BANNER},
params: {code: 200},
api: global.yoho.ServiceAPI
});
}
/**
... ... @@ -468,6 +485,9 @@ module.exports = class extends global.yoho.BaseModel {
});
}
return api.post('', apiParams);
return this.post({
data: apiParams,
api: global.yoho.API
});
}
};
... ...
... ... @@ -6,7 +6,6 @@
'use strict';
const logger = global.yoho.logger;
var api = global.yoho.API;
class qrcodeModel extends global.yoho.BaseModel {
constructor(ctx) {
... ... @@ -14,11 +13,12 @@ class qrcodeModel extends global.yoho.BaseModel {
}
getQRcodeData(id, uid) {
return api.get('', {
return this.get({data: {
method: 'app.SpaceOrders.getQrByOrderCode',
order_code: id,
uid: uid
}).then(result => {
}}).then(result => {
console.log(result);
if (result && result.code === 200) {
return result.data;
} else {
... ...
... ... @@ -7,7 +7,6 @@
'use strict';
const logger = global.yoho.logger;
const serviceAPI = global.yoho.ServiceAPI;
const camelCase = global.yoho.camelCase;
const _ = require('lodash');
... ... @@ -18,10 +17,14 @@ module.exports = class extends global.yoho.BaseModel {
suggestData(uid, udid, page, limit) {
return serviceAPI.get('suggest/api/v1/suggest/getList', {
udid: udid,
page: page,
limit: limit
return this.get({
url: 'suggest/api/v1/suggest/getList',
data: {
udid: udid,
page: page,
limit: limit
},
api: global.yoho.ServiceAPI
}).then((result) => {
if (result && result.code === 200 && result.data) {
_.forEach(result.data.list, function(data) {
... ... @@ -40,11 +43,15 @@ module.exports = class extends global.yoho.BaseModel {
}
upAndDown(uid, udid, reliable, suggestId) {
return serviceAPI.get('suggest/api/v1/suggest/is_reliable', {
uid: uid,
udid: udid,
is_reliable: reliable,
suggest_id: suggestId
return this.get({
url: 'suggest/api/v1/suggest/is_reliable',
data: {
uid: uid,
udid: udid,
is_reliable: reliable,
suggest_id: suggestId
},
api: global.yoho.ServiceAPI
});
}
... ... @@ -61,6 +68,10 @@ module.exports = class extends global.yoho.BaseModel {
per.image = image;
}
return serviceAPI.get('suggest/api/v1/suggest/saveSuggest', per);
return this.get({
url: 'suggest/api/v1/suggest/saveSuggest',
data: per,
api: global.yoho.ServiceAPI
});
}
};
... ...
const api = global.yoho.API;
const service = global.yoho.ServiceAPI;
const _ = require('lodash');
module.exports = class extends global.yoho.BaseModel {
... ... @@ -9,11 +7,13 @@ module.exports = class extends global.yoho.BaseModel {
// 文字说明
invitionText(uid) {
return api.get('', {
method: 'app.invitecode.my',
uid: uid
}, {
code: 200
return this.get({
data: {
method: 'app.invitecode.my',
uid: uid
},
api: global.yoho.API,
param: {code: 200}
}).then((result) => {
if (result && result.code === 200 && result.data) {
... ... @@ -27,10 +27,13 @@ module.exports = class extends global.yoho.BaseModel {
// 资源位图
resources(contentCode) {
return service.get('operations/api/v5/resource/get', {
content_code: contentCode
}, {
code: 200
return this.get({
url: 'operations/api/v5/resource/get',
data: {
content_code: contentCode
},
api: global.yoho.ServiceAPI,
param: {code: 200}
}).then((result) => {
if (result && result.data) {
... ... @@ -40,7 +43,7 @@ module.exports = class extends global.yoho.BaseModel {
}
invitionData(uid, contentCode) {
return api.all([this.invitionText(uid), this.resources(contentCode)]).then((result) => {
return Promise.all([this.invitionText(uid), this.resources(contentCode)]).then((result) => {
let finaData = {};
finaData = Object.assign(finaData, result[0]);
... ...
... ... @@ -4,8 +4,6 @@
'use strict';
const _ = require('lodash');
const helpers = global.yoho.helpers;
const api = global.yoho.API;
const singleAPI = global.yoho.SingleAPI;
const stringProcess = require(`${global.utils}/string-process`);
/**
... ... @@ -28,10 +26,14 @@ module.exports = class extends global.yoho.BaseModel {
* 店铺品牌列表
*/
getShopBrands(shopId) {
return api.get('', {
method: 'app.shops.getShopsBrands',
shop_id: shopId
}, {code: 200}).then(result => {
return this.get({
data: {
method: 'app.shops.getShopsBrands',
shop_id: shopId
},
api: global.yoho.API,
param: {code: 200}
}).then(result => {
if (result && result.data) {
_.forEach(result.data, value => {
value.url = helpers.urlFormat('', {
... ... @@ -70,7 +72,10 @@ module.exports = class extends global.yoho.BaseModel {
});
}
return api.get('', finalParams);
return this.get({
data: finalParams,
api: global.yoho.API
});
}
/**
... ... @@ -79,11 +84,13 @@ module.exports = class extends global.yoho.BaseModel {
* @return array | false
*/
getBrandLogoByDomain(domain) {
return api.get('', {
method: 'web.brand.byDomain',
domain: domain
}, {
cache: true
return this.get({
data: {
method: 'web.brand.byDomain',
domain: domain
},
api: global.yoho.API,
param: {cache: true}
}).then(result => {
if (result && result.data) {
let formatData = result.data;
... ... @@ -117,11 +124,13 @@ module.exports = class extends global.yoho.BaseModel {
return Promise.resolve({});
}
return api.get('', _.assign({
method: 'app.brand.getBrandIntro',
brand_id: brandId
}, param), {
code: 200
return this.get({
data: _.assign({
method: 'app.brand.getBrandIntro',
brand_id: brandId
}, param),
api: global.yoho.API,
param: {code: 200}
}).then(result => {
if (result && result.data) {
let list = result.data;
... ... @@ -144,11 +153,13 @@ module.exports = class extends global.yoho.BaseModel {
* @return array banner数据
*/
getBrandBanner(brandId) {
return api.get('', {
method: 'app.brand.banner',
brand_id: brandId
}, {
cache: true
return this.get({
data: {
method: 'app.brand.banner',
brand_id: brandId
},
api: global.yoho.API,
param: {cache: true}
}).then((result) => {
if (result && result.code === 200 && result.data) {
if (result.data.banner) {
... ... @@ -173,7 +184,11 @@ module.exports = class extends global.yoho.BaseModel {
shop_id: shopId
};
return api.get('', params, {cache: true, code: 200});
return this.get({
data: params,
api: global.yoho.API,
param: {cache: true, code: 200}
});
}
... ... @@ -188,7 +203,10 @@ module.exports = class extends global.yoho.BaseModel {
shop_id: shopId
};
return api.get('', params, {cache: true, code: 200});
return this.get({
data: params,
param: {cache: true, code: 200}
});
}
/**
... ... @@ -198,10 +216,13 @@ module.exports = class extends global.yoho.BaseModel {
* @return array
*/
getShopCategory(shopId, channel) {
return api.get('', {
method: 'app.shop.getSortInfo',
yh_channel: yhChannel[channel],
shop_id: shopId
return this.get({
data: {
method: 'app.shop.getSortInfo',
yh_channel: yhChannel[channel],
shop_id: shopId
},
api: global.yoho.API
});
}
... ... @@ -223,7 +244,10 @@ module.exports = class extends global.yoho.BaseModel {
});
}
return singleAPI.get('favorite', finalParams);
return this.get({
url: 'favorite',
data: finalParams
});
}
/**
... ... @@ -232,12 +256,15 @@ module.exports = class extends global.yoho.BaseModel {
* @return array
*/
getShopDecorator(shopId) {
return api.get('', {
method: 'app.shopsdecorator.getList',
shop_id: shopId
}, {
cache: true,
code: 200
return this.get({
data: {
method: 'app.shopsdecorator.getList',
shop_id: shopId
},
param: {
cache: true,
code: 200
}
}).then((result) => {
return (result && result.data) || {};
});
... ...
... ... @@ -41,7 +41,7 @@
"license": "MIT",
"dependencies": {
"bluebird": "^3.4.7",
"body-parser": "^1.17.2",
"body-parser": "^1.18.0",
"captchapng": "0.0.1",
"cheerio": "^0.22.0",
"client-sessions": "^0.8.0",
... ... @@ -77,7 +77,7 @@
"yoho-zookeeper": "^1.0.8"
},
"devDependencies": {
"autoprefixer": "^7.1.2",
"autoprefixer": "^7.1.4",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-polyfill": "^6.26.0",
... ... @@ -93,7 +93,7 @@
"happypack": "^3.1.0",
"husky": "^0.14.3",
"ignore-file-loader": "^1.0.0",
"nodemon": "^1.11.0",
"nodemon": "^1.12.0",
"opn": "^5.1.0",
"postcss-assets": "^4.2.0",
"postcss-calc": "^6.0.0",
... ... @@ -112,7 +112,7 @@
"shelljs": "^0.7.8",
"store": "^2.0.12",
"style-loader": "^0.18.2",
"stylelint": "^8.0.0",
"stylelint": "^8.1.1",
"stylelint-config-yoho": "^1.2.10",
"stylelint-formatter-table": "^1.0.2",
"stylelint-processor-html": "^1.0.0",
... ... @@ -122,11 +122,11 @@
"vue-lazyload": "^1.0.6",
"vue-loader": "^13.0.4",
"vue-template-compiler": "^2.4.2",
"webpack": "^3.5.5",
"webpack": "^3.5.6",
"webpack-bundle-analyzer": "^2.9.0",
"webpack-dev-middleware": "^1.12.0",
"webpack-dev-server": "^2.7.1",
"webpack-hot-middleware": "^2.18.2",
"webpack-hot-middleware": "^2.19.1",
"webpack-merge": "^4.1.0",
"webpack-uglify-parallel": "^0.1.3",
"yoho-cookie": "^1.2.0",
... ...
... ... @@ -118,6 +118,7 @@
display: inline-block;
position: relative;
top: 8px;
z-index: 5;
}
.code-tip {
... ...
... ... @@ -32,7 +32,6 @@
border-radius: 10px;
}
.world-number {
position: absolute;
font-size: 24px;
... ...