add-sylive-wx_share
This commit is contained in:
@@ -52,7 +52,6 @@ class Act extends Wx {
|
||||
$sub_redirect_url = urlencode(http_host_com('home') . '/h5/market/sylive/act/subscribemsg?skey=' . $skey
|
||||
. '&s_time=' . $row['timeStart']);
|
||||
$subscribemsg = "https://mp.weixin.qq.com/mp/subscribemsg?action=get_confirm&appid={$config['appid']}&scene=0&template_id=sdJ4eXXA3OdMZVkJdOrzusYLGr0Jpz9I7WiZurgGLBs&redirect_url={$sub_redirect_url}&reserved=test#wechat_redirect";
|
||||
|
||||
}
|
||||
}
|
||||
//浏览
|
||||
@@ -60,7 +59,6 @@ class Act extends Wx {
|
||||
$this->sylive_entity->kpi_log($params);
|
||||
$live_status = 0; //直播未开始
|
||||
if(time()>strtotime($row['timeStart']) && time()<=strtotime($row['timeEnd'])){ //直播期间人数
|
||||
$this->sylive_entity->kpi_log(['a_id' => $a_id, 'uid' => $this->uid,'cf_uid' => $act_user['channelId'], 'kpi' => 'watch']);
|
||||
$row['liveStatus']!=1 && $this->market_sylive_activity_model->update(['liveStatus'=>1],['activityId'=>$a_id]); //更新直播间状态
|
||||
$live_status = 1; //直播中
|
||||
}
|
||||
@@ -69,26 +67,7 @@ class Act extends Wx {
|
||||
$live_status = 2; //直播结束
|
||||
}
|
||||
$share_skey = "a_id=" . $a_id . "&cf_uid=" . $this->uid . "&cf_share=" . $this->myencryption->random_string(6);
|
||||
//微信分享
|
||||
$share_url = http_host_com('home') . "/h5/market/sylive/act?skey=" . $this->myencryption->base64url_encode($share_skey);
|
||||
$this->load->library('Jssdk');
|
||||
$jssdk = new Jssdk('liche');
|
||||
$shareTitle = $row['shareTitle'] ? json_decode($row['shareTitle'],true) : [];
|
||||
$sign_package = $jssdk->getSignPackage();
|
||||
$share = array(
|
||||
'title' => $row['title'],
|
||||
"img" => $row['sharePhoto'] ? build_qiniu_image_url($row['sharePhoto']) : '',
|
||||
"desc" => $shareTitle[array_rand($shareTitle)],
|
||||
"url" => $share_url
|
||||
);
|
||||
//直播参数
|
||||
// $live_user = ['userId' => $user['unionid'], 'userName' => $user['nickname'], 'pic' => $user['headimg']];
|
||||
// $this->load->library('PolyvApi');
|
||||
// $polyv = new PolyvApi(['channel_id'=>$row['channelId']]);
|
||||
// $liveSdk = $polyv->getLiveSdk();
|
||||
// $liveSdk['user'] = $live_user;
|
||||
$info['live_status'] = $live_status;
|
||||
// $info['liveSdk'] = $liveSdk;
|
||||
$info['skey'] = $this->myencryption->base64url_encode($share_skey);
|
||||
$info['a_id'] = $a_id;
|
||||
$info['org_id'] = $this->session['org_id'];
|
||||
@@ -108,10 +87,12 @@ class Act extends Wx {
|
||||
}
|
||||
//判断是否支付商品
|
||||
$is_pay = $this->market_sylive_order_model->count(['item_id'=>$a_id,'status'=>1,'uid'=>$this->uid]);
|
||||
//微信分享
|
||||
$wx_info = $this->share_info($row);
|
||||
$info['is_pay'] = $is_pay ? 1 : 0;
|
||||
$this->data['info'] = $info;
|
||||
$this->data['sign_package'] = $sign_package;
|
||||
$this->data['share'] = $share;
|
||||
$this->data['sign_package'] = $wx_info['sign_package'];
|
||||
$this->data['share'] = $wx_info['share'];
|
||||
$this->data['_title'] = $row['title'];
|
||||
$this->show_view('h5/market/sylive/act/index');
|
||||
}
|
||||
@@ -237,6 +218,10 @@ class Act extends Wx {
|
||||
$this->data['posterTip'] = "{$biz['organizationName']}{$user['uname']}诚挚邀请您参与";
|
||||
$this->data['lists'] = $lists;
|
||||
$this->data['shareTitle'] = $shareTitle;
|
||||
//微信分享
|
||||
$wx_info = $this->share_info($row);
|
||||
$this->data['sign_package'] = $wx_info['sign_package'];
|
||||
$this->data['share'] = $wx_info['share'];
|
||||
$this->show_view('h5/market/sylive/act/share');
|
||||
}
|
||||
|
||||
@@ -275,6 +260,10 @@ class Act extends Wx {
|
||||
];
|
||||
$this->data['info'] = $info;
|
||||
$this->data['_title'] = $row['title'];
|
||||
//微信分享
|
||||
$wx_info = $this->share_info($row);
|
||||
$this->data['sign_package'] = $wx_info['sign_package'];
|
||||
$this->data['share'] = $wx_info['share'];
|
||||
$this->show_view('h5/market/sylive/act/item');
|
||||
}
|
||||
|
||||
@@ -397,6 +386,10 @@ class Act extends Wx {
|
||||
];
|
||||
$this->data['info'] = $info;
|
||||
$this->data['_title'] = $row['title'];
|
||||
//微信分享
|
||||
$wx_info = $this->share_info($row);
|
||||
$this->data['sign_package'] = $wx_info['sign_package'];
|
||||
$this->data['share'] = $wx_info['share'];
|
||||
$this->show_view('h5/market/sylive/act/ucenter');
|
||||
}
|
||||
|
||||
@@ -483,4 +476,17 @@ class Act extends Wx {
|
||||
redirect($live_url);
|
||||
}
|
||||
}
|
||||
//进入直播间统计
|
||||
public function golive(){
|
||||
$params = $this->input->get();
|
||||
$a_id = $params['a_id'];
|
||||
$row = $this->market_sylive_activity_model->get(['activityId'=>$a_id]);
|
||||
if($row && time()>strtotime($row['timeStart']) && time()<=strtotime($row['timeEnd'])){
|
||||
$act_user = $this->act_user_model->get(['userId'=>$this->uid,'activityId'=>$a_id]);
|
||||
$this->sylive_entity->kpi_log(['a_id' => $a_id, 'uid' => $this->uid,'cf_uid' => $act_user['channelId'], 'kpi' => 'watch']);
|
||||
$this->show_json([],200,'操作成功');
|
||||
}else{
|
||||
$this->show_json([],400,'参数错误');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,6 +94,24 @@ abstract class Common extends CI_Controller{
|
||||
redirect($auth_url);
|
||||
}
|
||||
}
|
||||
//微信分享信息
|
||||
public function share_info($act_row){
|
||||
$a_id = $act_row['activityId'];
|
||||
$share_skey = "a_id=" . $a_id . "&cf_uid=" . $this->uid . "&cf_share=" . $this->myencryption->random_string(6);
|
||||
//微信分享
|
||||
$share_url = http_host_com('home') . "/h5/market/sylive/act?skey=" . $this->myencryption->base64url_encode($share_skey);
|
||||
$this->load->library('Jssdk');
|
||||
$jssdk = new Jssdk('liche');
|
||||
$shareTitle = $act_row['shareTitle'] ? json_decode($act_row['shareTitle'],true) : [];
|
||||
$sign_package = $jssdk->getSignPackage();
|
||||
$share = array(
|
||||
'title' => $act_row['title'],
|
||||
"img" => $act_row['sharePhoto'] ? build_qiniu_image_url($act_row['sharePhoto']) : '',
|
||||
"desc" => $shareTitle[array_rand($shareTitle)],
|
||||
"url" => $share_url
|
||||
);
|
||||
return ['sign_package' => $sign_package ,'share' => $share];
|
||||
}
|
||||
}
|
||||
|
||||
class Admin extends Common{
|
||||
|
||||
@@ -29,6 +29,10 @@ class Stic extends Admin{
|
||||
throw new Hd_exception('参数错误',400);
|
||||
}
|
||||
$info['tab'] = time()>=strtotime($row['timeStart']) ? 2 : 1;
|
||||
//微信分享
|
||||
$wx_info = $this->share_info($row);
|
||||
$this->data['sign_package'] = $wx_info['sign_package'];
|
||||
$this->data['share'] = $wx_info['share'];
|
||||
if($this->group_id==3){ //顾问
|
||||
$browse_count = $this->mdSytActivityKpiData->count(['a_id'=>$a_id,'kpi'=>'browse','cf_uid'=>$this->uid]);
|
||||
$subscribe_count = $this->mdSytActivityKpiData->count(['a_id'=>$a_id,'kpi'=>'subscribe','cf_uid'=>$this->uid]);
|
||||
@@ -264,7 +268,17 @@ class Stic extends Admin{
|
||||
$data['title'] = $title_arr[$type];
|
||||
$this->show_json($data,200);
|
||||
}
|
||||
$param = $this->myencryption->base64url_decode($this->data['skey']);
|
||||
$a_id = intval($param['a_id']);//活动id
|
||||
$row = $this->market_sylive_activity_model->get(['activityId'=>$a_id]);
|
||||
if(!$row){
|
||||
throw new Hd_exception('参数错误',400);
|
||||
}
|
||||
$this->data['params'] = $params;
|
||||
//微信分享
|
||||
$wx_info = $this->share_info($row);
|
||||
$this->data['sign_package'] = $wx_info['sign_package'];
|
||||
$this->data['share'] = $wx_info['share'];
|
||||
$this->show_view('h5/market/sylive/stic/rank');
|
||||
}
|
||||
|
||||
@@ -364,7 +378,16 @@ class Stic extends Admin{
|
||||
];
|
||||
$this->show_json($data,200);
|
||||
}
|
||||
$a_id = intval($params['a_id']);//活动id
|
||||
$row = $this->market_sylive_activity_model->get(['activityId'=>$a_id]);
|
||||
if(!$row){
|
||||
throw new Hd_exception('参数错误',400);
|
||||
}
|
||||
$this->data['params'] = $params;
|
||||
//微信分享
|
||||
$wx_info = $this->share_info($row);
|
||||
$this->data['sign_package'] = $wx_info['sign_package'];
|
||||
$this->data['share'] = $wx_info['share'];
|
||||
$this->show_view('h5/market/sylive/stic/users');
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@
|
||||
</div>
|
||||
<div class="fixed left-0 bottom-0 right-0 inner30 bg-fff z-index-4" >
|
||||
<template v-if="info.live_status<2">
|
||||
<a class="block bg-1a1a1a pt20 pb20 text-center font-36 color-fff ulib-r10" v-if="info.live_status==1" href="<?=$info['live_url']?>">进入直播间</a>
|
||||
<a class="block bg-1a1a1a pt20 pb20 text-center font-36 color-fff ulib-r10" v-if="info.live_status==1" @click="goLive" href="javascript:;">进入直播间</a>
|
||||
<a class="block bg-1a1a1a pt20 pb20 text-center font-36 color-fff ulib-r10" v-else href="javascript:;" @click="showCode">开播提醒</a>
|
||||
</template>
|
||||
<template v-else>
|
||||
@@ -69,37 +69,7 @@
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!--
|
||||
<script>
|
||||
var chatroom = null;
|
||||
var liveSdk = null;
|
||||
window.onload = function () {
|
||||
var liveSdk = new PolyvLiveSdk({
|
||||
channelId: "<?= $info['liveSdk']['channelId'] ?>",
|
||||
sign: "<?= $info['liveSdk']['sign'] ?>", // 频道验证签名
|
||||
timestamp: "<?= $info['liveSdk']['timestamp'] ?>", // 毫秒级时间戳
|
||||
appId: "<?= $info['liveSdk']['appId'] ?>", // polyv 后台的appId
|
||||
user: {
|
||||
userId: "<?= $info['liveSdk']['user']['userId'] ?>",
|
||||
userName: "<?= $info['liveSdk']['user']['userName'] ?>",
|
||||
pic: "<?= $info['liveSdk']['user']['pic'] ?>",
|
||||
},
|
||||
});
|
||||
|
||||
// 第四步:监听频道信息读取完成事件,初始化播放器
|
||||
liveSdk.on(PolyvLiveSdk.EVENTS.CHANNEL_DATA_INIT, (event, data) => {
|
||||
liveSdk.setupPlayer({
|
||||
el: "#player",
|
||||
type: "auto",
|
||||
autoplay: true, // 设置自动播放
|
||||
});
|
||||
console.log('---频道信息---')
|
||||
console.log(data)
|
||||
});
|
||||
/******函数*******/
|
||||
};
|
||||
</script>
|
||||
-->
|
||||
<script>
|
||||
let hostUrl = ''
|
||||
var app = new Vue({
|
||||
@@ -228,57 +198,15 @@
|
||||
|
||||
},
|
||||
|
||||
//进入直播间
|
||||
goLive(){
|
||||
$.get('/h5/market/sylive/act/golive',{'a_id':this.info.a_id},function (result){
|
||||
window.location.href = "<?=$info['live_url']?>"
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
wx.config({
|
||||
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印
|
||||
appId: "<?=$sign_package['appId']?>", // 必填,公众号的唯一标识
|
||||
timestamp: "<?=$sign_package['timestamp']?>", // 必填,生成签名的时间戳
|
||||
nonceStr: "<?=$sign_package['nonceStr']?>", // 必填,生成签名的随机串
|
||||
signature: "<?=$sign_package['signature']?>",// 必填,签名
|
||||
jsApiList: ["openLocation", "updateAppMessageShareData", "updateTimelineShareData"], // 必填,需要使用的JS接口列表
|
||||
openTagList: ['wx-open-launch-weapp'] // 可选,需要使用的开放标签列表,例如['wx-open-launch-app']
|
||||
});
|
||||
wx.ready(function () {
|
||||
//自定义“分享到朋友圈”及“分享到QQ空间”按钮的分享内容
|
||||
wx.updateTimelineShareData({
|
||||
title: '<?=$share['title']?>', // 分享标题
|
||||
link: '<?=$share['url']?>', // 分享链接
|
||||
imgUrl: '<?=$share['img']?>', // 分享图标
|
||||
desc: '<?=$share['desc']?>', // 分享描述
|
||||
success: function () {
|
||||
// 用户成功分享后执行的回调函数
|
||||
alert(option.title);
|
||||
option.success()
|
||||
},
|
||||
cancel: function () {
|
||||
// 用户取消分享后执行的回调函数
|
||||
option.error()
|
||||
}
|
||||
});
|
||||
//自定义“分享给朋友”及“分享到QQ”按钮的分享内容
|
||||
wx.updateAppMessageShareData({
|
||||
title: '<?=$share['title']?>', // 分享标题
|
||||
desc: '<?=$share['desc']?>', // 分享描述
|
||||
link: '<?=$share['url']?>', // 分享链接
|
||||
imgUrl: '<?=$share['img']?>', // 分享图标
|
||||
success: function () {
|
||||
// 用户成功分享后执行的回调函数
|
||||
alert(option.title);
|
||||
option.success()
|
||||
},
|
||||
cancel: function () {
|
||||
// 用户取消分享后执行的回调函数
|
||||
option.error()
|
||||
}
|
||||
});
|
||||
});
|
||||
wx.error(function (res) {
|
||||
console.log('res', res);
|
||||
// config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
|
||||
});
|
||||
</script>
|
||||
|
||||
<?=$this->load->view('h5/market/sylive/share_script')?>
|
||||
</body>
|
||||
|
||||
@@ -213,5 +213,5 @@
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<?=$this->load->view('h5/market/sylive/share_script')?>
|
||||
</body>
|
||||
@@ -141,4 +141,5 @@
|
||||
},
|
||||
})
|
||||
</script>
|
||||
<?=$this->load->view('h5/market/sylive/share_script')?>
|
||||
</body>
|
||||
@@ -95,5 +95,5 @@
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<?=$this->load->view('h5/market/sylive/share_script')?>
|
||||
</body>
|
||||
@@ -0,0 +1,49 @@
|
||||
<script type="text/javascript">
|
||||
wx.config({
|
||||
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印
|
||||
appId: "<?=$sign_package['appId']?>", // 必填,公众号的唯一标识
|
||||
timestamp: "<?=$sign_package['timestamp']?>", // 必填,生成签名的时间戳
|
||||
nonceStr: "<?=$sign_package['nonceStr']?>", // 必填,生成签名的随机串
|
||||
signature: "<?=$sign_package['signature']?>",// 必填,签名
|
||||
jsApiList: ["openLocation", "updateAppMessageShareData", "updateTimelineShareData"], // 必填,需要使用的JS接口列表
|
||||
openTagList: ['wx-open-launch-weapp'] // 可选,需要使用的开放标签列表,例如['wx-open-launch-app']
|
||||
});
|
||||
wx.ready(function () {
|
||||
//自定义“分享到朋友圈”及“分享到QQ空间”按钮的分享内容
|
||||
wx.updateTimelineShareData({
|
||||
title: '<?=$share['title']?>', // 分享标题
|
||||
link: '<?=$share['url']?>', // 分享链接
|
||||
imgUrl: '<?=$share['img']?>', // 分享图标
|
||||
desc: '<?=$share['desc']?>', // 分享描述
|
||||
success: function () {
|
||||
// 用户成功分享后执行的回调函数
|
||||
alert(option.title);
|
||||
option.success()
|
||||
},
|
||||
cancel: function () {
|
||||
// 用户取消分享后执行的回调函数
|
||||
option.error()
|
||||
}
|
||||
});
|
||||
//自定义“分享给朋友”及“分享到QQ”按钮的分享内容
|
||||
wx.updateAppMessageShareData({
|
||||
title: '<?=$share['title']?>', // 分享标题
|
||||
desc: '<?=$share['desc']?>', // 分享描述
|
||||
link: '<?=$share['url']?>', // 分享链接
|
||||
imgUrl: '<?=$share['img']?>', // 分享图标
|
||||
success: function () {
|
||||
// 用户成功分享后执行的回调函数
|
||||
alert(option.title);
|
||||
option.success()
|
||||
},
|
||||
cancel: function () {
|
||||
// 用户取消分享后执行的回调函数
|
||||
option.error()
|
||||
}
|
||||
});
|
||||
});
|
||||
wx.error(function (res) {
|
||||
console.log('res', res);
|
||||
// config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
|
||||
});
|
||||
</script>
|
||||
@@ -323,5 +323,5 @@
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<?=$this->load->view('h5/market/sylive/share_script')?>
|
||||
</body>
|
||||
|
||||
@@ -227,4 +227,5 @@
|
||||
},
|
||||
})
|
||||
</script>
|
||||
<?=$this->load->view('h5/market/sylive/share_script')?>
|
||||
</body>
|
||||
@@ -80,4 +80,5 @@
|
||||
},
|
||||
})
|
||||
</script>
|
||||
<?=$this->load->view('h5/market/sylive/share_script')?>
|
||||
</body>
|
||||
@@ -82,4 +82,5 @@
|
||||
},
|
||||
})
|
||||
</script>
|
||||
<?=$this->load->view('h5/market/sylive/share_script')?>
|
||||
</body>
|
||||
Reference in New Issue
Block a user