Authored by 周少峰

Merge branch 'release/4.8' of http://git.yoho.cn/fe/yohobuywap into release/4.8

... ... @@ -372,7 +372,14 @@ class Helpers
if ($isApp) {
$result['collect'] = array();
$result['collect']['isCollected'] = isset($articleData['isFavor']) && $articleData['isFavor'] === 'Y';
$result['collect']['url'] = !empty($uid) ? 'javascript:;' : strtr($articleData['url'], array('"islogin":"N"' => '"islogin":"Y"'));
// $originUrl = 'http:' . Helpers::url('/author/index',null,'guang') . $_SERVER["QUERY_STRING"]; // 跳转回的链接 https
$originUrl = Helpers::url('/author/index',null,'guang') . $_SERVER["QUERY_STRING"]; // 跳转回的链接
$collectUrl = 'javascript:;'; // 根据用户是否登录做处理的链接
if (empty($uid)) {
$playUrlEncode = strtr($originUrl, array('/' => '\\/'));
$collectUrl = $originUrl . '?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' . $playUrlEncode . '","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"N"}}';
}
$result['collect']['url'] = $collectUrl;
} // 点赞
else {
$result['like'] = array();
... ...
... ... @@ -160,27 +160,17 @@ function initInfosEvt($container) {
type: 'POST',
url: '/guang/opt/collectArticle',
data: {
id: getUrlParam('id'),
id: $info.data('id'),
opt: opt,
yh_channel: yhChannel,
uid: getUrlParam('uid')
},
success: function(data) {
if (data.code && data.code === 200) {
if (data.data.jump) {
if ($('#intimacy-link').length <= 0) {
$('body').append('<a href=\'' + data.data.jumpUrl +
'\' style="display:none;" id="intimacy-link">' +
'<span class="intimacy-link"></span></a>');
}
$('.intimacy-link').click();
} else {
//切换收藏状态
$btn.toggleClass('collected');
}
}
},
error: function() {
tip.show('网络断开连接了~');
... ...
... ... @@ -9,7 +9,9 @@
<span class="like-count">{{count}}</span>
{{/ like}}
{{# collect}}
<a href={{url}}>
<i class="iconfont collect-btn{{#isCollected}} collected{{/isCollected}}">&#xe605;</i>
</a>
{{/ collect}}
{{# share}}
<a href="{{.}}" class="iconfont share-btn">&#xe600;</a>
... ...
... ... @@ -52,39 +52,25 @@ class OptController extends AbstractAction
*/
public function collectArticleAction()
{
$result = array('code' => 200, 'message' => '成功!', 'data' => '');
$jumpUrl = '';
$isNoLogin = false;
$result = array('code' => 400, 'message' => '您未登录,无法收藏或者取消收藏。请先登录!', 'data' => '');
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
$result = array('code' => 400, 'message' => '不是Ajax请求!', 'data' => '');
break;
}
/* 判断参数是否有效 */
$id = $this->post('id');
if (!is_numeric($id)) {
$result = array('code' => 400, 'message' => '没有ID!', 'data' => '');
break;
}
/* 判断用户是否登录 */
$uid = $this->get('uid');
$isNoLogin = empty($uid) || !is_numeric($uid);
/* 如果有 yh_channel 是 app */
if ($yhChannel = $this->post('yh_channel')) {
/* 如果没有登录,拼接 App 登录规则 */
if ($isNoLogin) {
$playUrl = Helpers::url('/author/index', '', 'guang');
$playUrlEncode = strtr($playUrl, array('/' => '\\/'));
$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;
$result = array('code' => 200, 'message' => '未登录', 'data' => array('jumpUrl' => $jumpUrl, 'jump' => true));
$uid = $this->post('uid');
if (empty($uid) || !is_numeric($uid)) {
break;
} else {
}
/* 执行点赞或取消操作 */
$opt = $this->post('opt', 'ok');
... ... @@ -93,10 +79,8 @@ class OptController extends AbstractAction
$result = array('code' => 400, 'message' => '操作失败', 'data' => '');
break;
}
}
} else { /* 非 app 不需要点赞*/
$result = array('code' => 400, 'message' => '不是App!', 'data' => '');
}
$result = array('code' => 200, 'message' => '成功', 'data' => '');
} while (false);
$this->echoJson($result);
... ...