diff --git a/apps/product/controllers/list.js b/apps/product/controllers/list.js index 0a1869c..a780d60 100644 --- a/apps/product/controllers/list.js +++ b/apps/product/controllers/list.js @@ -486,6 +486,8 @@ const userCoupon = (req, res, next) => { let cryptCouponId = crypto.decrypt('', req.body.couponID); let uid = req.body.uid || req.user.uid; + let isApp = req.body.app_version || req.body.appVersion || false; + let data = {}; if (uid) { listModel.receiveCoupon( @@ -496,32 +498,19 @@ const userCoupon = (req, res, next) => { return; }).catch(next); } else { + data.code = 4401;// 401错误已经被接口占用 let refer = req.get('referer'); + let toUrl = helpers.urlFormat('/signin.html', {refer: refer}); - if (req.yoho.isApp !== 'false') { - let toUrl = refer + '&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' + - refer + + if (isApp) { + toUrl += '&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' + refer + '","param":{}},"requesturl":{"param":{"method":"app.promotion.getCoupon","couponId":"' + - cryptCouponId + - '"},"url":"' + - _.get(global, 'yoho.API.ApiUrl', '') + - '"},"priority":"Y"}}'; - - res.json({ - code: 4401, - url: toUrl - }); - - } else { - res.json({ - code: 4401, - url: helpers.urlFormat('/signin.html', {refer: refer}) - }); + cryptCouponId + '"},"url":"' + _.get(global, 'yoho.API.ApiUrl', '') + '"},"priority":"Y"}}'; } - + data.url = toUrl; + res.json(data); } - }; /** @@ -554,14 +543,14 @@ const getShopCouponsList = (req, res, next) => { */ const getBrandCouponsList = (req, res, next) => { let uid = req.query.uid || req.user.uid; - let shopId = req.query.shopId; + let brandId = req.query.brandId; let param = {}; if (uid) { param.uid = uid; } - param.shop_id = shopId; + param.brand_id = brandId; listModel.brandCouponsList(param).then(result => { res.json(result); @@ -579,5 +568,6 @@ module.exports = { baseShopFav, shopCategory, userCoupon, - getShopCouponsList + getShopCouponsList, + getBrandCouponsList }; diff --git a/apps/product/models/list.js b/apps/product/models/list.js index cf37e7d..4607841 100644 --- a/apps/product/models/list.js +++ b/apps/product/models/list.js @@ -877,7 +877,23 @@ const brandCouponsList = (params) => { let shopCoupons = []; let couPonstatus; - console.log(result, '===='); + if (result.data && result.data.coupons) { + _.forEach(result.data.coupons, value => { + couPonstatus = parseInt(value.status, 10); + + if (couPonstatus === 1 || couPonstatus === 3) { + shopCoupons.push({ + validity: value.couponValidity, + id: crypto.encryption('', value.coupon_id + ''), + name: value.coupon_name, + pic: value.coupon_pic, + money: parseInt(value.money, 10), + status: couPonstatus === 1 + }); + } + }); + } + return { couponsOne: shopCoupons.length <= 1, coupons: shopCoupons diff --git a/apps/product/router.js b/apps/product/router.js index 4b0b3f1..03155df 100644 --- a/apps/product/router.js +++ b/apps/product/router.js @@ -127,6 +127,7 @@ router.get('/index/baseShopFav', list.baseShopFav); router.get('/index/category', list.shopCategory); router.post('/index/userCoupon', list.userCoupon); router.get('/index/getShopCouponsList', list.getShopCouponsList); +router.get('/index/getBrandCouponsList', list.getBrandCouponsList); // 店铺介绍 router.get('/index/intro', list.shopIntro); diff --git a/public/js/product/shop/shop-coupon.js b/public/js/product/shop/shop-coupon.js index 9365f81..02ea02e 100644 --- a/public/js/product/shop/shop-coupon.js +++ b/public/js/product/shop/shop-coupon.js @@ -6,7 +6,6 @@ require('../../common'); var shopCoupon = {}; -console.log($('.shop-id').val(), $('.shop-id').val() === '', '==='); shopCoupon = { common: { appVersion: window.queryString.app_version || window.queryString.appVersion, @@ -22,9 +21,9 @@ shopCoupon = { var that = this, _url = location.protocol + '//m.yohobuy.com'; if (that.common.shopId === '') { - _url = '/product/index/getBrandCouponsList'; + _url += '/product/index/getBrandCouponsList'; } else { - _url = '/product/index/getShopCouponsList'; + _url += '/product/index/getShopCouponsList'; } $.ajax({ @@ -64,8 +63,9 @@ shopCoupon = { $.ajax({ method: 'POST', - url: location.protocol + '//m.yohobuy.com/product/index/userCoupon', + url: '/product/index/userCoupon', data: { + appVersion: $self.common.appVersion, couponID: code, uid: $self.common.uid }, diff --git a/public/scss/product/search/_list.css b/public/scss/product/search/_list.css index 3985df9..59fb65a 100644 --- a/public/scss/product/search/_list.css +++ b/public/scss/product/search/_list.css @@ -151,7 +151,7 @@ bottom: 0; background: rgba(0, 0, 0, 0.3); padding: 88px 0; - z-index: 1; + z-index: 10; overflow: auto; .brand-intro { diff --git a/public/scss/product/shop/_shop-index-coupon.css b/public/scss/product/shop/_shop-index-coupon.css index f57c540..fb40167 100644 --- a/public/scss/product/shop/_shop-index-coupon.css +++ b/public/scss/product/shop/_shop-index-coupon.css @@ -85,7 +85,7 @@ .coupon-left .coupon-left-name { font-size: 18px; width: 150px; - height: 45px; + height: 50px; line-height: 24px; padding-top: 2px; overflow: hidden;