Merge branch 'feature/context-api' into 'release/6.6'
Feature/context api 以下接口上下文调用修改 /operations/api/v5/webshare/getShare app.coupons.couponsSend app.search.newPromotion app.query.bundleSkn See merge request !1366
Showing
10 changed files
with
174 additions
and
151 deletions
@@ -22,7 +22,7 @@ const _getPname = (req) => { | @@ -22,7 +22,7 @@ const _getPname = (req) => { | ||
22 | }; | 22 | }; |
23 | 23 | ||
24 | exports.index = function(req, res, next) { | 24 | exports.index = function(req, res, next) { |
25 | - model.index({ | 25 | + req.ctx(model).index({ |
26 | code: req.params.code, | 26 | code: req.params.code, |
27 | type: stringProcess.paramsFilter(req.query.type), | 27 | type: stringProcess.paramsFilter(req.query.type), |
28 | from_page_name: _getPname(req), | 28 | from_page_name: _getPname(req), |
@@ -53,7 +53,7 @@ exports.index = function(req, res, next) { | @@ -53,7 +53,7 @@ exports.index = function(req, res, next) { | ||
53 | }; | 53 | }; |
54 | 54 | ||
55 | exports.sidebar = function(req, res, next) { | 55 | exports.sidebar = function(req, res, next) { |
56 | - model.index({ | 56 | + req.ctx(model).index({ |
57 | code: req.params.code | 57 | code: req.params.code |
58 | }).then((result) => { | 58 | }).then((result) => { |
59 | if (!result) { | 59 | if (!result) { |
@@ -68,7 +68,7 @@ exports.sidebar = function(req, res, next) { | @@ -68,7 +68,7 @@ exports.sidebar = function(req, res, next) { | ||
68 | 68 | ||
69 | 69 | ||
70 | exports.bottombar = function(req, res, next) { | 70 | exports.bottombar = function(req, res, next) { |
71 | - model.index({ | 71 | + req.ctx(model).index({ |
72 | code: req.params.code | 72 | code: req.params.code |
73 | }).then((result) => { | 73 | }).then((result) => { |
74 | if (!result) { | 74 | if (!result) { |
@@ -117,7 +117,7 @@ exports.couponSend = (req, res, next) => { | @@ -117,7 +117,7 @@ exports.couponSend = (req, res, next) => { | ||
117 | return res.jsonp(resultData); | 117 | return res.jsonp(resultData); |
118 | } | 118 | } |
119 | 119 | ||
120 | - model.couponSend(uid, token).then(result => { | 120 | + req.ctx(model).couponSend(uid, token).then(result => { |
121 | res.set({ | 121 | res.set({ |
122 | 'Cache-Control': 'no-cache', | 122 | 'Cache-Control': 'no-cache', |
123 | Pragma: 'no-cache', | 123 | Pragma: 'no-cache', |
@@ -15,7 +15,7 @@ exports.productLst = function(req, res, next) { | @@ -15,7 +15,7 @@ exports.productLst = function(req, res, next) { | ||
15 | let getProductList; | 15 | let getProductList; |
16 | 16 | ||
17 | if (req.query.maybeLike) { | 17 | if (req.query.maybeLike) { |
18 | - getProductList = model.maybeLikeList(Object.assign({ | 18 | + getProductList = req.ctx(model).maybeLikeList(Object.assign({ |
19 | uid: uid, | 19 | uid: uid, |
20 | udid: udid, | 20 | udid: udid, |
21 | yh_channel: req.query.yh_channel || (req.cookies._Channel && channels[req.cookies._Channel]) || 1, | 21 | yh_channel: req.query.yh_channel || (req.cookies._Channel && channels[req.cookies._Channel]) || 1, |
@@ -58,7 +58,7 @@ exports.productLst = function(req, res, next) { | @@ -58,7 +58,7 @@ exports.productLst = function(req, res, next) { | ||
58 | } | 58 | } |
59 | } | 59 | } |
60 | 60 | ||
61 | - getProductList = model.productLst(params); | 61 | + getProductList = req.ctx(model).productLst(params); |
62 | } | 62 | } |
63 | 63 | ||
64 | getProductList.then((result) => { | 64 | getProductList.then((result) => { |
@@ -93,7 +93,7 @@ exports.coupon = function(req, res, next) { | @@ -93,7 +93,7 @@ exports.coupon = function(req, res, next) { | ||
93 | }); | 93 | }); |
94 | } | 94 | } |
95 | 95 | ||
96 | - model.getCoupon({ | 96 | + req.ctx(model).getCoupon({ |
97 | activity_template_id, | 97 | activity_template_id, |
98 | uid | 98 | uid |
99 | }).then((result) => { | 99 | }).then((result) => { |
@@ -3,9 +3,8 @@ | @@ -3,9 +3,8 @@ | ||
3 | * Created by yoho on 2016/10/19. | 3 | * Created by yoho on 2016/10/19. |
4 | */ | 4 | */ |
5 | 'use strict'; | 5 | 'use strict'; |
6 | -const mRoot = '../models'; | ||
7 | -const share = require(`${mRoot}/share`); | ||
8 | const _ = require('lodash'); | 6 | const _ = require('lodash'); |
7 | +const shareModel = require('../models/share'); | ||
9 | 8 | ||
10 | exports.getShareContent = (req, res, next) => { | 9 | exports.getShareContent = (req, res, next) => { |
11 | if (!req.query.shareId) { | 10 | if (!req.query.shareId) { |
@@ -22,7 +21,7 @@ exports.getShareContent = (req, res, next) => { | @@ -22,7 +21,7 @@ exports.getShareContent = (req, res, next) => { | ||
22 | }); | 21 | }); |
23 | } | 22 | } |
24 | 23 | ||
25 | - share.getShareContent({ | 24 | + req.ctx(shareModel).getShareContent({ |
26 | shareId: req.query.shareId | 25 | shareId: req.query.shareId |
27 | }).then(result => { | 26 | }).then(result => { |
28 | res.jsonp(result); | 27 | res.jsonp(result); |
@@ -57,8 +57,11 @@ const _getShopGroup = (shopRawData) => { | @@ -57,8 +57,11 @@ const _getShopGroup = (shopRawData) => { | ||
57 | }); | 57 | }); |
58 | }; | 58 | }; |
59 | 59 | ||
60 | -module.exports = { | ||
61 | - index: function(params) { | 60 | +class featureModel extends global.yoho.BaseModel { |
61 | + constructor(ctx) { | ||
62 | + super(ctx); | ||
63 | + } | ||
64 | + index(params) { | ||
62 | return Promise.coroutine(function*() { | 65 | return Promise.coroutine(function*() { |
63 | if (!params.code) { | 66 | if (!params.code) { |
64 | return Promise.resolve({}); | 67 | return Promise.resolve({}); |
@@ -134,7 +137,7 @@ module.exports = { | @@ -134,7 +137,7 @@ module.exports = { | ||
134 | 137 | ||
135 | return data; | 138 | return data; |
136 | })(); | 139 | })(); |
137 | - }, | 140 | + } |
138 | 141 | ||
139 | /** | 142 | /** |
140 | * 领取优惠券 | 143 | * 领取优惠券 |
@@ -157,7 +160,7 @@ module.exports = { | @@ -157,7 +160,7 @@ module.exports = { | ||
157 | }; | 160 | }; |
158 | } | 161 | } |
159 | 162 | ||
160 | - return api.get('', data).then(result => { | 163 | + return this.get({data}).then(result => { |
161 | 164 | ||
162 | if (!result) { | 165 | if (!result) { |
163 | result.code = 404; | 166 | result.code = 404; |
@@ -167,4 +170,7 @@ module.exports = { | @@ -167,4 +170,7 @@ module.exports = { | ||
167 | return result; | 170 | return result; |
168 | }); | 171 | }); |
169 | } | 172 | } |
170 | -}; | 173 | + |
174 | +} | ||
175 | + | ||
176 | +module.exports = featureModel; |
1 | 'use strict'; | 1 | 'use strict'; |
2 | 2 | ||
3 | -const api = global.yoho.API; | ||
4 | - | ||
5 | let _getProduct = function(o) { | 3 | let _getProduct = function(o) { |
6 | return { | 4 | return { |
7 | small_sort_id: o.small_sort_id, | 5 | small_sort_id: o.small_sort_id, |
@@ -30,12 +28,16 @@ const gender = { | @@ -30,12 +28,16 @@ const gender = { | ||
30 | 2: '2,3' | 28 | 2: '2,3' |
31 | }; | 29 | }; |
32 | 30 | ||
33 | -module.exports = { | ||
34 | - productLst: function(params) { | ||
35 | - return api.get('', Object.assign({ | ||
36 | - method: 'app.search.newPromotion' | ||
37 | - }, params), { | ||
38 | - cache: true | 31 | +class individuationModel extends global.yoho.BaseModel { |
32 | + constructor(ctx) { | ||
33 | + super(ctx); | ||
34 | + } | ||
35 | + productLst(params) { | ||
36 | + return this.get({ | ||
37 | + data: Object.assign({ | ||
38 | + method: 'app.search.newPromotion' | ||
39 | + }, params), | ||
40 | + param: {cache: true} | ||
39 | }).then(res => { | 41 | }).then(res => { |
40 | var data = [], | 42 | var data = [], |
41 | lst = (res && res.data && res.data.product_list) || []; | 43 | lst = (res && res.data && res.data.product_list) || []; |
@@ -45,19 +47,20 @@ module.exports = { | @@ -45,19 +47,20 @@ module.exports = { | ||
45 | }); | 47 | }); |
46 | return data; | 48 | return data; |
47 | }); | 49 | }); |
48 | - }, | ||
49 | - maybeLikeList: function(params) { | ||
50 | - return api.get('', { | ||
51 | - method: 'app.home.newPreference', | ||
52 | - uid: params.uid || 0, | ||
53 | - udid: params.udid || 0, | ||
54 | - yh_channel: params.yh_channel, | ||
55 | - limit: params.limit || 60, | ||
56 | - need_filter: 'null', | ||
57 | - rec_pos: '100053', | ||
58 | - gender: params.gender || gender[params.yh_channel] | ||
59 | - }, { | ||
60 | - cache: true | 50 | + } |
51 | + maybeLikeList(params) { | ||
52 | + return this.get({ | ||
53 | + data: { | ||
54 | + method: 'app.home.newPreference', | ||
55 | + uid: params.uid || 0, | ||
56 | + udid: params.udid || 0, | ||
57 | + yh_channel: params.yh_channel, | ||
58 | + limit: params.limit || 60, | ||
59 | + need_filter: 'null', | ||
60 | + rec_pos: '100053', | ||
61 | + gender: params.gender || gender[params.yh_channel] | ||
62 | + }, | ||
63 | + param: {cache: true} | ||
61 | }).then(res => { | 64 | }).then(res => { |
62 | var data = [], | 65 | var data = [], |
63 | lst = (res && res.data && res.data.product_list) || []; | 66 | lst = (res && res.data && res.data.product_list) || []; |
@@ -67,12 +70,16 @@ module.exports = { | @@ -67,12 +70,16 @@ module.exports = { | ||
67 | }); | 70 | }); |
68 | return data; | 71 | return data; |
69 | }); | 72 | }); |
70 | - }, | ||
71 | - getCoupon: function(params) { | ||
72 | - return api.get('', Object.assign({ | ||
73 | - method: 'app.coupons.personalCoupons' | ||
74 | - }, params), { | ||
75 | - cache: true | 73 | + } |
74 | + getCoupon(params) { | ||
75 | + return this.get({ | ||
76 | + data: Object.assign({ | ||
77 | + method: 'app.coupons.personalCoupons' | ||
78 | + }, params), | ||
79 | + param: {cache: true} | ||
76 | }); | 80 | }); |
77 | } | 81 | } |
78 | -}; | 82 | + |
83 | +} | ||
84 | + | ||
85 | +module.exports = individuationModel; |
1 | -/** | ||
2 | - * Created by yoho on 2016/10/19. | ||
3 | - */ | ||
4 | 'use strict'; | 1 | 'use strict'; |
5 | -const serviceApi = global.yoho.ServiceAPI; | ||
6 | 2 | ||
7 | -/** | ||
8 | - * 从接口获取 share 内容 | ||
9 | - * @returns {*|Promise.<TResult>} | ||
10 | - */ | ||
11 | -const getShareContent = (params) => { | ||
12 | - return serviceApi.get('operations/api/v5/webshare/getShare', { | ||
13 | - share_id: params.shareId | ||
14 | - }).then(result => { | ||
15 | - return result; | ||
16 | - }); | ||
17 | -}; | 3 | +class shareModel extends global.yoho.BaseModel { |
4 | + constructor(ctx) { | ||
5 | + super(ctx); | ||
6 | + } | ||
18 | 7 | ||
19 | -module.exports = { | ||
20 | - getShareContent | ||
21 | -}; | 8 | + /** |
9 | + * 从接口获取 share 内容 | ||
10 | + * @returns {*|Promise.<TResult>} | ||
11 | + */ | ||
12 | + getShareContent(params) { | ||
13 | + return this.get({ | ||
14 | + url: 'operations/api/v5/webshare/getShare', | ||
15 | + data: {share_id: params.shareId}, | ||
16 | + api: global.yoho.ServiceAPI, | ||
17 | + }).then(result => { | ||
18 | + return result; | ||
19 | + }); | ||
20 | + } | ||
21 | + | ||
22 | +} | ||
23 | + | ||
24 | +module.exports = shareModel; |
@@ -15,7 +15,7 @@ const bundleModel = require(`${mRoot}/bundle`); | @@ -15,7 +15,7 @@ const bundleModel = require(`${mRoot}/bundle`); | ||
15 | * @param next | 15 | * @param next |
16 | */ | 16 | */ |
17 | exports.detail = (req, res, next) => { | 17 | exports.detail = (req, res, next) => { |
18 | - bundleModel.detail(req.query, req.yoho.isApp).then(result => { | 18 | + req.ctx(bundleModel).detail(req.query, req.yoho.isApp).then(result => { |
19 | if (!result.bundleDatas) { | 19 | if (!result.bundleDatas) { |
20 | return next(); | 20 | return next(); |
21 | } | 21 | } |
@@ -40,7 +40,7 @@ exports.detail = (req, res, next) => { | @@ -40,7 +40,7 @@ exports.detail = (req, res, next) => { | ||
40 | exports.addToCart = (req, res, next) => { | 40 | exports.addToCart = (req, res, next) => { |
41 | let shoppingKey = req.cookies._SPK || ''; | 41 | let shoppingKey = req.cookies._SPK || ''; |
42 | 42 | ||
43 | - bundleModel.addToCart({ | 43 | + req.ctx(bundleModel).addToCart({ |
44 | uid: req.user.uid, | 44 | uid: req.user.uid, |
45 | activity_id: req.body.activity_id, | 45 | activity_id: req.body.activity_id, |
46 | product_sku_list: req.body.product_sku_list, | 46 | product_sku_list: req.body.product_sku_list, |
@@ -4,95 +4,103 @@ | @@ -4,95 +4,103 @@ | ||
4 | 'use strict'; | 4 | 'use strict'; |
5 | const utils = '../../../utils'; | 5 | const utils = '../../../utils'; |
6 | const _ = require('lodash'); | 6 | const _ = require('lodash'); |
7 | -const api = global.yoho.API; | ||
8 | const helpers = global.yoho.helpers; | 7 | const helpers = global.yoho.helpers; |
9 | const productProcess = require(`${utils}/product-process`); | 8 | const productProcess = require(`${utils}/product-process`); |
10 | 9 | ||
11 | -/** | ||
12 | - * 从接口获取套装数据 | ||
13 | - * @private | ||
14 | - */ | ||
15 | -const getBundleBySkn = (productSkn) => { | ||
16 | - return api.get('', { | ||
17 | - method: 'app.query.bundleSkn', | ||
18 | - product_skn: productSkn | ||
19 | - }, {cache: false}).then(result => { | ||
20 | - return result; | ||
21 | - }); | ||
22 | -}; | ||
23 | - | ||
24 | -/** | ||
25 | - * 套装详情页数据 | ||
26 | - * @param params | ||
27 | - * @returns {*} | ||
28 | - */ | ||
29 | -const detail = (params, isApp) => { | ||
30 | - if (!params.skn && !params.bundle_skn) { | ||
31 | - return Promise.resolve({}); | 10 | +class bundleModel extends global.yoho.BaseModel { |
11 | + constructor(ctx) { | ||
12 | + super(ctx); | ||
32 | } | 13 | } |
33 | - let bundleIndex = (params.index || 1); | ||
34 | - | ||
35 | - --bundleIndex; | ||
36 | - return getBundleBySkn(params.skn || params.bundle_skn).then(result => { | ||
37 | - if (_.has(result, `data[${bundleIndex}]`)) { | ||
38 | - let shareInfo = _.get(result, 'data[0].shareInfo', {}); | ||
39 | 14 | ||
40 | - return { | ||
41 | - bundleDatas: _.map(result.data, (bundle, index) => { | ||
42 | - let query = {bundle_skn: params.skn || | ||
43 | - params.bundle_skn, productId: params.productId, index: index + 1}; | 15 | + /** |
16 | + * 从接口获取套装数据 | ||
17 | + * @private | ||
18 | + */ | ||
19 | + getBundleBySkn(productSkn) { | ||
20 | + return this.get({ | ||
21 | + data: { | ||
22 | + method: 'app.query.bundleSkn', | ||
23 | + product_skn: productSkn | ||
24 | + }, | ||
25 | + param: {cache: false} | ||
26 | + }).then(result => { | ||
27 | + return result; | ||
28 | + }); | ||
29 | + } | ||
44 | 30 | ||
45 | - if (isApp) { | ||
46 | - query.app_version = isApp; | ||
47 | - } | ||
48 | - return { | ||
49 | - selected: index === bundleIndex, | ||
50 | - title: _.get(bundle, 'bundleInfo.tabName') || '', | ||
51 | - href: helpers.urlFormat('/product/bundle/detail', query), | ||
52 | - }; | ||
53 | - }), | ||
54 | - shareInfo: { | ||
55 | - imgUrl: `http:${helpers.image(shareInfo.imgUrl, 300, 300)}`, | ||
56 | - subTitle: encodeURIComponent(shareInfo.subTitle), | ||
57 | - title: encodeURIComponent(shareInfo.title), | ||
58 | - url: shareInfo.url | ||
59 | - }, | ||
60 | - bundleInfo: _.get(result, `data[${bundleIndex}].bundleInfo`, {}), | ||
61 | - productList: productProcess.processProductList(_.get(result, `data[${bundleIndex}].productList`, [])) | ||
62 | - }; | 31 | + /** |
32 | + * 套装详情页数据 | ||
33 | + * @param params | ||
34 | + * @returns {*} | ||
35 | + */ | ||
36 | + detail(params, isApp) { | ||
37 | + if (!params.skn && !params.bundle_skn) { | ||
38 | + return Promise.resolve({}); | ||
63 | } | 39 | } |
64 | - return {}; | ||
65 | - }); | ||
66 | -}; | 40 | + let bundleIndex = (params.index || 1); |
67 | 41 | ||
68 | -/** | ||
69 | - * 套餐加入购物车 | ||
70 | - * @param {*} params | ||
71 | - */ | ||
72 | -const addToCart = (params) => { | ||
73 | - let skuList = params.product_sku_list; | ||
74 | - let finalParams = { | ||
75 | - method: 'app.Shopping.addBundle', | ||
76 | - shopping_key: params.shopping_key, | ||
77 | - activity_id: params.activity_id, | ||
78 | - product_sku_list: skuList | ||
79 | - }; | 42 | + --bundleIndex; |
43 | + return this.getBundleBySkn(params.skn || params.bundle_skn).then(result => { | ||
44 | + if (_.has(result, `data[${bundleIndex}]`)) { | ||
45 | + let shareInfo = _.get(result, 'data[0].shareInfo', {}); | ||
80 | 46 | ||
81 | - if (params.uid) { | ||
82 | - Object.assign(finalParams, { | ||
83 | - uid: params.uid | 47 | + return { |
48 | + bundleDatas: _.map(result.data, (bundle, index) => { | ||
49 | + let query = {bundle_skn: params.skn || | ||
50 | + params.bundle_skn, productId: params.productId, index: index + 1}; | ||
51 | + | ||
52 | + if (isApp) { | ||
53 | + query.app_version = isApp; | ||
54 | + } | ||
55 | + return { | ||
56 | + selected: index === bundleIndex, | ||
57 | + title: _.get(bundle, 'bundleInfo.tabName') || '', | ||
58 | + href: helpers.urlFormat('/product/bundle/detail', query), | ||
59 | + }; | ||
60 | + }), | ||
61 | + shareInfo: { | ||
62 | + imgUrl: `http:${helpers.image(shareInfo.imgUrl, 300, 300)}`, | ||
63 | + subTitle: encodeURIComponent(shareInfo.subTitle), | ||
64 | + title: encodeURIComponent(shareInfo.title), | ||
65 | + url: shareInfo.url | ||
66 | + }, | ||
67 | + bundleInfo: _.get(result, `data[${bundleIndex}].bundleInfo`, {}), | ||
68 | + productList: productProcess.processProductList( | ||
69 | + _.get(result, `data[${bundleIndex}].productList`, [])) | ||
70 | + }; | ||
71 | + } | ||
72 | + return {}; | ||
84 | }); | 73 | }); |
85 | } | 74 | } |
86 | 75 | ||
87 | - return api.post('', finalParams, { | ||
88 | - headers: { | ||
89 | - 'User-Agent': params.userAgent | 76 | + /** |
77 | + * 套餐加入购物车 | ||
78 | + * @param {*} params | ||
79 | + */ | ||
80 | + addToCart(params) { | ||
81 | + let skuList = params.product_sku_list; | ||
82 | + let finalParams = { | ||
83 | + method: 'app.Shopping.addBundle', | ||
84 | + shopping_key: params.shopping_key, | ||
85 | + activity_id: params.activity_id, | ||
86 | + product_sku_list: skuList | ||
87 | + }; | ||
88 | + | ||
89 | + if (params.uid) { | ||
90 | + Object.assign(finalParams, { | ||
91 | + uid: params.uid | ||
92 | + }); | ||
90 | } | 93 | } |
91 | - }); | ||
92 | -}; | ||
93 | 94 | ||
94 | -module.exports = { | ||
95 | - getBundleBySkn, | ||
96 | - detail, | ||
97 | - addToCart | ||
98 | -}; | 95 | + return this.post({ |
96 | + data: finalParams, | ||
97 | + param: { | ||
98 | + headers: { | ||
99 | + 'User-Agent': params.userAgent | ||
100 | + } | ||
101 | + } | ||
102 | + }); | ||
103 | + } | ||
104 | +} | ||
105 | + | ||
106 | +module.exports = bundleModel; |
@@ -241,7 +241,7 @@ module.exports = class extends global.yoho.BaseModel { | @@ -241,7 +241,7 @@ module.exports = class extends global.yoho.BaseModel { | ||
241 | }), | 241 | }), |
242 | this._getCommonConsult(), // eslint-disable-line | 242 | this._getCommonConsult(), // eslint-disable-line |
243 | comment.getConsults(result.product_id, 1, 2), | 243 | comment.getConsults(result.product_id, 1, 2), |
244 | - bundle.getBundleBySkn(result.product_skn) | 244 | + this.ctx.req.ctx(bundle).getBundleBySkn(result.product_skn) |
245 | ]).then((info) => { | 245 | ]).then((info) => { |
246 | finalResult = _detailDataPkg(result, data.ua); // eslint-disable-line | 246 | finalResult = _detailDataPkg(result, data.ua); // eslint-disable-line |
247 | finalResult.enterStore = info[0]; | 247 | finalResult.enterStore = info[0]; |
@@ -256,7 +256,7 @@ module.exports = class extends global.yoho.BaseModel { | @@ -256,7 +256,7 @@ module.exports = class extends global.yoho.BaseModel { | ||
256 | href: helpers.urlFormat('/product/bundle/detail', | 256 | href: helpers.urlFormat('/product/bundle/detail', |
257 | {skn: result.product_skn, id: result.product_id}), | 257 | {skn: result.product_skn, id: result.product_id}), |
258 | description: '立省¥' + (parseInt(_.get(bundleData, 'bundleInfo.salesPrice', 0), 10) - | 258 | description: '立省¥' + (parseInt(_.get(bundleData, 'bundleInfo.salesPrice', 0), 10) - |
259 | - parseInt(_.get(bundleData, 'bundleInfo.discountPrice', 0), 10)) + '元', | 259 | + parseInt(_.get(bundleData, 'bundleInfo.discountPrice', 0), 10)) + '元', |
260 | productList: productProcess.processProductList(bundleData && bundleData.productList) | 260 | productList: productProcess.processProductList(bundleData && bundleData.productList) |
261 | }; | 261 | }; |
262 | } | 262 | } |
@@ -631,14 +631,14 @@ module.exports = class extends global.yoho.BaseModel { | @@ -631,14 +631,14 @@ module.exports = class extends global.yoho.BaseModel { | ||
631 | }); | 631 | }); |
632 | dest.showBuyNow = true; | 632 | dest.showBuyNow = true; |
633 | dest.cartInfo.addToCartUrl = helpers.urlFormat('/product/buy_' + origin.product_id + '_' + | 633 | dest.cartInfo.addToCartUrl = helpers.urlFormat('/product/buy_' + origin.product_id + '_' + |
634 | - origin.goods_id + '.html'); | 634 | + origin.goods_id + '.html'); |
635 | } else { // 除了上面商品之外的普通商品 | 635 | } else { // 除了上面商品之外的普通商品 |
636 | Object.assign(dest.cartInfo, cartInfo, { | 636 | Object.assign(dest.cartInfo, cartInfo, { |
637 | price: dest.goodsPrice.previousPrice ? dest.goodsPrice.previousPrice : '', | 637 | price: dest.goodsPrice.previousPrice ? dest.goodsPrice.previousPrice : '', |
638 | salePrice: dest.goodsPrice.currentPrice ? dest.goodsPrice.currentPrice : '', | 638 | salePrice: dest.goodsPrice.currentPrice ? dest.goodsPrice.currentPrice : '', |
639 | }); | 639 | }); |
640 | dest.cartInfo.addToCartUrl = helpers.urlFormat('/product/buy_' + origin.product_id + '_' + | 640 | dest.cartInfo.addToCartUrl = helpers.urlFormat('/product/buy_' + origin.product_id + '_' + |
641 | - origin.goods_id + '.html'); | 641 | + origin.goods_id + '.html'); |
642 | } | 642 | } |
643 | return resolve(dest); | 643 | return resolve(dest); |
644 | }).then(result => { | 644 | }).then(result => { |
@@ -728,7 +728,7 @@ module.exports = class extends global.yoho.BaseModel { | @@ -728,7 +728,7 @@ module.exports = class extends global.yoho.BaseModel { | ||
728 | ]; | 728 | ]; |
729 | 729 | ||
730 | if (data.bundleType) { | 730 | if (data.bundleType) { |
731 | - apiArray.push(bundle.getBundleBySkn(data.productSkn)); | 731 | + apiArray.push(this.ctx.req.ctx(bundle).getBundleBySkn(data.productSkn)); |
732 | } | 732 | } |
733 | 733 | ||
734 | return Promise.all(apiArray).then((res) => { | 734 | return Promise.all(apiArray).then((res) => { |
@@ -93,8 +93,8 @@ module.exports = class extends global.yoho.BaseModel { | @@ -93,8 +93,8 @@ module.exports = class extends global.yoho.BaseModel { | ||
93 | } | 93 | } |
94 | 94 | ||
95 | /* | 95 | /* |
96 | - 获取 促销,评论,咨询,品牌信息 | ||
97 | - */ | 96 | + 获取 促销,评论,咨询,品牌信息 |
97 | + */ | ||
98 | querySknData(params) { | 98 | querySknData(params) { |
99 | let brandId = params.brandId; | 99 | let brandId = params.brandId; |
100 | let shopId = params.shopId; | 100 | let shopId = params.shopId; |
@@ -112,7 +112,7 @@ module.exports = class extends global.yoho.BaseModel { | @@ -112,7 +112,7 @@ module.exports = class extends global.yoho.BaseModel { | ||
112 | ]; | 112 | ]; |
113 | 113 | ||
114 | if (params.bundleType) { | 114 | if (params.bundleType) { |
115 | - apiArray.push(bundle.getBundleBySkn(skn)); | 115 | + apiArray.push(this.ctx.req.ctx(bundle).getBundleBySkn(skn)); |
116 | } | 116 | } |
117 | 117 | ||
118 | return Promise.all(apiArray).then(info => { | 118 | return Promise.all(apiArray).then(info => { |
@@ -153,8 +153,8 @@ module.exports = class extends global.yoho.BaseModel { | @@ -153,8 +153,8 @@ module.exports = class extends global.yoho.BaseModel { | ||
153 | // ------------------------------接口 | 153 | // ------------------------------接口 |
154 | 154 | ||
155 | /* | 155 | /* |
156 | - 接口: 根据BrandID, 查询品牌信息 | ||
157 | - */ | 156 | + 接口: 根据BrandID, 查询品牌信息 |
157 | + */ | ||
158 | queryShopsByBrandId(brandId, shopId) { | 158 | queryShopsByBrandId(brandId, shopId) { |
159 | let params = { | 159 | let params = { |
160 | method: 'app.product.queryShopsInfoById', | 160 | method: 'app.product.queryShopsInfoById', |
-
Please register or login to post a comment