Authored by 梁志锋

Merge remote-tracking branch 'remotes/origin/release/4.7'

<?php
namespace Plugin;
use Plugin\DataProcess\CouponFloorProcess;
/**
... ... @@ -380,10 +381,9 @@ class Helpers
}
if ($isApp && isset($articleData['share']['url'])) {
$shareUrl = explode("?", $articleData['share']['url'], 2); // 分享的链接取链接值
$paramId = explode("=", $shareUrl[1], 2); // 返回的链接取参数值
// 分享链接
$result['share'] = $shareUrl[0] . '?openby:yohobuy={"action":"go.share","params":{"title":"' . $articleData['title'] . '","content":"' . $articleData['intro'] . '","url":"' . $articleData['share']['url'] . '","param":{"id":"' . $paramId[1] . '"},"pic":""}}';
$result['share'] = $articleData['share']['url'] . '?openby:yohobuy={"action":"go.share","params":{"title":"' . $articleData['title'] . '","content":"' . $articleData['intro'] . '","url":"' . $articleData['share']['url'] . '","pic":"https:' . $result['img'] . '"}}';
}
// 判断是否显示作者信息
... ... @@ -393,7 +393,7 @@ class Helpers
}
//编辑人员 app跳转url处理 20160601
$isLogin = is_null($uid) ? 'N' : 'Y';
$articleData['author']['url'] = self::getUrlSafe($articleData['author']['url']) . '&openby:yohobuy={"action":"go.h5","params":{"param":{"id":"' . $articleData['author']['author_id'] . '"},"share":"","id":' . $articleData['author']['author_id'] . ',"type":0,"islogin":"' . $isLogin . '","url":"' . 'https:' . self::url('/author/index', array('uid' => $uid), 'guang') . '"}}';
$articleData['author']['url'] = self::getUrlSafe($articleData['author']['url']) . '&openby:yohobuy={"action":"go.h5","params":{"param":{"id":"' . $articleData['author']['author_id'] . '"},"share":"","id":' . $articleData['author']['author_id'] . ',"type":0,"islogin":"' . $isLogin . '","url":"' . 'https:' . self::url('/author/index', array('uid' => $uid), 'guang') . '"}}&uid=' . $uid;
$result['author'] = $articleData['author'];
if (isset($result['author']['avatar'])) {
$result['author']['avatar'] = strtr($result['author']['avatar'], array('http://' => '//'));
... ...
... ... @@ -1491,25 +1491,25 @@ function initInfosEvt($container) {
type: 'POST',
url: '/guang/opt/collectArticle',
data: {
id: $info.data('id'),
id: getUrlParam('id'),
opt: opt,
yh_channel: yhChannel
yh_channel: yhChannel,
uid: getUrlParam('uid')
},
success: function(data) {
if (data.code && data.code === 200) {
//切换收藏状态
$btn.toggleClass('collected');
}
if (data.code && data.code === 400 && data.data.jumpUrl) {
if (yhChannel) {
if (data.data.jump) {
if ($('#intimacy-link').length <= 0) {
$('body').append('<a href=\'' + data.data.jumpUrl + '\' style="display:none;" id="intimacy-link">' +
$('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');
}
}
},
... ...
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
... ... @@ -160,25 +160,25 @@ function initInfosEvt($container) {
type: 'POST',
url: '/guang/opt/collectArticle',
data: {
id: $info.data('id'),
id: getUrlParam('id'),
opt: opt,
yh_channel: yhChannel
yh_channel: yhChannel,
uid: getUrlParam('uid')
},
success: function(data) {
if (data.code && data.code === 200) {
//切换收藏状态
$btn.toggleClass('collected');
}
if (data.code && data.code === 400 && data.data.jumpUrl) {
if (yhChannel) {
if (data.data.jump) {
if ($('#intimacy-link').length <= 0) {
$('body').append('<a href=\'' + data.data.jumpUrl + '\' style="display:none;" id="intimacy-link">' +
$('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');
}
}
},
... ...
... ... @@ -9,9 +9,7 @@
<span class="like-count">{{count}}</span>
{{/ like}}
{{# collect}}
<a href={{url}}>
<i class="iconfont collect-btn{{#isCollected}} collected{{/isCollected}}">&#xe605;</i>
</a>
<i class="iconfont collect-btn{{#isCollected}} collected{{/isCollected}}">&#xe605;</i>
{{/ collect}}
{{# share}}
<a href="{{.}}" class="iconfont share-btn">&#xe600;</a>
... ...
... ... @@ -52,19 +52,21 @@ class OptController extends AbstractAction
*/
public function collectArticleAction()
{
$result = array('code' => 400, 'message' => '您未登录,无法收藏或者取消收藏。请先登录!', 'data' => '');
$result = array('code' => 200, 'message' => '成功!', 'data' => '');
$jumpUrl = '';
$isNoLogin = false;
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;
}
... ... @@ -72,31 +74,28 @@ class OptController extends AbstractAction
$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('/' => '\\/'));
if ($isNoLogin) {
$jumpUrl = $playUrl . '?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' . $playUrlEncode . '","param":{"from":"app","id"'.$id.'"yh_channel":'.$yhChannel.'}},"requesturl":{"url":"","param":{}},"priority":"N"}}';
} else {
$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"}}';
$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));
break;
} else {
/* 执行点赞或取消操作 */
$opt = $this->post('opt', 'ok');
$data = OptData::collectArticle($uid, $id, $opt);
if (!$data) {
$result = array('code' => 400, 'message' => '操作失败', 'data' => '');
break;
}
}
}
/* 执行点赞或取消操作 */
$opt = $this->post('opt', 'ok');
$data = OptData::collectArticle($uid, $id, $opt);
if (!$data) {
$result = array('code' => 400, 'message' => '操作失败', 'data' => '');
break;
}
if ($isNoLogin) {
$result = array('code' => 400, 'message' => '未登录', 'data' => array('jumpUrl' => $jumpUrl));
} else {
$result = array('code' => 200, 'message' => '成功', 'data' => '');
} else { /* 非 app 不需要点赞*/
$result = array('code' => 400, 'message' => '不是App!', 'data' => '');
}
} while (false);
... ...