edit-sylive-org_select

This commit is contained in:
lccsw
2022-12-09 14:11:16 +08:00
parent 97dda9fc2e
commit e4712f0f79
6 changed files with 184 additions and 328 deletions
+169
View File
@@ -0,0 +1,169 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once 'Common.php';
class User extends Admin
{
public function __construct()
{
parent::__construct();
$this->load->model('market/Market_sylive_organization_model', 'mdSyliveOrganization');
$this->load->library('market/sylive_entity');
$this->biz_id = 0;
$this->session['org_id'];
}
public function index()
{
$row = $this->market_sylive_organization_model->get(['organizationId' => $this->biz_id]);
$headimg = $row['logo'] ? build_qiniu_image_url($row['logo']) : Sylive_entity::HD_IMG;
$this->data['headimg'] = $headimg;
$this->data['biz_name'] = $row['organizationName'];
$this->data['biz_id'] = $this->biz_id;
//微信分享
$wx_info = $this->share_info();
$this->data['sign_package'] = $wx_info['sign_package'];
$this->show_view('h5/market/sylive2/user/index');
}
public function lists()
{
$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,
"organizationId in (select organizationId from lc_market_sylive_organization where parentId={$this->biz_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()
{
$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_org = $this->market_sylive_organization_model->get(['parentId' => $this->biz_id, 'organizationType' => 4
, 'status' => 0]);
if (!$re_org) {
$this->show_json('', 400, '门店未添加顾问类型,请联系管理员');
}
$organizationId = $re_org['organizationId'];
$topOrgId = $this->getTopOrgId($organizationId);
$re = $this->user_model->get(['mobile' => $mobile, 'topOrgId' => $topOrgId]);
if ($re && $re['status'] != -1) {
if ($re['teamId'] || $re['organizationId']) {
$this->show_json('', 400, '手机号已存在');
}
}
$addDate = ['topOrgId' => $topOrgId, 'organizationId' => $organizationId, 'biz_id' => $this->biz_id,
'uname' => $uname, 'status' => 0, 'teamId' => 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()
{
$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, 'topOrgId' => $re['topOrgId']]);
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()
{
$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, '操作成功');
}
/**
* Notes:获取顶级机构id
* Created on: 2022/12/8 14:39
* Created by: dengbw
* @param $organizationId
* @param $topOrgId
* @return mixed
*/
private function getTopOrgId($organizationId, $topOrgId = 0)
{
$re = $this->mdSyliveOrganization->get(['organizationId' => $organizationId], 'organizationId,parentId');
if (!$re) {
return $topOrgId;
} else {
$topOrgId = $re['organizationId'];
if ($re['parentId']) {
return $this->getTopOrgId($re['parentId'], $topOrgId);
} else {
return $topOrgId;
}
}
}
}
@@ -27,7 +27,7 @@ class Welcome extends Admin {
'url' => "/h5/market/sylive2/welcome/org?org_id={$levl_top['organizationId']}&userId={$val['userId']}"
];
$org_lists[$temp['organizationId']] = $temp;
$org_lists[$levl_top['organizationId']] = $temp;
}
$_SESSION[self::SESSION_KEY]['multi_org'] = 1;
$this->data['org_lists'] = $org_lists;
@@ -6,6 +6,9 @@
<a class="block fn-fl pt10 pb10 pl20 pr20 bg-ccc font-28 ulib-r750" href="javascript:;" @click="logout()">
<i class="iconfont icon-tuichu text-middle"></i><span class="ml5 text-middle">退出</span>
</a>
<a class="block fn-fr pt10 pb10 pl20 pr20 bg-333 font-28 color-fff ulib-r750" href="/h5/market/sylive2/user">
<i class="iconfont icon-guanli text-middle"></i><span class="ml5 text-middle">顾问管理</span>
</a>
<?if($multi_org){?>
<a class="block fn-fr pt10 pb10 pl20 pr20 bg-333 font-28 color-fff ulib-r750" href="/h5/market/sylive2">
<i class="iconfont icon-qiehuan1 text-middle"></i><span class="ml5 text-middle">切换机构</span>
+1 -1
View File
@@ -8,7 +8,7 @@
</div>
<div class="absolute bp20 left-0 right-0 pl100 pr100 text-center fn-flex fn-flex-wrap">
<a class="block wp50" :href="item.url" v-for="item in list">
<img class='inline-block imgsize-210X210' :src='item.logo' />
<img class='inline-block imgsize-210X210 box-shadow-lightGray ulib-r750' :src='item.logo' />
</a>
</div>
</div>
+10 -7
View File
@@ -59,7 +59,10 @@
<a class="block bg-1a1a1a pt25 pb25 text-center font-36 color-fff ulib-r10" @click="showForm(-1)"
href="javascript:void(0)">新增顾问</a>
</div>
<? $this->load->view('h5/market/sylive/nav') ?>
<a class="bottom-opt pt15 bg-1a1a1a ulib-r750 text-center color-fff" href="/h5/market/sylive2/biz">
<i class="iconfont icon-shouye text-middle font-36"></i>
<div class="font-22">首页</div>
</a>
<div class="msg fn-hide" :style="isShowForm?'display:block':'display:none'" v-if="isShowForm">
<div class="msgBg" @click="closeOpt"></div>
<div class="msgMain">
@@ -191,7 +194,7 @@
params['size'] = this.size;
}
//请求接口
$.get('/h5/market/sylive/user/lists', params, function (result) {
$.get('/h5/market/sylive2/user/lists', params, function (result) {
that.loading = false;
that.isRefresh = false;
if (result.code == 200) {
@@ -241,13 +244,13 @@
});
} else {
that.isSubmiting = true;
let url = '/h5/market/sylive/user/add';
let url = '/h5/market/sylive2/user/add';
let params = {};
params['uname'] = that.uname;
params['mobile'] = that.mobile;
params['biz_id'] = <?=$biz_id?>;
if (that.formIndex > -1) {
url = '/h5/market/sylive/user/edit';
url = '/h5/market/sylive2/user/edit';
params['userId'] = this.list[that.formIndex].userId;
}
$.post(url, params, function (response) {
@@ -280,7 +283,7 @@
params['userId'] = that.list[that.ableIndex].userId;
params['status'] = that.list[that.ableIndex].status == 1 ? 0 : 1;
//执行接口
$.post('/h5/market/sylive/user/status', params, function (response) {
$.post('/h5/market/sylive2/user/status', params, function (response) {
mDialog.msg({content: response.msg});
if (response.code == 200) {
that.list[that.ableIndex].status = that.list[that.ableIndex].status == 1 ? 0 : 1;
@@ -300,7 +303,7 @@
let params = {};
params['userId'] = that.list[that.delIndex].userId;
params['status'] = -1;
$.post('/h5/market/sylive/user/status', params, function (response) {
$.post('/h5/market/sylive2/user/status', params, function (response) {
mDialog.msg({content: response.msg});
if (response.code == 200) {
that.isShowDel = false;
@@ -316,5 +319,5 @@
},
})
</script>
<?= $this->load->view('h5/market/sylive/hidden_wx_share') ?>
<?= $this->load->view('h5/market/sylive2/hidden_wx_share') ?>
</body>
-319
View File
@@ -1,319 +0,0 @@
<body class="bg-f6">
<div id="app" ref="app">
<div class="container relative bg-no-repeat bg-size-fullwidth bg-pos-top pb150">
<div class="inner30 fn-flex">
<div class="fn-flex-item wp50 mr20">
<div class="mt10 text-nowrap">
<img class="text-middle imgsize-40X40 ulib-r750" :src="info.logo" alt="#"/>
<span class="text-middle font-28">{{info.title}}</span>
</div>
</div>
<div class="fn-flex-item wp50 relative pt10 pb10 pl50 pr20 bg-ddd ulib-r750">
<div class="absolute box-middle left-0 font-24 color-999 pl15 pr10 brs-1-999"><i
class="iconfont icon-sousuo"></i></div>
<input class="wp90 bg-ddd bds-1-ddd font-22 ulib-r750" type="search" class="ipt-seach"
placeholder="请输入团员姓名" v-model="keyWord" @input="searchHandler"/>
</div>
</div>
<div class="relative bg-fff ml30 mr30 inner30 ulib-r20 box-shadow-darkGray" style="min-height:75vh;">
<div>
<!--团员列表-->
<div class="relative mb30 bg-f9 pt20 pb20 pl30 pr200 ulib-r20" v-for="(item,index) in list">
<div>
<div class="font-28">{{item.uname}}·{{item.mobile}}</div>
<div class="mt10 font-22 color-999" v-if="item.wxuname">
<img class="text-middle imgsize-30X30 ulib-r750" :src="item.wxheadimg" alt="#"/>
<span class="text-middle">{{item.wxuname}}</span>
</div>
<div class="mt10 font-22 color-999" v-else>暂未绑定微信</div>
</div>
<div class="absolute box-middle right-0 mr30 space-nowrap font-26">
<a class="text-middle" href="javascript:void(0);" v-if="!item.wxuname" @click="showForm(index)">修改</a>
<span class="text-middle font-22 pl5 pr5" v-if="!item.wxuname">|</span>
<a class="text-middle" href="javascript:void(0);" @click="showDel(index)">删除</a>
<span class="text-middle font-22 pl5 pr5">|</span>
<a class="text-middle color-ffa85a" href="javascript:void(0);" v-if="item.status==1"
@click=showAble(index)>启用</a>
<a class="text-middle color-ffa85a" href="javascript:void(0);" v-else-if="item.status==0"
@click=showAble(index)>禁用</a>
</div>
</div>
<!--end活动列表-->
</div>
<mugen-scroll :handler="fetchData" :should-handle="!loading" scroll-container="app">
<div class="pt100 pb100 text-center color-ccc" v-if="isNoData"><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>10">我们是有底线的</div>
</mugen-scroll>
</div>
</div>
<? $this->load->view('h5/market/sylive/nav') ?>
<div class="fixed left-0 bottom-0 right-0 inner30 pt15 bg-fff z-index-2">
<div class="pb15 text-center font-22 color-999">
<i class="iconfont icon-xinxi text-middle"></i>
<span class="text-middle">绑定微信后,信息无法修改</span>
</div>
<a class="block bg-1a1a1a pt25 pb25 text-center font-36 color-fff ulib-r10" @click="showForm(-1)"
href="javascript:void(0)">新增团员</a>
</div>
<div class="msg fn-hide" :style="isShowForm?'display:block':'display:none'" v-if="isShowForm">
<div class="msgBg" @click="closeOpt"></div>
<div class="msgMain">
<div class="content">
<div class="word">
<div class="relative bg-f6 ulib-r10">
<input class="wp100 inner30 font-30 bg-f6 border-none ulib-r10" type="text" v-model="uname"
placeholder="请输入团员姓名"/>
</div>
<div class="mt30 relative bg-f6 ulib-r10">
<input class="wp100 inner30 font-30 bg-f6 border-none ulib-r10" type="tel" v-model="mobile"
placeholder="请输入手机号"/>
</div>
</div>
<div class="mt30">
<a class="block pt25 pb25 bg-1a1a1a text-center font-32 color-fff ulib-r10" @click="submit()">{{formIndex>-1?'修改':'新增'}}</a>
</div>
</div>
</div>
</div>
<div class="msg fn-hide" :style="isShowDel?'display:block':'display:none'" v-if="isShowDel">
<div class="msgBg" @click="closeOpt"></div>
<div class="msgMain">
<div class="content" style="padding:0;">
<div class="pt60 pb60 pl40 pr40 text-center font-32">确认删除{{list[delIndex].uname}}"吗?"</div>
<div class="fn-flex bts-1-eee text-center font-28">
<a class="fn-flex-item pt30 pb30" href="javascript:void(0);" @click="delOpt()">确定</a>
<a class="fn-flex-item pt30 pb30 bls-1-eee color-999" href="javascript:void(0);" @click="closeOpt">取消</a>
</div>
</div>
</div>
</div>
<div class="msg fn-hide" :style="isShowAble?'display:block':'display:none'" v-if="isShowAble">
<div class="msgBg" @click="closeOpt"></div>
<div class="msgMain">
<div class="content" style="padding:0;">
<div class="pt60 pb60 pl40 pr40 text-center font-32">
{{list[ableIndex].status==1?'确认启用':'确认禁用'}}{{list[ableIndex].uname}}"吗?"
</div>
<div class="fn-flex bts-1-eee text-center font-28">
<a class="fn-flex-item pt30 pb30" href="javascript:void(0);" @click="ableOpt()">确定</a>
<a class="fn-flex-item pt30 pb30 bls-1-eee color-999" href="javascript:void(0);" @click="closeOpt">取消</a>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
function _Debounce(fn, t) {
let delay = t || 500;
let timer;
return function () {
let args = arguments;
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(() => {
timer = null;
fn.apply(this, args);
}, delay);
}
}
var app = new Vue({
el: '#app',
data: {
keyWord: '',
info: {},
loading: false,
isDataEnd: false,
isNoData: false,
page: 1, //页数
size: 10, //每页取多少个数据
list: [],
uname: '',
mobile: '',
isSubmiting: false,
isRefresh: false,//是否是刷新列表,用于操作后刷新列表
isShowForm: false,
isShowDel: false,
isShowAble: false,
formIndex: -1,
delIndex: -1,
ableIndex: -1,
},
mounted() {
this.getInfo()
},
methods: {
//获取基础信息
getInfo() {
this.info = {
title: "<?=$team_name?>",
logo: "<?=$headimg?>",
}
},
//拉取数据
fetchData: function () {
this.getStaffList()
},
//团员列表
searchHandler: _Debounce(function () {
this.loading = false;
this.isDataEnd = false;
this.isNoData = false;
this.page = 1;
this.list = [];
this.getStaffList()
}, 250),
//团员列表
getStaffList() {
let that = this;
if (!that.isNoData && !that.isDataEnd && !that.loading) {
that.loading = true;
//请求参数
let params = {};
params['keyWord'] = that.keyWord;
params['team_id'] = <?=$team_id?>;
if (this.isRefresh) {//刷新列表参数
this.page = this.page - 1;
params['page'] = 1;
params['size'] = this.page * this.size;
} else {
params['page'] = this.page;
params['size'] = this.size;
}
//请求接口
$.get('/h5/market/sylive/userTeam/lists', params, function (result) {
that.loading = false;
that.isRefresh = false;
if (result.code == 200) {
that.page = that.page + 1;
that.list = that.list.concat(result.data.list);
if (result.data.total == 0) {
that.isNoData = true;
} else if (that.list.length == result.data.total) {
that.isDataEnd = true;
}
} else {
mDialog.msg({content: result.msg});
}
}, 'json');
}
},
//关闭弹框
closeOpt: function () {
this.isShowForm = false;
this.isShowDel = false;
this.isShowAble = false;
},
//显示新增编辑弹框
showForm(index) {
this.formIndex = index;
this.isShowForm = true;
if (index > -1) {
this.uname = this.list[index].uname;
this.mobile = this.list[index].mobile;
}
},
//提交新增编辑弹框
submit() {
let that = this;
if (that.isSubmiting) return;
if (!that.uname) {
mDialog.msg({
duration: 250,
pause: 2000,
content: "请输入团员姓名"
});
} else if (!/^1[3456789]\d{9}$/.test(that.mobile)) {
mDialog.msg({
duration: 250,
pause: 2000,
content: "请输入正确手机号"
});
} else {
that.isSubmiting = true;
let url = '/h5/market/sylive/userTeam/add';
let params = {};
params['uname'] = that.uname;
params['mobile'] = that.mobile;
params['team_id'] = <?=$team_id?>;
if (that.formIndex > -1) {
url = '/h5/market/sylive/userTeam/edit';
params['userId'] = this.list[that.formIndex].userId;
}
$.post(url, params, function (response) {
mDialog.msg({content: response.msg});
that.isSubmiting = false;
if (response.code == 200) {
that.isShowForm = false;
that.uname = '';
that.mobile = '';
that.loading = false;
that.isDataEnd = false;
that.isNoData = false;
that.page = 1;
that.list = [];
that.getStaffList();
}
}, 'json');
}
},
//显示启用禁用确认框
showAble(index) {
this.ableIndex = index;
this.isShowAble = true;
},
//启用禁用
ableOpt() {
//请求参数delOpt
let that = this;
let params = {};
params['userId'] = that.list[that.ableIndex].userId;
params['status'] = that.list[that.ableIndex].status == 1 ? 0 : 1;
//执行接口
$.post('/h5/market/sylive/userTeam/status', params, function (response) {
mDialog.msg({content: response.msg});
if (response.code == 200) {
that.list[that.ableIndex].status = that.list[that.ableIndex].status == 1 ? 0 : 1;
that.isShowAble = false;
}
}, 'json');
},
//删除确认框
showDel(index) {
this.delIndex = index;
this.isShowDel = true;
},
//删除
delOpt() {
let that = this;
//请求参数
let params = {};
params['userId'] = that.list[that.delIndex].userId;
params['status'] = -1;
$.post('/h5/market/sylive/userTeam/status', params, function (response) {
mDialog.msg({content: response.msg});
if (response.code == 200) {
that.isShowDel = false;
that.isRefresh = true;
that.loading = false;
that.isDataEnd = false;
that.isNoData = false;
that.list = [];
that.getStaffList();
}
}, 'json');
},
},
})
</script>
<?= $this->load->view('h5/market/sylive/hidden_wx_share') ?>
</body>