Authored by 毕凯

Merge remote-tracking branch 'origin/feature/couponCenter' into release/6.1

@@ -285,10 +285,10 @@ exports.floor = (params, isApp, appVersion) => { @@ -285,10 +285,10 @@ exports.floor = (params, isApp, appVersion) => {
285 })(); 285 })();
286 }; 286 };
287 287
288 -exports.status = (params, isApp) => { 288 +exports.status = (params) => {
289 return Promise.coroutine(function*() { 289 return Promise.coroutine(function*() {
290 const resource = yield api.get('', Object.assign(params, { 290 const resource = yield api.get('', Object.assign(params, {
291 - method: 'app.promotion.queryCouponCenter' 291 + method: 'app.promotion.couponStatus'
292 })); 292 }));
293 const result = { 293 const result = {
294 code: resource.code, 294 code: resource.code,
@@ -296,13 +296,12 @@ exports.status = (params, isApp) => { @@ -296,13 +296,12 @@ exports.status = (params, isApp) => {
296 }; 296 };
297 297
298 if (resource && resource.code === 200 && resource.data.length) { 298 if (resource && resource.code === 200 && resource.data.length) {
299 - resource.data.forEach(function(d) {  
300 - if (d.template_name === 'getCoupon') {  
301 - if (d.data && d.data[0] && ['2', '3'].indexOf(d.data[0].status) > -1) {  
302 - result.data.push(processFun.getCoupon(d.data, isApp));  
303 - }  
304 - }  
305 - 299 + resource.data.forEach(function(val) {
  300 + result.data.push({
  301 + hasNum: val.hasNum,
  302 + couponId: crypto.encryption('yoho9646abcdefgh', String(val.couponId)),
  303 + status: val.status
  304 + });
306 }); 305 });
307 } 306 }
308 return result; 307 return result;
@@ -74,7 +74,7 @@ @@ -74,7 +74,7 @@
74 "xml2js": "^0.4.19", 74 "xml2js": "^0.4.19",
75 "yoho-express-session": "^2.0.0", 75 "yoho-express-session": "^2.0.0",
76 "yoho-md5": "^2.0.0", 76 "yoho-md5": "^2.0.0",
77 - "yoho-node-lib": "=0.3.4", 77 + "yoho-node-lib": "=0.3.5",
78 "yoho-zookeeper": "^1.0.8" 78 "yoho-zookeeper": "^1.0.8"
79 }, 79 },
80 "devDependencies": { 80 "devDependencies": {
@@ -18,6 +18,12 @@ function getUrlParam(name) { @@ -18,6 +18,12 @@ function getUrlParam(name) {
18 return window.queryString[name]; 18 return window.queryString[name];
19 } 19 }
20 20
  21 +// 券显示状态
  22 +function couponShow($parents, $sons) {
  23 + $parents.find('[class^=main-right-]').hide();
  24 + $parents.find(`.main-right-${$sons}`).show();
  25 +}
  26 +
21 // 获取领券状态 27 // 获取领券状态
22 setTimeout(function() { 28 setTimeout(function() {
23 let req = '', 29 let req = '',
@@ -43,28 +49,19 @@ setTimeout(function() { @@ -43,28 +49,19 @@ setTimeout(function() {
43 if (res.code === 200) { 49 if (res.code === 200) {
44 let cates = res.data || []; 50 let cates = res.data || [];
45 51
46 - cates.forEach(function(obj) {  
47 - let e = document.getElementById(obj.couponID);  
48 -  
49 - if (!e) {  
50 - return;  
51 - }  
52 -  
53 - let child = e.children;  
54 -  
55 - if (!child.length) {  
56 - return;  
57 - }  
58 -  
59 - for (let i = 0; i < child.length; i++) {  
60 - if (child[i].className.indexOf('receive') > -1) {  
61 - child[i].classList.add('hidden');  
62 - }  
63 -  
64 - if ((obj.isGeted && child[i].className.indexOf('use') > -1) ||  
65 - (obj.isZero && child[i].className.indexOf('go') > -1)) {  
66 - child[i].classList.remove('hidden');  
67 - } 52 + cates.forEach((obj) => {
  53 + let e = document.getElementById(obj.couponId);
  54 + let $e = $(e);
  55 + let status = obj.status;
  56 +
  57 + switch (status) {
  58 + case 1: couponShow($e, 'receive');
  59 + break;
  60 + case 2: couponShow($e, 'go');
  61 + break;
  62 + case 3: couponShow($e, 'use');
  63 + break;
  64 + default: couponShow($e, 'go');
68 } 65 }
69 }); 66 });
70 } 67 }