Showing
6 changed files
with
37 additions
and
30 deletions
@@ -486,6 +486,8 @@ const userCoupon = (req, res, next) => { | @@ -486,6 +486,8 @@ const userCoupon = (req, res, next) => { | ||
486 | 486 | ||
487 | let cryptCouponId = crypto.decrypt('', req.body.couponID); | 487 | let cryptCouponId = crypto.decrypt('', req.body.couponID); |
488 | let uid = req.body.uid || req.user.uid; | 488 | let uid = req.body.uid || req.user.uid; |
489 | + let isApp = req.body.app_version || req.body.appVersion || false; | ||
490 | + let data = {}; | ||
489 | 491 | ||
490 | if (uid) { | 492 | if (uid) { |
491 | listModel.receiveCoupon( | 493 | listModel.receiveCoupon( |
@@ -496,32 +498,19 @@ const userCoupon = (req, res, next) => { | @@ -496,32 +498,19 @@ const userCoupon = (req, res, next) => { | ||
496 | return; | 498 | return; |
497 | }).catch(next); | 499 | }).catch(next); |
498 | } else { | 500 | } else { |
501 | + data.code = 4401;// 401错误已经被接口占用 | ||
499 | let refer = req.get('referer'); | 502 | let refer = req.get('referer'); |
503 | + let toUrl = helpers.urlFormat('/signin.html', {refer: refer}); | ||
500 | 504 | ||
501 | - if (req.yoho.isApp !== 'false') { | ||
502 | - let toUrl = refer + '&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' + | ||
503 | - refer + | 505 | + if (isApp) { |
506 | + toUrl += '&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' + refer + | ||
504 | '","param":{}},"requesturl":{"param":{"method":"app.promotion.getCoupon","couponId":"' + | 507 | '","param":{}},"requesturl":{"param":{"method":"app.promotion.getCoupon","couponId":"' + |
505 | - cryptCouponId + | ||
506 | - '"},"url":"' + | ||
507 | - _.get(global, 'yoho.API.ApiUrl', '') + | ||
508 | - '"},"priority":"Y"}}'; | ||
509 | - | ||
510 | - res.json({ | ||
511 | - code: 4401, | ||
512 | - url: toUrl | ||
513 | - }); | ||
514 | - | ||
515 | - } else { | ||
516 | - res.json({ | ||
517 | - code: 4401, | ||
518 | - url: helpers.urlFormat('/signin.html', {refer: refer}) | ||
519 | - }); | 508 | + cryptCouponId + '"},"url":"' + _.get(global, 'yoho.API.ApiUrl', '') + '"},"priority":"Y"}}'; |
520 | } | 509 | } |
521 | 510 | ||
522 | - | 511 | + data.url = toUrl; |
512 | + res.json(data); | ||
523 | } | 513 | } |
524 | - | ||
525 | }; | 514 | }; |
526 | 515 | ||
527 | /** | 516 | /** |
@@ -554,14 +543,14 @@ const getShopCouponsList = (req, res, next) => { | @@ -554,14 +543,14 @@ const getShopCouponsList = (req, res, next) => { | ||
554 | */ | 543 | */ |
555 | const getBrandCouponsList = (req, res, next) => { | 544 | const getBrandCouponsList = (req, res, next) => { |
556 | let uid = req.query.uid || req.user.uid; | 545 | let uid = req.query.uid || req.user.uid; |
557 | - let shopId = req.query.shopId; | 546 | + let brandId = req.query.brandId; |
558 | let param = {}; | 547 | let param = {}; |
559 | 548 | ||
560 | if (uid) { | 549 | if (uid) { |
561 | param.uid = uid; | 550 | param.uid = uid; |
562 | } | 551 | } |
563 | 552 | ||
564 | - param.shop_id = shopId; | 553 | + param.brand_id = brandId; |
565 | 554 | ||
566 | listModel.brandCouponsList(param).then(result => { | 555 | listModel.brandCouponsList(param).then(result => { |
567 | res.json(result); | 556 | res.json(result); |
@@ -579,5 +568,6 @@ module.exports = { | @@ -579,5 +568,6 @@ module.exports = { | ||
579 | baseShopFav, | 568 | baseShopFav, |
580 | shopCategory, | 569 | shopCategory, |
581 | userCoupon, | 570 | userCoupon, |
582 | - getShopCouponsList | 571 | + getShopCouponsList, |
572 | + getBrandCouponsList | ||
583 | }; | 573 | }; |
@@ -877,7 +877,23 @@ const brandCouponsList = (params) => { | @@ -877,7 +877,23 @@ const brandCouponsList = (params) => { | ||
877 | let shopCoupons = []; | 877 | let shopCoupons = []; |
878 | let couPonstatus; | 878 | let couPonstatus; |
879 | 879 | ||
880 | - console.log(result, '===='); | 880 | + if (result.data && result.data.coupons) { |
881 | + _.forEach(result.data.coupons, value => { | ||
882 | + couPonstatus = parseInt(value.status, 10); | ||
883 | + | ||
884 | + if (couPonstatus === 1 || couPonstatus === 3) { | ||
885 | + shopCoupons.push({ | ||
886 | + validity: value.couponValidity, | ||
887 | + id: crypto.encryption('', value.coupon_id + ''), | ||
888 | + name: value.coupon_name, | ||
889 | + pic: value.coupon_pic, | ||
890 | + money: parseInt(value.money, 10), | ||
891 | + status: couPonstatus === 1 | ||
892 | + }); | ||
893 | + } | ||
894 | + }); | ||
895 | + } | ||
896 | + | ||
881 | return { | 897 | return { |
882 | couponsOne: shopCoupons.length <= 1, | 898 | couponsOne: shopCoupons.length <= 1, |
883 | coupons: shopCoupons | 899 | coupons: shopCoupons |
@@ -127,6 +127,7 @@ router.get('/index/baseShopFav', list.baseShopFav); | @@ -127,6 +127,7 @@ router.get('/index/baseShopFav', list.baseShopFav); | ||
127 | router.get('/index/category', list.shopCategory); | 127 | router.get('/index/category', list.shopCategory); |
128 | router.post('/index/userCoupon', list.userCoupon); | 128 | router.post('/index/userCoupon', list.userCoupon); |
129 | router.get('/index/getShopCouponsList', list.getShopCouponsList); | 129 | router.get('/index/getShopCouponsList', list.getShopCouponsList); |
130 | +router.get('/index/getBrandCouponsList', list.getBrandCouponsList); | ||
130 | 131 | ||
131 | // 店铺介绍 | 132 | // 店铺介绍 |
132 | router.get('/index/intro', list.shopIntro); | 133 | router.get('/index/intro', list.shopIntro); |
@@ -6,7 +6,6 @@ require('../../common'); | @@ -6,7 +6,6 @@ require('../../common'); | ||
6 | 6 | ||
7 | var shopCoupon = {}; | 7 | var shopCoupon = {}; |
8 | 8 | ||
9 | -console.log($('.shop-id').val(), $('.shop-id').val() === '', '==='); | ||
10 | shopCoupon = { | 9 | shopCoupon = { |
11 | common: { | 10 | common: { |
12 | appVersion: window.queryString.app_version || window.queryString.appVersion, | 11 | appVersion: window.queryString.app_version || window.queryString.appVersion, |
@@ -22,9 +21,9 @@ shopCoupon = { | @@ -22,9 +21,9 @@ shopCoupon = { | ||
22 | var that = this, _url = location.protocol + '//m.yohobuy.com'; | 21 | var that = this, _url = location.protocol + '//m.yohobuy.com'; |
23 | 22 | ||
24 | if (that.common.shopId === '') { | 23 | if (that.common.shopId === '') { |
25 | - _url = '/product/index/getBrandCouponsList'; | 24 | + _url += '/product/index/getBrandCouponsList'; |
26 | } else { | 25 | } else { |
27 | - _url = '/product/index/getShopCouponsList'; | 26 | + _url += '/product/index/getShopCouponsList'; |
28 | } | 27 | } |
29 | 28 | ||
30 | $.ajax({ | 29 | $.ajax({ |
@@ -64,8 +63,9 @@ shopCoupon = { | @@ -64,8 +63,9 @@ shopCoupon = { | ||
64 | 63 | ||
65 | $.ajax({ | 64 | $.ajax({ |
66 | method: 'POST', | 65 | method: 'POST', |
67 | - url: location.protocol + '//m.yohobuy.com/product/index/userCoupon', | 66 | + url: '/product/index/userCoupon', |
68 | data: { | 67 | data: { |
68 | + appVersion: $self.common.appVersion, | ||
69 | couponID: code, | 69 | couponID: code, |
70 | uid: $self.common.uid | 70 | uid: $self.common.uid |
71 | }, | 71 | }, |
@@ -151,7 +151,7 @@ | @@ -151,7 +151,7 @@ | ||
151 | bottom: 0; | 151 | bottom: 0; |
152 | background: rgba(0, 0, 0, 0.3); | 152 | background: rgba(0, 0, 0, 0.3); |
153 | padding: 88px 0; | 153 | padding: 88px 0; |
154 | - z-index: 1; | 154 | + z-index: 10; |
155 | overflow: auto; | 155 | overflow: auto; |
156 | 156 | ||
157 | .brand-intro { | 157 | .brand-intro { |
@@ -85,7 +85,7 @@ | @@ -85,7 +85,7 @@ | ||
85 | .coupon-left .coupon-left-name { | 85 | .coupon-left .coupon-left-name { |
86 | font-size: 18px; | 86 | font-size: 18px; |
87 | width: 150px; | 87 | width: 150px; |
88 | - height: 45px; | 88 | + height: 50px; |
89 | line-height: 24px; | 89 | line-height: 24px; |
90 | padding-top: 2px; | 90 | padding-top: 2px; |
91 | overflow: hidden; | 91 | overflow: hidden; |
-
Please register or login to post a comment