Authored by 郭成尧

Merge branch 'hotfix/guangFav' into release/4.8

@@ -372,7 +372,14 @@ class Helpers @@ -372,7 +372,14 @@ class Helpers
372 if ($isApp) { 372 if ($isApp) {
373 $result['collect'] = array(); 373 $result['collect'] = array();
374 $result['collect']['isCollected'] = isset($articleData['isFavor']) && $articleData['isFavor'] === 'Y'; 374 $result['collect']['isCollected'] = isset($articleData['isFavor']) && $articleData['isFavor'] === 'Y';
375 - $result['collect']['url'] = !empty($uid) ? 'javascript:;' : strtr($articleData['url'], array('"islogin":"N"' => '"islogin":"Y"')); 375 +// $originUrl = 'http:' . Helpers::url('/author/index',null,'guang') . $_SERVER["QUERY_STRING"]; // 跳转回的链接 https
  376 + $originUrl = Helpers::url('/author/index',null,'guang') . $_SERVER["QUERY_STRING"]; // 跳转回的链接
  377 + $collectUrl = 'javascript:;'; // 根据用户是否登录做处理的链接
  378 + if (empty($uid)) {
  379 + $playUrlEncode = strtr($originUrl, array('/' => '\\/'));
  380 + $collectUrl = $originUrl . '?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' . $playUrlEncode . '","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"N"}}';
  381 + }
  382 + $result['collect']['url'] = $collectUrl;
376 } // 点赞 383 } // 点赞
377 else { 384 else {
378 $result['like'] = array(); 385 $result['like'] = array();
@@ -160,26 +160,16 @@ function initInfosEvt($container) { @@ -160,26 +160,16 @@ function initInfosEvt($container) {
160 type: 'POST', 160 type: 'POST',
161 url: '/guang/opt/collectArticle', 161 url: '/guang/opt/collectArticle',
162 data: { 162 data: {
163 - id: getUrlParam('id'), 163 + id: $info.data('id'),
164 opt: opt, 164 opt: opt,
165 yh_channel: yhChannel, 165 yh_channel: yhChannel,
166 uid: getUrlParam('uid') 166 uid: getUrlParam('uid')
167 }, 167 },
168 success: function(data) { 168 success: function(data) {
169 if (data.code && data.code === 200) { 169 if (data.code && data.code === 200) {
170 - if (data.data.jump) {  
171 - if ($('#intimacy-link').length <= 0) {  
172 - $('body').append('<a href=\'' + data.data.jumpUrl +  
173 - '\' style="display:none;" id="intimacy-link">' +  
174 - '<span class="intimacy-link"></span></a>');  
175 - }  
176 -  
177 - $('.intimacy-link').click();  
178 - } else {  
179 -  
180 - //切换收藏状态  
181 - $btn.toggleClass('collected');  
182 - } 170 +
  171 + //切换收藏状态
  172 + $btn.toggleClass('collected');
183 } 173 }
184 }, 174 },
185 error: function() { 175 error: function() {
@@ -9,7 +9,9 @@ @@ -9,7 +9,9 @@
9 <span class="like-count">{{count}}</span> 9 <span class="like-count">{{count}}</span>
10 {{/ like}} 10 {{/ like}}
11 {{# collect}} 11 {{# collect}}
  12 + <a href={{url}}>
12 <i class="iconfont collect-btn{{#isCollected}} collected{{/isCollected}}">&#xe605;</i> 13 <i class="iconfont collect-btn{{#isCollected}} collected{{/isCollected}}">&#xe605;</i>
  14 + </a>
13 {{/ collect}} 15 {{/ collect}}
14 {{# share}} 16 {{# share}}
15 <a href="{{.}}" class="iconfont share-btn">&#xe600;</a> 17 <a href="{{.}}" class="iconfont share-btn">&#xe600;</a>
@@ -52,51 +52,35 @@ class OptController extends AbstractAction @@ -52,51 +52,35 @@ class OptController extends AbstractAction
52 */ 52 */
53 public function collectArticleAction() 53 public function collectArticleAction()
54 { 54 {
55 - $result = array('code' => 200, 'message' => '成功!', 'data' => '');  
56 - $jumpUrl = '';  
57 - $isNoLogin = false; 55 + $result = array('code' => 400, 'message' => '您未登录,无法收藏或者取消收藏。请先登录!', 'data' => '');
58 56
59 do { 57 do {
60 /* 判断是不是AJAX请求 */ 58 /* 判断是不是AJAX请求 */
61 if (!$this->isAjax()) { 59 if (!$this->isAjax()) {
62 - $result = array('code' => 400, 'message' => '不是Ajax请求!', 'data' => '');  
63 break; 60 break;
64 } 61 }
65 62
66 /* 判断参数是否有效 */ 63 /* 判断参数是否有效 */
67 $id = $this->post('id'); 64 $id = $this->post('id');
68 if (!is_numeric($id)) { 65 if (!is_numeric($id)) {
69 - $result = array('code' => 400, 'message' => '没有ID!', 'data' => '');  
70 break; 66 break;
71 } 67 }
72 68
73 /* 判断用户是否登录 */ 69 /* 判断用户是否登录 */
74 - $uid = $this->get('uid');  
75 - $isNoLogin = empty($uid) || !is_numeric($uid);  
76 -  
77 - /* 如果有 yh_channel 是 app */  
78 - if ($yhChannel = $this->post('yh_channel')) {  
79 -  
80 - /* 如果没有登录,拼接 App 登录规则 */  
81 - if ($isNoLogin) {  
82 - $playUrl = Helpers::url('/author/index', '', 'guang');  
83 - $playUrlEncode = strtr($playUrl, array('/' => '\\/'));  
84 - $jumpUrl = $playUrl . '?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' . $playUrlEncode . '","param":{"from":"app","id":"' . $id . '",""yh_channel":"' . $yhChannel . '",""uid":"' . $uid . '"}},"requesturl":{"url":"","param":{}},"priority":"N"}}&uid=' . $uid;  
85 - $result = array('code' => 200, 'message' => '未登录', 'data' => array('jumpUrl' => $jumpUrl, 'jump' => true));  
86 - break;  
87 - } else {  
88 -  
89 - /* 执行点赞或取消操作 */  
90 - $opt = $this->post('opt', 'ok');  
91 - $data = OptData::collectArticle($uid, $id, $opt);  
92 - if (!$data) {  
93 - $result = array('code' => 400, 'message' => '操作失败', 'data' => '');  
94 - break;  
95 - }  
96 - }  
97 - } else { /* 非 app 不需要点赞*/  
98 - $result = array('code' => 400, 'message' => '不是App!', 'data' => ''); 70 + $uid = $this->post('uid');
  71 + if (empty($uid) || !is_numeric($uid)) {
  72 + break;
  73 + }
  74 +
  75 + /* 执行点赞或取消操作 */
  76 + $opt = $this->post('opt', 'ok');
  77 + $data = OptData::collectArticle($uid, $id, $opt);
  78 + if (!$data) {
  79 + $result = array('code' => 400, 'message' => '操作失败', 'data' => '');
  80 + break;
99 } 81 }
  82 +
  83 + $result = array('code' => 200, 'message' => '成功', 'data' => '');
100 } while (false); 84 } while (false);
101 85
102 $this->echoJson($result); 86 $this->echoJson($result);