edit-sylive-user_list

This commit is contained in:
lccsw
2022-10-13 17:34:27 +08:00
parent f457136e65
commit 2e7d6e5805
5 changed files with 158 additions and 66 deletions
+3 -3
View File
@@ -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) {
@@ -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'] ? '本人' : '',
+96 -49
View File
@@ -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);
}
}
+1 -1
View File
@@ -4,7 +4,7 @@
<div class="relative height-710">
<div class="pt90 pl100 pr100 fn-clear">
<div class="fn-fl font-18">订单号 {{info.order.oid}}</div>
<div class="fn-fr font-18"><i class="iconfont icon-time"></i>{{info.order.c_time}}</div>
<div class="fn-fr font-18"><i class="iconfont icon-time"></i> {{info.order.c_time}}</div>
</div>
<div class="uinfo absolute box-center pt15 pb15 pl30 pr30 font-32 ulib-r750">{{info.order.uname}} · {{info.order.utel}}</div>
<div class="odslogan absolute box-center text-center color-e4bc93 space-nowrap">
+56 -13
View File
@@ -1,24 +1,36 @@
<body class="bg-f6">
<div id="app">
<div class="container relative bg-no-repeat bg-size-fullwidth bg-pos-top pt30 pb50">
<div class="relative bg-fff ml30 mr30 inner30 ulib-r20 box-shadow-darkGray" style="min-height:90vh;">
<div class="pt10 pb20 text-center"><b class="font-40 text-italic" v-html="title"></b></div>
<div class="pt20 pb20 fn-flex font-28 color-666" v-for="(item,index) in list">
<div id="main" class="relative bg-fff ml30 mr30 inner30 ulib-r20 box-shadow-darkGray" style="min-height:90vh;">
<template v-if="tab.length>1">
<div v-if="tabFixed">
<div class="height-60"></div>
<div class="fixed top-0 left-0 right-0 z-index-10 bg-fff pl30 pr30 pt20 pb20">
<div class="relative height-60 ml50 mr50 fn-flex text-center">
<div class="fn-flex-item" v-for="(item,index) in tab"><a :class="'relative inline-block tab-menu '+ [tabid == item.id?'font-36 active':'font-32']" @click="changeTab(item.id,index)" href="javascript:">{{item.title}}</a></div>
<div :class="'glider glider-'+tabIndex"></div>
</div>
</div>
</div>
<div v-else class="relative height-60 ml50 mr50 fn-flex text-center">
<div class="fn-flex-item" v-for="(item,index) in tab"><a :class="'relative inline-block tab-menu '+ [tabid == item.id?'font-36 active':'font-32']" @click="changeTab(item.id,index)" href="javascript:">{{item.title}}</a></div>
<div :class="'glider glider-'+tabIndex"></div>
</div>
</template>
<template v-else>
<div class="pt10 pb20 text-center"><b class="font-40 text-italic" v-html="tab[0]['title']"></b></div>
</template>
<div class="pt30 pb20 fn-flex font-28 color-666" v-for="(item,index) in list">
<div class="fn-flex-item text-nowrap" flexsize="3">
<img class="imgsize-32X32 text-middle ulib-r750" :src="item.headimg" alt="#" />
<img class="imgsize-32X32 text-middle ulib-r750 bds-1-eee" :src="item.headimg" alt="#" />
<span class="text-middle">{{item.nickname}}</span>
</div>
<div class="fn-flex-item text-center" flexsize="2">
<template v-if="item.tel">
{{item.tel}}
</template>
</div>
<div class="fn-flex-item text-center" flexsize="3">{{item.time}}</div>
<div class="fn-flex-item text-right" flexsize="5">{{item.time}}</div>
</div>
<mugen-scroll :handler="fetchData" :should-handle="!loading">
<div class="pt100 pb100 text-center color-ccc" v-if="isNoData"></i><span class="text-middle font-22">暂无数据</span></div>
<div class="pt20 pb20 text-center color-ccc" v-else-if="loading"><i class="iconfont icon-jiazai text-middle"></i><span class="text-middle font-22">请稍等...</span></div>
<div class="pt20 pb20 text-center font-22 color-ccc" v-else-if="isDataEnd && list.length>20">我们是有底线的</div>
<div class="pt20 pb20 text-center font-22 color-ccc" v-else-if="isDataEnd&&list.length>10">我们是有底线的</div>
</mugen-scroll>
</div>
</div>
@@ -30,6 +42,10 @@
var app = new Vue({
el: '#app',
data: {
tabFixed:false,
tab:<?=json_encode($tab,JSON_UNESCAPED_UNICODE)?>,
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':'<?=$params['a_id']?>','type':'<?=$params['type']?>','kpi':'<?=$params['kpi']?>','page':that.page},function (res){
$.get('/h5/market/sylive/stic/user_lists',{'a_id':'<?=$params['a_id']?>','type':'<?=$params['type']?>','kpi':'<?=$params['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;