From e69db7d48c2f4e11068fa2af665850d6ec5f9640 Mon Sep 17 00:00:00 2001 From: dengbw Date: Fri, 4 Nov 2022 15:57:18 +0800 Subject: [PATCH] h5_team_1104 --- home/controllers/h5/market/sylive/Team.php | 2 +- home/controllers/h5/market/sylive/User.php | 9 +- .../controllers/h5/market/sylive/UserTeam.php | 166 +++++++++ home/views/h5/market/sylive/team/index.php | 121 ++++--- home/views/h5/market/sylive/team/lists.php | 103 +++--- home/views/h5/market/sylive/user/index.php | 6 +- home/views/h5/market/sylive/user/team.php | 319 ++++++++++++++++++ market/controllers/api/sylive/Goods.php | 22 +- 8 files changed, 631 insertions(+), 117 deletions(-) create mode 100644 home/controllers/h5/market/sylive/UserTeam.php create mode 100644 home/views/h5/market/sylive/user/team.php diff --git a/home/controllers/h5/market/sylive/Team.php b/home/controllers/h5/market/sylive/Team.php index 1b1fbc7b..56bd85cb 100644 --- a/home/controllers/h5/market/sylive/Team.php +++ b/home/controllers/h5/market/sylive/Team.php @@ -45,7 +45,7 @@ class Team extends Admin{ $row = $this->market_sylive_team_model->get(['teamId'=>$team_id]); $this->data['headimg'] = Sylive_entity::DF_IMG; $this->data['biz_name'] = $row['teamName']; - $this->data['team_id'] = $this->input->get('team_id'); + $this->data['team_id'] = $team_id; $this->data['teamLevel'] = $this->teamLevel; //微信分享 $wx_info = $this->share_info(); diff --git a/home/controllers/h5/market/sylive/User.php b/home/controllers/h5/market/sylive/User.php index 0124e68d..0ac288ec 100644 --- a/home/controllers/h5/market/sylive/User.php +++ b/home/controllers/h5/market/sylive/User.php @@ -13,9 +13,12 @@ class User extends Admin $this->load->model('market/Market_sylive_organization_model', 'mdSyliveOrganization'); $this->load->library('market/sylive_entity'); $this->group_id = $this->sylive_entity->get_level($this->session['org_id']); - $biz_id = intval($this->input->get('biz_id')); - !$biz_id && $biz_id = intval($this->input->post('biz_id')); - $this->group_id == 2 && $biz_id = $this->session['org_id']; + if ($this->group_id == 2) { + $biz_id = $this->session['org_id']; + } else { + $biz_id = intval($this->input->get('biz_id')); + !$biz_id && $biz_id = intval($this->input->post('biz_id')); + } $this->biz_id = $biz_id; } diff --git a/home/controllers/h5/market/sylive/UserTeam.php b/home/controllers/h5/market/sylive/UserTeam.php new file mode 100644 index 00000000..afb797b6 --- /dev/null +++ b/home/controllers/h5/market/sylive/UserTeam.php @@ -0,0 +1,166 @@ +load->model('market/Market_sylive_user_model', 'mdSyliveUser'); + $this->load->model('market/Market_sylive_team_model', 'mdSyliveTeam'); + $this->load->library('market/sylive_entity'); + $this->teamLevel = $this->sylive_entity->get_team_level($this->session['teamId']); + if ($this->teamLevel == 1) { + $team_id = $this->session['teamId']; + } else { + $team_id = intval($this->input->get('team_id')); + !$team_id && $team_id = intval($this->input->post('team_id')); + } + $this->team_id = $team_id; + } + + public function index() + { + if ($this->teamLevel != 1) { + throw new Hd_exception('权限不足', 400); + } + $row = $this->mdSyliveTeam->get(['teamId' => $this->team_id]); + $this->data['headimg'] = Sylive_entity::DF_IMG; + $this->data['team_name'] = $row['teamName']; + $this->data['team_id'] = $this->team_id; + //微信分享 + $wx_info = $this->share_info(); + $this->data['sign_package'] = $wx_info['sign_package']; + $this->show_view('h5/market/sylive/user/team'); + } + + public function lists() + { + if ($this->teamLevel != 1) { + $this->show_json('', 400, '权限不足'); + } + $keyWord = $this->input->get('keyWord'); + $page = intval($this->input->get('page')); + $size = intval($this->input->get('size')); + !$page && $page = 1; + !$size && $size = 10; + $where = [ + 'status<>' => -1, + "teamId in (select teamId from lc_market_sylive_team where parentId={$this->team_id})" => null + ]; + $keyWord && $where["uname like '%{$keyWord}%'"] = null; + $total = $this->user_model->count($where); + $lists = []; + if ($total) { + $res = $this->user_model->select($where, 'userId desc', $page, $size, 'userId,mobile,uname,nickname,headimg,status'); + foreach ($res as $val) { + $temp = [ + 'userId' => $val['userId'], + 'status' => $val['status'], + 'uname' => $val['uname'], + 'mobile' => $val['mobile'], + 'wxuname' => $val['nickname'], + 'wxheadimg' => $val['headimg'] + ]; + $lists[] = $temp; + } + } + $data['list'] = $lists; + $data['total'] = $total; + $this->show_json($data, 200); + } + + public function add() + { + if ($this->teamLevel != 1) { + $this->show_json('', 400, '权限不足'); + } + $uname = $this->input->post('uname'); + $mobile = $this->input->post('mobile'); + if (!$uname) { + $this->show_json('', 400, '请输入团员姓名'); + } + if (!mobile_valid($mobile)) { + $this->show_json('', 400, '请输入正确手机号'); + } + $re_team = $this->mdSyliveTeam->get(['parentId' => $this->team_id, 'teamType' => 3, 'status' => 0]); + if (!$re_team) { + $this->show_json('', 400, '门店未添加团员类型,请联系管理员'); + } + $teamId = $re_team['teamId']; + $re = $this->user_model->get(['mobile' => $mobile]); + if ($re && $re['status'] != -1) { + if ($re['teamId'] || $re['organizationId']) { + $this->show_json('', 400, '手机号已存在'); + } + } + $addDate = ['teamId' => $teamId, 'uname' => $uname, 'status' => 0, 'organizationId' => 0]; + if ($re['userId']) { + $this->user_model->update($addDate, ['userId' => $re['userId']]); + $this->show_json('', 200, '绑定用户成功'); + } else { + $addDate['mobile'] = $mobile; + $addDate['createTime'] = date('Y-m-d H:i:s'); + $id = $this->user_model->add($addDate); + if (!$id) { + $this->show_json('', 400, '添加用户失败'); + } + $this->show_json('', 200, '操作成功'); + } + } + + public function edit() + { + if ($this->teamLevel != 1) { + $this->show_json('', 400, '权限不足'); + } + $uname = $this->input->post('uname'); + $mobile = $this->input->post('mobile'); + $userId = intval($this->input->post('userId')); + if (!$userId) { + $this->show_json('', 400, '参数错误'); + } + if (!$uname) { + $this->show_json('', 400, '请输入团员姓名'); + } + if (!mobile_valid($mobile)) { + $this->show_json('', 400, '请输入正确手机号'); + } + $re = $this->user_model->get(['userId' => $userId]); + if (!$re) { + $this->show_json('', 400, '无此团员'); + } + if ($re['mobile'] == $mobile) { + $uppDate = ['uname' => $uname]; + } else { + $re = $this->user_model->get(['mobile' => $mobile]); + if ($re && $re['status'] != -1) { + if ($re['teamId'] || $re['organizationId']) { + $this->show_json('', 400, '手机号已存在'); + } + } + $uppDate = ['uname' => $uname, 'mobile' => $mobile]; + } + $this->user_model->update($uppDate, ['userId' => $re['userId']]); + $this->show_json('', 200, '操作成功'); + } + + public function status() + { + if ($this->teamLevel != 1) { + $this->show_json('', 400, '权限不足'); + } + $userId = intval($this->input->post('userId')); + $status = intval($this->input->post('status')); + if (!$userId) { + $this->show_json('', 400, '参数错误'); + } + $this->user_model->update(['status' => $status], ['userId' => $userId]); + $this->show_json('', 200, '操作成功'); + } + +} \ No newline at end of file diff --git a/home/views/h5/market/sylive/team/index.php b/home/views/h5/market/sylive/team/index.php index baa49a5f..b92c3a39 100644 --- a/home/views/h5/market/sylive/team/index.php +++ b/home/views/h5/market/sylive/team/index.php @@ -1,13 +1,14 @@
-
+
- # - {{info.nickname}} - - 退出 - + # + {{info.nickname}} + 退出
@@ -79,23 +96,21 @@ var app = new Vue({ el: '#app', data: { - tabFixed:false, - tabIndex:0, - tabid:'1',//1大区列表 /2活动列表 - info:'',//基础信息 + tabFixed: false, + tabIndex: 0, + tabid: '1',//1大区列表 /2活动列表 + info: '',//基础信息 loading: false, isDataEnd: false, isNoData: false, page: 1, //页数 size: 20, //每页取多少个数据 - list:[], + list: [], }, - created(){ - - }, - computed: { + created() { }, + computed: {}, mounted() { window.addEventListener('scroll', this.handleScroll, true) this.getInfo() @@ -104,23 +119,23 @@ }, //离开页面时 - destroyed () { + destroyed() { window.removeEventListener('scroll', this.handleScroll) }, methods: { //获取基础信息 - getInfo(){ + getInfo() { var that = this; - that.info = + that.info = }, //tab切换 - changeTab(id,index){ - if(id != this.tabid&&!this.loading){ - if(this.tabFixed){ + 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); + $('html,body').animate({scrollTop: mainoffsetTop + 5}, 500); } this.tabid = id this.tabIndex = index @@ -128,16 +143,16 @@ this.isNoData = false this.page = 1 this.list = [] - if(this.tabid == 1){ + if (this.tabid == 1) { this.getRegionList() - }else if(this.tabid == 2){ + } else if (this.tabid == 2) { this.getActivityList() } } }, //判断导航是否需要吸顶 - handleScroll () { + handleScroll() { let scrollTop = document.querySelector('#app').scrollTop let mainoffsetTop = document.querySelector('#main').offsetTop if (scrollTop > mainoffsetTop) { @@ -148,20 +163,20 @@ }, //拉取数据 - fetchData: function() { - if(this.tabid == 1){ + fetchData: function () { + if (this.tabid == 1) { this.getRegionList() - }else if(this.tabid == 2){ + } else if (this.tabid == 2) { this.getActivityList() } }, //获取大区列表 - getRegionList(){ - let that=this; + getRegionList() { + let that = this; if (!that.isNoData && !that.isDataEnd && !that.loading) { that.loading = true; - $.get('/h5/market/sylive/team/team_list',{'page':that.page},function (result) { + $.get('/h5/market/sylive/team/team_list', {'page': that.page}, function (result) { that.loading = false; that.page = that.page + 1; that.list = that.list.concat(result.data.list); @@ -170,16 +185,16 @@ } else if (that.list.length == result.data.total) { that.isDataEnd = true; } - },'json') + }, 'json') } }, //获取活动列表 - getActivityList(){ - let that=this; + getActivityList() { + let that = this; if (!that.isNoData && !that.isDataEnd && !that.loading) { that.loading = true; //请求接口 - $.get('/h5/market/sylive/team/act_list',{'page':that.page},function (result) { + $.get('/h5/market/sylive/team/act_list', {'page': that.page}, function (result) { that.loading = false; that.page = that.page + 1; that.list = that.list.concat(result.data.list); @@ -188,31 +203,31 @@ } else if (that.list.length == result.data.total) { that.isDataEnd = true; } - },'json') + }, 'json') } }, - logout(){ - $.get('/h5/market/sylive/login/logout',function (response) { - if(response.code==200){ + logout() { + $.get('/h5/market/sylive/login/logout', function (response) { + if (response.code == 200) { mDialog.msg({ duration: 250, pause: 2000, content: response.msg, - onClose:function(){ + onClose: function () { window.location = '/h5/market/sylive/login' } }); - }else{ + } else { mDialog.msg({ duration: 250, pause: 2000, content: response.msg }); } - },'json') + }, 'json') }, }, }) -load->view('h5/market/sylive/hidden_wx_share')?> +load->view('h5/market/sylive/hidden_wx_share') ?> \ No newline at end of file diff --git a/home/views/h5/market/sylive/team/lists.php b/home/views/h5/market/sylive/team/lists.php index 59148f4c..16bb496f 100644 --- a/home/views/h5/market/sylive/team/lists.php +++ b/home/views/h5/market/sylive/team/lists.php @@ -1,48 +1,60 @@
-
+
- # + #
{{info.title}}
- -
暂无数据
-
请稍等...
-
我们是有底线的
+
暂无数据 +
+
请稍等... +
+
我们是有底线的 +
- - load->view('h5/market/sylive/nav')?> -
-load->view('h5/market/sylive/hidden_wx_share')?> +load->view('h5/market/sylive/hidden_wx_share') ?> \ No newline at end of file diff --git a/home/views/h5/market/sylive/user/index.php b/home/views/h5/market/sylive/user/index.php index a9c27d48..5de15778 100644 --- a/home/views/h5/market/sylive/user/index.php +++ b/home/views/h5/market/sylive/user/index.php @@ -59,11 +59,7 @@ 新增顾问
- - - load->view('h5/market/sylive/nav') ?> - - + load->view('h5/market/sylive/nav') ?>
diff --git a/home/views/h5/market/sylive/user/team.php b/home/views/h5/market/sylive/user/team.php new file mode 100644 index 00000000..09a1e09e --- /dev/null +++ b/home/views/h5/market/sylive/user/team.php @@ -0,0 +1,319 @@ + +
+
+
+
+
+ # + {{info.title}} +
+
+
+
+ +
+
+
+
+ +
+
+
{{item.uname}}·{{item.mobile}}
+
+ # + {{item.wxuname}} +
+
暂未绑定微信
+
+
+ 修改 + | + 删除 + | + 启用 + 禁用 +
+
+ +
+ +
暂无数据
+
请稍等... +
+
我们是有底线的
+
+
+
+ load->view('h5/market/sylive/nav') ?> +
+
+ + 绑定微信后,信息无法修改 +
+ 新增团员 +
+
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+ +
+
+
+
+
确认删除{{list[delIndex].uname}}"吗?"
+
+ 确定 + 取消 +
+
+
+
+ +
+
+
+
+
+ {{list[ableIndex].status==1?'确认启用':'确认禁用'}}{{list[ableIndex].uname}}"吗?" +
+
+ 确定 + 取消 +
+
+
+
+ +
+ + +load->view('h5/market/sylive/hidden_wx_share') ?> + \ No newline at end of file diff --git a/market/controllers/api/sylive/Goods.php b/market/controllers/api/sylive/Goods.php index 06900e1b..b9204112 100644 --- a/market/controllers/api/sylive/Goods.php +++ b/market/controllers/api/sylive/Goods.php @@ -36,7 +36,7 @@ class Goods extends BaseController $sort_order = $sort . ' ' . $order; } $where['status>'] = 0; - $activityId && $where['a_id'] = $activityId; + $activityId && $where['activityId'] = $activityId; $title && $where['title'] = $title; $count = $this->mdSyliveItems->count($where); $list = []; @@ -57,28 +57,30 @@ class Goods extends BaseController */ public function index_post() { - $a_id = intval($this->input_param('a_id')); + $activityId = intval($this->input_param('activityId')); $title = $this->input_param('title'); - $imgs = $this->input_param('imgs'); + $banner = $this->input_param('banner'); $descrip = $this->input_param('descrip'); $price = $this->input_param('price'); $stock = $this->input_param('stock'); $sort = $this->input_param('sort'); - if (!$a_id) { + if (!$activityId) { $this->return_json('参数错误'); } if (!$title) { $this->return_json('请输入商品标题'); } - $addDate = ['a_id' => $a_id, 'title' => $title, 'price' => $price, 'stock' => $stock, 'sort' => $sort + $addDate = ['activityId' => $activityId, 'title' => $title, 'price' => $price, 'stock' => $stock, 'sort' => $sort , 'descrip' => $descrip, 'c_time' => time()]; - if ($imgs) { - $setImgs = []; - foreach ($imgs as $v) { - $setImgs[] = $v['fileUrl']; + $imgs = []; + if ($banner) { + $banner = []; + foreach ($banner as $v) { + $banner[] = $v['fileUrl']; } - $addDate['imgs'] = $setImgs; + $banner && $imgs['banner'] = $banner; } + $imgs && $addDate['imgs'] = json_encode($imgs, JSON_UNESCAPED_UNICODE); $id = $this->mdSyliveItems->add($addDate); if (!$id) { $this->return_json('添加商品失败');