作者 景龙
1 个管道 的构建 通过 耗费 1 秒

测试微博

... ... @@ -15,6 +15,7 @@ use cmf\lib\Storage;
use think\Db;
use anerg\OAuth2\OAuth;
use think\Config;
use app\portal\model\PortalPostModel;
class LoginController extends HomeBaseController
{
... ... @@ -450,6 +451,7 @@ class LoginController extends HomeBaseController
$token = session('token');
$title = $this->request->post('title');//分享标题
$share_url = $this->request->post('share_url');//分享url
$article_id = $this->request->post('article_id');//分享文章id
$url = 'https://api.weibo.com/2/statuses/share.json';
$data = [
'access_token' => $token,
... ... @@ -460,6 +462,8 @@ class LoginController extends HomeBaseController
if(isset($json_arr['error_code'])&&!empty($json_arr['error_code'])){
$this->apiResponse(0,$json_arr['error']);
}
$postModel = new PortalPostModel();
$postModel->where('id',$article_id)->setInc('post_share_wb',1);
$this->apiResponse(1,'分享成功!');
}
... ...
... ... @@ -113,7 +113,7 @@
<input type="hidden" class="collection" value="">
<input type="hidden" class="like" value="">
<img src="__TMPL__/public/assets/starImg/aicon_89.png" alt="">
<img src="__TMPL__/public/assets/starImg/aicon_90.png" alt="">
<img src="__TMPL__/public/assets/starImg/aicon_90.png" alt="" class="wb_share">
<img id="collections" src="__TMPL__/public/assets/starImg/bicon_02.png" alt="">
<img id="likes" src="__TMPL__/public/assets/starImg/bicon_031.png" alt="">
</div>
... ...
... ... @@ -198,7 +198,7 @@ $(function() {
});
//微博分享
$('#wb_share').click(function() {
$('.wb_share').click(function() {
thirdShare('/portal/login/wb_share');
});
... ... @@ -212,10 +212,12 @@ $(function() {
function thirdShare(url){
var title = $(document).attr("title");
var share_url = window.location.href;
var article_id = getUrlParam('id');
$.ajax({
type: 'POST',
url: url,
data: {
'id': article_id,
'title': title,
'share_url': share_url
},
... ...
... ... @@ -19,11 +19,11 @@
<!-- wx分享 -->
<div class="wx_go weixin">
<img src="__TMPL__/public/assets/starImg/bicon_04.png" alt="">
<p>168</p>
<p>{$share.post_share_wx}</p>
</div>
<!-- wb分享 -->
<div class="wb_go weibo_share" id="wb_share">
<div class="wb_go wb_share">
<img src="__TMPL__/public/assets/starImg/bicon_05.png" alt="">
<p>168</p>
<p>{$share.post_share_wx}</p>
</div>
</div>
\ No newline at end of file
... ...
... ... @@ -138,7 +138,7 @@
<img src="__TMPL__/public/assets/images/cicon_71@2x.png" alt="" />
</div>
<div class="index_seventh_bottom_img1">
<img src="__TMPL__/public/assets/images/cicon_72@2x.png" alt="" />
<img src="__TMPL__/public/assets/images/cicon_72@2x.png" alt="" class="wb_share"/>
</div>
<div class="index_seventh_bottom_img2" style="margin-left:0.3rem;">
<img id="collections" src="__TMPL__/public/assets/images/bicon_02.png" alt="">
... ...
... ... @@ -231,19 +231,40 @@ $(function() {
}
window.open('http://v.t.sina.com.cn/share/share.php?' + temp.join('&'));
});
//微博分享
$('.wb_share').click(function() {
thirdShare('/portal/login/wb_share');
});
//微博登录
$('#wb_login').click(function(){
$('#wb_form').submit();
});
//分享到微信
// $('.weixin').click(function(){
// var target_url = "http://qr.liantu.com/api.php?text="+share_url;
// window.open(target_url, 'weixin', 'height=320, width=320');
// });
});
//第三方分享
function thirdShare(url){
var title = $(document).attr("title");
var share_url = window.location.href;
var article_id = getUrlParam('id');
$.ajax({
type: 'POST',
url: url,
data: {
'id': article_id,
'title': title,
'share_url': share_url
},
dataType: 'json',
async: false,
success: function(data) {
if (data.code == 1) {
mask(data.msg);
} else {
mask(data.msg);
}
}
});
}
//弹框
function mask(msg) {
$('.mask').text(msg);
... ...
... ... @@ -4,13 +4,13 @@
<div class="share1_Img weixin">
<img src="__TMPL__/public/assets/images/bicon_04.png" alt="" />
</div>
<p class="share1_Txt">3.6k</p>
<p class="share1_Txt">{$share.post_share_wx}</p>
</li>
<li class="share1">
<div class="share1_Img weibo">
<div class="share1_Img wb_share">
<img src="__TMPL__/public/assets/images/bicon_05.png" alt="" />
</div>
<p class="share1_Txt">168</p>
<p class="share1_Txt">{$share.post_share_wx}</p>
</li>
<!--收藏-->
<li class="share2">
... ...
... ... @@ -15,6 +15,7 @@ use app\admin\model\ThemeModel;
use think\View;
use app\portal\model\CollectionModel;
use app\portal\model\LikeModel;
use app\portal\model\PortalPostModel;
use think\Session;
class HomeBaseController extends BaseController
... ... @@ -34,6 +35,7 @@ class HomeBaseController extends BaseController
$this->getComment();
$this->is_collection();
$this->is_like();
$this->getShareCount();
$keyword = $this->request->param('keyword');
$this->assign('keyword',$keyword);
}
... ... @@ -385,4 +387,12 @@ hello;
}
}
//获取微信微博分享数量
public function getShareCount(){
$article_id = $this->request->param('id');//文章id
$postModel = new PortalPostModel();
$share = $postModel->where(['id'=>$article_id])->field('id,post_share_wx,post_share_wb')->find();
$this->assign('share',$share);
}
}
\ No newline at end of file
... ...