Merge remote-tracking branch 'origin/hotfix/shopfav'
Showing
4 changed files
with
18 additions
and
25 deletions
@@ -597,8 +597,11 @@ if ($brandHeader.length > 0) { | @@ -597,8 +597,11 @@ if ($brandHeader.length > 0) { | ||
597 | 597 | ||
598 | $.ajax({ | 598 | $.ajax({ |
599 | type: 'GET', | 599 | type: 'GET', |
600 | - url: postUrl, | 600 | + url: location.protocol + '//m.yohobuy.com' + postUrl, |
601 | data: postData, | 601 | data: postData, |
602 | + xhrFields: { | ||
603 | + withCredentials: true | ||
604 | + }, | ||
602 | success: function(data) { | 605 | success: function(data) { |
603 | if (data.code === 200) { | 606 | if (data.code === 200) { |
604 | $this.toggleClass('coled'); | 607 | $this.toggleClass('coled'); |
@@ -883,7 +883,9 @@ function postCollect(info) { | @@ -883,7 +883,9 @@ function postCollect(info) { | ||
883 | method: 'get', | 883 | method: 'get', |
884 | url: location.protocol + '//m.yohobuy.com' + info.url, | 884 | url: location.protocol + '//m.yohobuy.com' + info.url, |
885 | data: info.data, | 885 | data: info.data, |
886 | - | 886 | + xhrFields: { |
887 | + withCredentials: true | ||
888 | + }, | ||
887 | success: function(data) { | 889 | success: function(data) { |
888 | 890 | ||
889 | if (data.code === 200) { | 891 | if (data.code === 200) { |
@@ -631,7 +631,8 @@ class IndexController extends AbstractAction | @@ -631,7 +631,8 @@ class IndexController extends AbstractAction | ||
631 | */ | 631 | */ |
632 | public function shopFavAction() | 632 | public function shopFavAction() |
633 | { | 633 | { |
634 | - header('Access-Control-Allow-Origin:*'); | 634 | + header('Access-Control-Allow-Origin:' . $_SERVER['HTTP_ORIGIN']); |
635 | + header('Access-Control-Allow-Credentials:true'); | ||
635 | $data = array(); | 636 | $data = array(); |
636 | $shopId = $this->get('shop_id', 0); | 637 | $shopId = $this->get('shop_id', 0); |
637 | $appVersion = $this->get('app_version', 0); | 638 | $appVersion = $this->get('app_version', 0); |
@@ -641,9 +642,6 @@ class IndexController extends AbstractAction | @@ -641,9 +642,6 @@ class IndexController extends AbstractAction | ||
641 | $uid = $this->getUid(); | 642 | $uid = $this->getUid(); |
642 | } | 643 | } |
643 | do { | 644 | do { |
644 | - // if (!$this->isAjax()) { | ||
645 | - // break; | ||
646 | - // } | ||
647 | if (empty($uid)) { | 645 | if (empty($uid)) { |
648 | $data['code'] = 401; | 646 | $data['code'] = 401; |
649 | $refer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; | 647 | $refer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; |
@@ -667,7 +665,8 @@ class IndexController extends AbstractAction | @@ -667,7 +665,8 @@ class IndexController extends AbstractAction | ||
667 | */ | 665 | */ |
668 | public function cancelShopFavAction() | 666 | public function cancelShopFavAction() |
669 | { | 667 | { |
670 | - header('Access-Control-Allow-Origin:*'); | 668 | + header('Access-Control-Allow-Origin:' . $_SERVER['HTTP_ORIGIN']); |
669 | + header('Access-Control-Allow-Credentials:true'); | ||
671 | $data = array(); | 670 | $data = array(); |
672 | $shopId = $this->get('shop_id', 0); | 671 | $shopId = $this->get('shop_id', 0); |
673 | $appVersion = $this->get('app_version', 0); | 672 | $appVersion = $this->get('app_version', 0); |
@@ -676,14 +675,9 @@ class IndexController extends AbstractAction | @@ -676,14 +675,9 @@ class IndexController extends AbstractAction | ||
676 | } else { | 675 | } else { |
677 | $uid = $this->getUid(); | 676 | $uid = $this->getUid(); |
678 | } | 677 | } |
679 | - do { | ||
680 | - // if (!$this->isAjax()) { | ||
681 | - // break; | ||
682 | - // } | ||
683 | - if (!empty($shopId) && !empty($uid)) { | ||
684 | - $data = ShopData::cancelShopFav($uid, $shopId); | ||
685 | - } | ||
686 | - } while(false); | 678 | + if (!empty($shopId) && !empty($uid)) { |
679 | + $data = ShopData::cancelShopFav($uid, $shopId); | ||
680 | + } | ||
687 | $this->echoJson($data); | 681 | $this->echoJson($data); |
688 | } | 682 | } |
689 | 683 |
@@ -25,14 +25,11 @@ class OptController extends AbstractAction | @@ -25,14 +25,11 @@ class OptController extends AbstractAction | ||
25 | */ | 25 | */ |
26 | public function favoriteBrandAction() | 26 | public function favoriteBrandAction() |
27 | { | 27 | { |
28 | + header('Access-Control-Allow-Origin:' . $_SERVER['HTTP_ORIGIN']); | ||
29 | + header('Access-Control-Allow-Credentials:true'); | ||
28 | $result = array('code' => 401, 'message' => '参数不正确', 'data' => false); | 30 | $result = array('code' => 401, 'message' => '参数不正确', 'data' => false); |
29 | 31 | ||
30 | do { | 32 | do { |
31 | - /* 判断是否是AJAX请求 */ | ||
32 | - if (!$this->isAjax()) { | ||
33 | - break; | ||
34 | - } | ||
35 | - | ||
36 | /* 判断品牌ID是否有效 */ | 33 | /* 判断品牌ID是否有效 */ |
37 | $id = $this->post('id'); | 34 | $id = $this->post('id'); |
38 | if (!is_numeric($id)) { | 35 | if (!is_numeric($id)) { |
@@ -74,14 +71,11 @@ class OptController extends AbstractAction | @@ -74,14 +71,11 @@ class OptController extends AbstractAction | ||
74 | */ | 71 | */ |
75 | public function favoriteProductAction() | 72 | public function favoriteProductAction() |
76 | { | 73 | { |
74 | + header('Access-Control-Allow-Origin:' . $_SERVER['HTTP_ORIGIN']); | ||
75 | + header('Access-Control-Allow-Credentials:true'); | ||
77 | $result = array('code' => 401, 'message' => '参数不正确', 'data' => false); | 76 | $result = array('code' => 401, 'message' => '参数不正确', 'data' => false); |
78 | 77 | ||
79 | do { | 78 | do { |
80 | - /* 判断是否是AJAX请求 */ | ||
81 | - if (!$this->isAjax()) { | ||
82 | - break; | ||
83 | - } | ||
84 | - | ||
85 | /* 判断品牌ID是否有效 */ | 79 | /* 判断品牌ID是否有效 */ |
86 | $id = $this->post('id'); | 80 | $id = $this->post('id'); |
87 | if (!is_numeric($id)) { | 81 | if (!is_numeric($id)) { |
-
Please register or login to post a comment