From a99bcfd54ef301f35bede476b6aca5ae0e875b1d Mon Sep 17 00:00:00 2001 From: lccsw <805383944@qq.com> Date: Wed, 12 Oct 2022 16:33:11 +0800 Subject: [PATCH] add-sylive-wx_share --- home/controllers/h5/market/sylive/Act.php | 52 +++++++----- home/controllers/h5/market/sylive/Common.php | 18 ++++ home/controllers/h5/market/sylive/Stic.php | 23 +++++ home/views/h5/market/sylive/act/index.php | 88 ++------------------ home/views/h5/market/sylive/act/item.php | 2 +- home/views/h5/market/sylive/act/share.php | 1 + home/views/h5/market/sylive/act/ucenter.php | 2 +- home/views/h5/market/sylive/share_script.php | 49 +++++++++++ home/views/h5/market/sylive/stic/area.php | 2 +- home/views/h5/market/sylive/stic/index.php | 1 + home/views/h5/market/sylive/stic/rank.php | 1 + home/views/h5/market/sylive/stic/users.php | 1 + 12 files changed, 134 insertions(+), 106 deletions(-) create mode 100644 home/views/h5/market/sylive/share_script.php diff --git a/home/controllers/h5/market/sylive/Act.php b/home/controllers/h5/market/sylive/Act.php index f1e30ffa..e0e3344a 100644 --- a/home/controllers/h5/market/sylive/Act.php +++ b/home/controllers/h5/market/sylive/Act.php @@ -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,'参数错误'); + } + } } diff --git a/home/controllers/h5/market/sylive/Common.php b/home/controllers/h5/market/sylive/Common.php index a198923d..e9dae793 100644 --- a/home/controllers/h5/market/sylive/Common.php +++ b/home/controllers/h5/market/sylive/Common.php @@ -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{ diff --git a/home/controllers/h5/market/sylive/Stic.php b/home/controllers/h5/market/sylive/Stic.php index adaead5b..101c62fb 100644 --- a/home/controllers/h5/market/sylive/Stic.php +++ b/home/controllers/h5/market/sylive/Stic.php @@ -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'); } } \ No newline at end of file diff --git a/home/views/h5/market/sylive/act/index.php b/home/views/h5/market/sylive/act/index.php index d51405b2..e1445fad 100644 --- a/home/views/h5/market/sylive/act/index.php +++ b/home/views/h5/market/sylive/act/index.php @@ -23,7 +23,7 @@