Authored by 李奇

app.search.newPromotion及其关联接口验证通过

@@ -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) => {
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;