Authored by 郝肖肖

'ctx'

@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 'use strict'; 2 'use strict';
3 3
4 const Promise = require('bluebird'); 4 const Promise = require('bluebird');
5 -const api = global.yoho.API;  
6 const _ = require('lodash'); 5 const _ = require('lodash');
7 const helpers = global.yoho.helpers; 6 const helpers = global.yoho.helpers;
8 const crypto = global.yoho.crypto; 7 const crypto = global.yoho.crypto;
@@ -279,11 +278,15 @@ class couponFloor extends global.yoho.BaseModel { @@ -279,11 +278,15 @@ class couponFloor extends global.yoho.BaseModel {
279 } 278 }
280 279
281 floor(params, isApp, appVersion) { 280 floor(params, isApp, appVersion) {
  281 + let that = this;
  282 +
282 return Promise.coroutine(function*() { 283 return Promise.coroutine(function*() {
283 let result = {}, 284 let result = {},
284 - resource = yield api.get('', Object.assign(params, { 285 + resource = yield that.get({
  286 + data: Object.assign(params, {
285 method: 'app.promotion.queryCouponCenter', 287 method: 'app.promotion.queryCouponCenter',
286 - })); 288 + })
  289 + });
287 290
288 if (resource && resource.code === 200) { 291 if (resource && resource.code === 200) {
289 result = _getContent(resource.data, isApp); 292 result = _getContent(resource.data, isApp);
@@ -298,10 +301,14 @@ class couponFloor extends global.yoho.BaseModel { @@ -298,10 +301,14 @@ class couponFloor extends global.yoho.BaseModel {
298 } 301 }
299 302
300 status(params) { 303 status(params) {
  304 + let that = this;
  305 +
301 return Promise.coroutine(function*() { 306 return Promise.coroutine(function*() {
302 - const resource = yield api.get('', Object.assign(params, { 307 + const resource = yield that.get({
  308 + data: Object.assign(params, {
303 method: 'app.promotion.couponStatus' 309 method: 'app.promotion.couponStatus'
304 - })); 310 + })
  311 + });
305 const result = { 312 const result = {
306 code: resource.code, 313 code: resource.code,
307 data: [] 314 data: []
@@ -332,10 +339,12 @@ class couponFloor extends global.yoho.BaseModel { @@ -332,10 +339,12 @@ class couponFloor extends global.yoho.BaseModel {
332 } 339 }
333 340
334 // 登录后调用领券接口 341 // 登录后调用领券接口
335 - return api.get('', { 342 + return this.get({
  343 + data: {
336 method: 'app.promotion.getCoupon', 344 method: 'app.promotion.getCoupon',
337 couponId: receiveData.couponID, 345 couponId: receiveData.couponID,
338 uid: uid 346 uid: uid
  347 + }
339 }).then(result => { 348 }).then(result => {
340 switch (result.code) { 349 switch (result.code) {
341 case 200: 350 case 200:
@@ -394,8 +403,9 @@ class couponFloor extends global.yoho.BaseModel { @@ -394,8 +403,9 @@ class couponFloor extends global.yoho.BaseModel {
394 }; 403 };
395 } 404 }
396 405
397 - return api.get('', data).then(result => {  
398 - 406 + return this.get({
  407 + data: data
  408 + }).then(result => {
399 if (!result) { 409 if (!result) {
400 result.code = 404; 410 result.code = 404;
401 result.message = '出错啦~'; 411 result.message = '出错啦~';
1 -const api = global.yoho.API;  
2 const _ = require('lodash'); 1 const _ = require('lodash');
3 const moment = require('moment'); 2 const moment = require('moment');
4 3
@@ -11,9 +10,11 @@ module.exports = class extends global.yoho.BaseModel { @@ -11,9 +10,11 @@ module.exports = class extends global.yoho.BaseModel {
11 * 领取验证以及领券列表 10 * 领取验证以及领券列表
12 */ 11 */
13 freeMail(uid, verify) { 12 freeMail(uid, verify) {
14 - return api.get('', { 13 + return this.get({
  14 + data: {
15 method: 'app.coupons.queryFreePostCoupons', 15 method: 'app.coupons.queryFreePostCoupons',
16 uid: uid 16 uid: uid
  17 + }
17 }).then((result) => { 18 }).then((result) => {
18 if (verify) { 19 if (verify) {
19 return result; 20 return result;
@@ -34,11 +35,11 @@ module.exports = class extends global.yoho.BaseModel { @@ -34,11 +35,11 @@ module.exports = class extends global.yoho.BaseModel {
34 } 35 }
35 36
36 receiveCoupon(uid) { 37 receiveCoupon(uid) {
37 - return api.get('', { 38 + return this.get({
  39 + data: {
38 method: 'app.coupons.getFreePostCoupons', 40 method: 'app.coupons.getFreePostCoupons',
39 uid: uid 41 uid: uid
40 - }).then((result) => {  
41 - return result; 42 + }
42 }); 43 });
43 } 44 }
44 }; 45 };