Authored by 郭成尧

'uid获取方式更改'

@@ -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'); 70 $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' => ''); 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);