Authored by ccbikai(👎🏻🍜)

收券需求传入 code 和 uid

@@ -18,6 +18,7 @@ const couponData = (params) => { @@ -18,6 +18,7 @@ const couponData = (params) => {
18 elem.bestowLink = helpers.urlFormat('/product/index/index', 18 elem.bestowLink = helpers.urlFormat('/product/index/index',
19 { 19 {
20 coupon_id: elem.couponId, 20 coupon_id: elem.couponId,
  21 + coupon_code: elem.couponCode,
21 title: '优惠活动商品', 22 title: '优惠活动商品',
22 intro_text: `以下商品可使用【${elem.couponDetailInfomation}】优惠券` 23 intro_text: `以下商品可使用【${elem.couponDetailInfomation}】优惠券`
23 } 24 }
@@ -249,9 +249,18 @@ const search = (req, res, next) => { @@ -249,9 +249,18 @@ const search = (req, res, next) => {
249 * 筛选 249 * 筛选
250 */ 250 */
251 let filter = (req, res, next) => { 251 let filter = (req, res, next) => {
252 - res.header('Access-Control-Allow-Origin', '*'); 252 + let allowOrigin = _.get(req, 'headers.origin', null) ?
  253 + req.headers.origin : req.protocol + '://' + req.headers.host;
  254 +
  255 + res.setHeader('Access-Control-Allow-Origin', allowOrigin);
  256 + res.setHeader('Access-Control-Allow-Credentials', 'true');
253 257
254 let params = Object.assign({}, req.query); 258 let params = Object.assign({}, req.query);
  259 + let uid = req.user.uid || 0;
  260 +
  261 + if (uid) {
  262 + params.uid = uid;
  263 + }
255 264
256 searchModel.getFilterData(params).then((result) => { 265 searchModel.getFilterData(params).then((result) => {
257 res.render('search/filter', { 266 res.render('search/filter', {
@@ -178,7 +178,7 @@ const _searchGoods = (params) => { @@ -178,7 +178,7 @@ const _searchGoods = (params) => {
178 } 178 }
179 179
180 // 个人中心优惠券立即使用 - 商品列表 180 // 个人中心优惠券立即使用 - 商品列表
181 - if (params.coupon_id) { 181 + if (params.coupon_id || params.coupon_code) {
182 method = 'app.search.coupon'; 182 method = 'app.search.coupon';
183 } 183 }
184 184
@@ -38,6 +38,7 @@ let $input = $('#search-input').find('input[name="query"]'), @@ -38,6 +38,7 @@ let $input = $('#search-input').find('input[name="query"]'),
38 38
39 let shopId, sort, brand, outlets, app_type, age_level, msort, misort, coin, app_version, students, couponId, searchFrom; 39 let shopId, sort, brand, outlets, app_type, age_level, msort, misort, coin, app_version, students, couponId, searchFrom;
40 let size, color, style, standard, gender, price, p_d, oldquery, query, limited, specialoffer, specialsale_id, promotion; 40 let size, color, style, standard, gender, price, p_d, oldquery, query, limited, specialoffer, specialsale_id, promotion;
  41 +let couponCode;
41 42
42 // 默认筛选条件 43 // 默认筛选条件
43 let defaultOpt = require('common/query-param'); 44 let defaultOpt = require('common/query-param');
@@ -248,6 +249,7 @@ specialsale_id = getQueryString('specialsale_id'); @@ -248,6 +249,7 @@ specialsale_id = getQueryString('specialsale_id');
248 promotion = getQueryString('promotion'); 249 promotion = getQueryString('promotion');
249 students = getQueryString('students'); 250 students = getQueryString('students');
250 couponId = getQueryString('coupon_id'); 251 couponId = getQueryString('coupon_id');
  252 +couponCode = getQueryString('coupon_code');
251 searchFrom = getQueryString('from'); 253 searchFrom = getQueryString('from');
252 254
253 if ($fsgc.children().length > 0) { 255 if ($fsgc.children().length > 0) {
@@ -523,6 +525,10 @@ function search(opt) { @@ -523,6 +525,10 @@ function search(opt) {
523 params.coupon_id = couponId; 525 params.coupon_id = couponId;
524 } 526 }
525 527
  528 + if (couponCode) {
  529 + params.coupon_code = couponCode;
  530 + }
  531 +
526 if (searchFrom) { 532 if (searchFrom) {
527 params.from = searchFrom; 533 params.from = searchFrom;
528 } 534 }
@@ -856,10 +862,17 @@ if ($brandHeader.data('isbaseshop') === true) { @@ -856,10 +862,17 @@ if ($brandHeader.data('isbaseshop') === true) {
856 pars.coupon_id = couponId; 862 pars.coupon_id = couponId;
857 } 863 }
858 864
  865 + if (couponCode) {
  866 + pars.coupon_code = couponCode;
  867 + }
  868 +
859 $.extend(defaultOpt, pars); 869 $.extend(defaultOpt, pars);
860 $.ajax({ 870 $.ajax({
861 type: 'GET', 871 type: 'GET',
862 url: location.protocol + '//m.yohobuy.com/product/search/filter', 872 url: location.protocol + '//m.yohobuy.com/product/search/filter',
  873 + xhrFields: {
  874 + withCredentials: true
  875 + },
863 data: defaultOpt, 876 data: defaultOpt,
864 success: function(data) { 877 success: function(data) {
865 if (data === '') { 878 if (data === '') {