From 2e7d6e5805a47c001a49752b0f33e1ec663aaedf Mon Sep 17 00:00:00 2001 From: lccsw <805383944@qq.com> Date: Thu, 13 Oct 2022 17:34:27 +0800 Subject: [PATCH] edit-sylive-user_list --- common/helpers/comm_helper.php | 6 +- common/libraries/market/Sylive_entity.php | 2 + home/controllers/h5/market/sylive/Stic.php | 145 +++++++++++++------- home/views/h5/market/sylive/act/ucenter.php | 2 +- home/views/h5/market/sylive/stic/users.php | 69 ++++++++-- 5 files changed, 158 insertions(+), 66 deletions(-) diff --git a/common/helpers/comm_helper.php b/common/helpers/comm_helper.php index 115c2984..d596fdbc 100644 --- a/common/helpers/comm_helper.php +++ b/common/helpers/comm_helper.php @@ -725,7 +725,7 @@ if (!function_exists('num_to_rmb')) { * @return string */ if (!function_exists('friendly_date')) { - function friendly_date($sTime, $type = 'normal') + function friendly_date($sTime, $type = 'normal',$d_type = '') { if (!$sTime) return ''; //sTime=源时间,cTime=当前时间,dTime=时间差 @@ -749,9 +749,9 @@ if (!function_exists('friendly_date')) { //return intval($dTime/3600)."小时前"; return '今天' . date('H:i', $sTime); } elseif ($dYear == 0) { - return date("m月d日 H:i", $sTime); + return $d_type ? date("m.d H:i", $sTime) : date("m月d日 H:i", $sTime) ; } else { - return date("Y-m-d H:i", $sTime); + return $d_type ? date("Y.m.d H:i", $sTime) : date("Y-m-d H:i", $sTime) ; } } elseif ($type == 'mohu') { if ($dTime < 60) { diff --git a/common/libraries/market/Sylive_entity.php b/common/libraries/market/Sylive_entity.php index 27e1a3aa..9773efb1 100644 --- a/common/libraries/market/Sylive_entity.php +++ b/common/libraries/market/Sylive_entity.php @@ -4,6 +4,7 @@ */ class Sylive_entity{ + const DEFAULT_HEAD = 'https://qs.haodian.cn/web/images/project/H5-ShiYu/default-head.png'; //默认头像 private $ci; private $map_kpi_biz = [ 'browse' => 'browse', 'subscribe' => 'subscribe', 'order' => 'orderTotal','watch' => 'watch' @@ -194,6 +195,7 @@ class Sylive_entity{ $lists[] = [ 'uid' => $item['userId'], 'name' => $item['uname'] ? $item['uname'] : $item['nickname'], + 'headimg' => $item['headimg'] ? $item['headimg'] : self::DEFAULT_HEAD, 'total' => $total, 'num' => "{$total}人", 'tip' => $uid == $item['userId'] ? '本人' : '', diff --git a/home/controllers/h5/market/sylive/Stic.php b/home/controllers/h5/market/sylive/Stic.php index d6b3a6f0..483eb4b7 100644 --- a/home/controllers/h5/market/sylive/Stic.php +++ b/home/controllers/h5/market/sylive/Stic.php @@ -374,60 +374,23 @@ class Stic extends Admin{ 'browse' => '访问用户', 'subscribe' => '预约用户', 'order' => '下单用户','watch' => '观看用户' ]; $params = $this->input->get(); - if($this->input->is_ajax_request()){ - $page = $params['page'] ? intval($params['page']) : 1; - $where = [ - 'a_id' => $params['a_id'], - 'kpi' => $params['kpi'], - ]; - if($params['type']=='all' && $this->group_id<3){ //所有 - if(!$this->group_id){ //品牌 - $where["a_id"] = $params['a_id']; - }elseif($this->group_id==1){ //大区 - $org_row = $this->market_sylive_organization_model->get(['organizationId'=>$this->session['org_id']],'parentId'); - $org_id = $org_row['parentId'] ? $org_row['parentId'] : 0; - $where["area_id in (select organizationId from lc_market_sylive_organization where parentId={$org_id} and status=0)"] = null; - }else{ //店长 - $where['biz_id'] = $this->session['org_id']; - } - }else{ //只显示个人 - $where['cf_uid'] = $this->uid; - } - $total = $this->mdSytActivityKpiData->count($where); - $lists = []; - if($total){ - $rows = $this->mdSytActivityKpiData->select($where,'id desc',$page,20,'uid,c_time'); - $uids = implode(',',array_unique(array_column($rows,'uid'))); - $users = []; - if($uids){ - $where = [ - "userId in ($uids)" => null, - ]; - $users = $this->user_model->map('userId','',$where,'','','','userId,nickname,headimg'); - } - foreach ($rows as $key => $item) { - $user = $users[$item['uid']] ? $users[$item['uid']][0] : []; - $nickname = $user['nickname'] ? $user['nickname'] : '用户'.$user['userId']; - $headimg = $user['headimg'] ? $user['headimg'] : 'https://thirdwx.qlogo.cn/mmopen/vi_32/Q3auHgzwzM483tlYWFg5RWQ1Xat94ib82prnDSicm2GHuxI49swU08N2I1aHb7B1gmicyxXF8R1BsVWahU9SiaPEzA/132'; - $lists[] = [ - 'nickname' => $nickname, - 'headimg' => $headimg, - 'time' => friendly_date($item['c_time']) - ]; - } - } - $data = [ - 'title' => $map_kpi_name[$params['kpi']], - 'total' => $total, - 'lists' => $lists - ]; - $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); } + $title = $map_kpi_name[$params['kpi']]; + if($this->group_id==2){ //店长 + $tab = [ + ['id'=>1,'title'=>$title], + ['id'=>2,'title'=>'顾问数据'] + ]; + }else{ + $tab = [ + ['id'=>1,'title'=>$title], + ]; + } + $this->data['tab'] = $tab; $this->data['params'] = $params; //微信分享 $wx_info = $this->share_info($row); @@ -435,4 +398,88 @@ class Stic extends Admin{ $this->data['share'] = $wx_info['share']; $this->show_view('h5/market/sylive/stic/users'); } + + public function user_lists(){ + $params = $this->input->get(); + if($params['tabid']==2){ //顾问数据 + $this->gw_lists(); + } + $page = $params['page'] ? intval($params['page']) : 1; + $where = [ + 'a_id' => $params['a_id'], + 'kpi' => $params['kpi'], + ]; + if($params['type']=='all' && $this->group_id<3){ //所有 + if(!$this->group_id){ //品牌 + $where["a_id"] = $params['a_id']; + }elseif($this->group_id==1){ //大区 + $org_row = $this->market_sylive_organization_model->get(['organizationId'=>$this->session['org_id']],'parentId'); + $org_id = $org_row['parentId'] ? $org_row['parentId'] : 0; + $where["area_id in (select organizationId from lc_market_sylive_organization where parentId={$org_id} and status=0)"] = null; + }else{ //店长 + $where['biz_id'] = $this->session['org_id']; + } + }else{ //只显示个人 + $where['cf_uid'] = $this->uid; + } + $total = $this->mdSytActivityKpiData->count($where); + $lists = []; + if($total){ + $rows = $this->mdSytActivityKpiData->select($where,'id desc',$page,20,'uid,cf_uid,c_time'); + $uids_arr = array_column($rows,'uid'); + if($this->group_id==2){ + $gw_uids_arr = array_column($rows,'cf_uid'); + $uids_arr = array_merge($uids_arr,$gw_uids_arr); + } + $uids = implode(',',array_unique($uids_arr)); + $users = []; + if($uids){ + $where = [ + "userId in ($uids)" => null, + ]; + $users = $this->user_model->map('userId','',$where,'','','','userId,uname,nickname,headimg'); + } + foreach ($rows as $key => $item) { + $user = $users[$item['uid']] ? $users[$item['uid']][0] : []; + $nickname = $user['nickname'] ? $user['nickname'] : '用户'.$user['userId']; + $headimg = $user['headimg'] ? $user['headimg'] : 'https://thirdwx.qlogo.cn/mmopen/vi_32/Q3auHgzwzM483tlYWFg5RWQ1Xat94ib82prnDSicm2GHuxI49swU08N2I1aHb7B1gmicyxXF8R1BsVWahU9SiaPEzA/132'; + $cf_uname = ''; + if($this->group_id==2){ //店长 + $cf_user = $users[$item['cf_uid']] ? $users[$item['cf_uid']][0] : []; + $cf_uname = $cf_user['uname'] ? "({$cf_user['uname']})" : ""; + } + $lists[] = [ + 'nickname' => $nickname, + 'headimg' => $headimg, + 'time' => $cf_uname.friendly_date($item['c_time'],'normal',1) + ]; + } + } + $data = [ + 'total' => $total, + 'lists' => $lists + ]; + $this->show_json($data,200); + } + + public function gw_lists(){ + $params = $this->input->get(); + + $res = $this->sylive_entity->top_biz_user($params['a_id'],$this->session['org_id'],$this->uid,$params['kpi']); + $lists = []; + if($res['lists']){ + foreach ($res['lists'] as $item) { + $lists[] = [ + 'nickname' => $item['name'], + 'headimg' => $item['headimg'], + 'time' => $item['num'] + ]; + } + } + $data = [ + 'total' => $res['total'], + 'lists' => $lists + ]; + $this->show_json($data,200); + } } \ No newline at end of file diff --git a/home/views/h5/market/sylive/act/ucenter.php b/home/views/h5/market/sylive/act/ucenter.php index 3c1bb5d8..6fe76f11 100644 --- a/home/views/h5/market/sylive/act/ucenter.php +++ b/home/views/h5/market/sylive/act/ucenter.php @@ -4,7 +4,7 @@
订单号 {{info.order.oid}}
-
{{info.order.c_time}}
+
{{info.order.c_time}}
{{info.order.uname}} · {{info.order.utel}}
diff --git a/home/views/h5/market/sylive/stic/users.php b/home/views/h5/market/sylive/stic/users.php index 9571baa1..720896ce 100644 --- a/home/views/h5/market/sylive/stic/users.php +++ b/home/views/h5/market/sylive/stic/users.php @@ -1,24 +1,36 @@
-
-
-
+
+ + +
- # + # {{item.nickname}}
-
- -
-
{{item.time}}
+
{{item.time}}
暂无数据
请稍等...
-
我们是有底线的
+
我们是有底线的
@@ -30,6 +42,10 @@ var app = new Vue({ el: '#app', data: { + tabFixed:false, + tab:, + tabIndex:0, + tabid:'1',//1观看用户 /2顾问数据 loading: false, isDataEnd: false, isNoData: false, @@ -53,6 +69,34 @@ destroyed () { }, methods: { + //判断导航是否需要吸顶 + handleScroll () { + let scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop + let mainoffsetTop = document.querySelector('#main').offsetTop + if (scrollTop > mainoffsetTop) { + this.tabFixed = true + } else { + this.tabFixed = false + } + }, + + //tab切换 + changeTab(id,index){ + if(id != this.tabid&&!this.loading){ + if(this.tabFixed){ + let mainoffsetTop = document.querySelector('#main').offsetTop + $('html,body').animate({scrollTop: mainoffsetTop+5},500); + } + this.tabid = id; + this.tabIndex = index; + this.loading = false; + this.isDataEnd = false; + this.isNoData = false; + this.page = 1; + this.list = []; + this.fetchData() + } + }, //拉取数据 fetchData: function() { this.getActivityList() @@ -65,11 +109,10 @@ if (!that.isNoData && !that.isDataEnd && !that.loading) { that.loading = true; //请求接口 - $.get('/h5/market/sylive/stic/users',{'a_id':'','type':'','kpi':'','page':that.page},function (res){ + $.get('/h5/market/sylive/stic/user_lists',{'a_id':'','type':'','kpi':'','page':that.page,'tabid':that.tabid},function (res){ that.loading = false; that.page = that.page + 1; - that.title = res.data.title that.list = that.list.concat(res.data.lists); if (res.data.total == 0) { that.isNoData = true;