liche update for admin user support super majia
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
require_once(dirname(__DIR__).'/Appconf.php');
|
||||
|
||||
/**
|
||||
* 为app用户披上马甲以在小程序里查看其他用户信息,方便线上测试
|
||||
* Created by PhpStorm.
|
||||
* User: xuxb
|
||||
* Date: 2020/4/29
|
||||
* Time: 15:40
|
||||
*/
|
||||
class Umajia extends Appconf{
|
||||
public function index(){
|
||||
// TODO: Implement index() method.
|
||||
}
|
||||
|
||||
public function lists(){
|
||||
// TODO: Implement lists() method.
|
||||
}
|
||||
|
||||
public function get(){
|
||||
$uid = intval($this->input->get('uid'));
|
||||
|
||||
$row = $this->u_entity->get(array('id'=>$uid));
|
||||
$info = array(
|
||||
'uid' => $row['id'],
|
||||
'nickname' => $row['nickname'],
|
||||
'mobile' => $row['mobile'],
|
||||
);
|
||||
$majia = array();
|
||||
$title ='披上马甲';
|
||||
if($row['jsondata']){
|
||||
$json = json_decode($row['jsondata'], true);
|
||||
$majia_uid = $json['majia']['uid'];
|
||||
|
||||
if($majia_uid){
|
||||
$row = $this->u_entity->get(array('id'=>$majia_uid));
|
||||
if($row){
|
||||
$majia = array(
|
||||
'uid' => $row['id'],
|
||||
'nickname' => $row['nickname'],
|
||||
'mobile' => $row['mobile'],
|
||||
);
|
||||
$title ='编辑马甲';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$info['majia'] = $majia;
|
||||
|
||||
$this->data['info'] = $info;
|
||||
$this->data['_title'] = $title;
|
||||
$this->show_view('app/appusual/umajia/get', true);
|
||||
}
|
||||
|
||||
public function add(){
|
||||
// TODO: Implement add() method.
|
||||
}
|
||||
|
||||
public function edit(){
|
||||
$info = $this->input->post('info');
|
||||
|
||||
$uid = $info['uid'];
|
||||
|
||||
$user = $this->u_entity->get(array('id'=>$uid));
|
||||
$json = $user['jsondata'] ? json_decode($user['jsondata'], true) : array();
|
||||
|
||||
if($info['majia']){
|
||||
$json['majia'] = array('uid' => $info['majia']['uid']);
|
||||
} else {
|
||||
unset($json['majia']);
|
||||
}
|
||||
|
||||
$upd = array(
|
||||
'jsondata' => json_encode($json, JSON_UNESCAPED_UNICODE)
|
||||
);
|
||||
|
||||
$this->u_entity->update($upd, array('id' => $uid));
|
||||
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '操作成功!');
|
||||
}
|
||||
|
||||
public function del(){
|
||||
$uid = $this->input->post('uid');
|
||||
|
||||
$user = $this->u_entity->get(array('id' => $uid));
|
||||
$json = $user['jsondata'] ? json_decode($user['jsondata'], true) : array();
|
||||
unset($json['majia']);
|
||||
|
||||
$upd = array(
|
||||
'jsondata' => json_encode($json, JSON_UNESCAPED_UNICODE)
|
||||
);
|
||||
|
||||
$this->u_entity->update($upd, array('id' => $uid));
|
||||
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '操作成功!');
|
||||
}
|
||||
|
||||
public function batch(){
|
||||
// TODO: Implement batch() method.
|
||||
}
|
||||
|
||||
public function export(){
|
||||
// TODO: Implement export() method.
|
||||
}
|
||||
|
||||
}
|
||||
@@ -41,7 +41,18 @@ class Member extends HD_Controller{
|
||||
|
||||
$count = $this->userM->count($where);
|
||||
$lists = $this->userM->select($where,'id desc',$page,$size);
|
||||
foreach($lists as &$row_user){
|
||||
if(SUPER_ADMIN == $this->role){//超级管理员才允许操作用户的披上超级马甲
|
||||
$majia = array();
|
||||
if($row_user['jsondata']){
|
||||
$json = json_decode($row_user['jsondata'], true);
|
||||
$majia = $json['majia'] ? $json['majia'] : array();
|
||||
}
|
||||
$row_user['umajia'] = $majia;
|
||||
}
|
||||
}
|
||||
|
||||
$this->data['app_id'] = 1;
|
||||
$this->data['lists'] = $lists;
|
||||
$this->data['_title'] = '用户列表';
|
||||
$this->data['pager'] = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count);
|
||||
|
||||
@@ -42,7 +42,17 @@ class Member extends HD_Controller{
|
||||
$biz = $this->biz_model->get(['id'=>$val['biz_id']],'biz_name');
|
||||
$lists[$key]['biz_name'] = $biz['biz_name'];
|
||||
$lists[$key]['group_name'] = $this->groups[$val['group_id']];
|
||||
|
||||
if(SUPER_ADMIN == $this->role){//超级管理员才允许操作用户的披上超级马甲
|
||||
$majia = array();
|
||||
if($val['jsondata']){
|
||||
$json = json_decode($val['jsondata'], true);
|
||||
$majia = $json['majia'] ? $json['majia'] : array();
|
||||
}
|
||||
$lists[$key]['umajia'] = $majia;
|
||||
}
|
||||
}
|
||||
$this->data['app_id'] = 2;
|
||||
$this->data['lists'] = $lists;
|
||||
$this->data['_title'] = '用户列表';
|
||||
$this->data['pager'] = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count);
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
<form id="vue-app" class="am-form am-form-horizontal ml20" action="/app/appusual/umajia/edit"
|
||||
data-auto="true" method="post" style="width: 90%;padding-top: 10px">
|
||||
<div class="am-form-group">
|
||||
<span class="am-para-label">用户信息:</span>
|
||||
<div class="am-para-input" style="width: 50%">
|
||||
<span>{{info.nickname}} {{info.mobile}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">马甲信息:</label>
|
||||
<div class="am-para-input">
|
||||
<span class="mr10">{{info.majia.nickname}} {{info.majia.mobile}}</span>
|
||||
<button class="am-btn am-btn-success" type="button" @click="userModal">选择马甲</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<div class="am-para-input">
|
||||
<button class="am-btn am-btn-secondary" type="button" @click='saveEdit();'>保存</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="user-modal" style="display: none;">
|
||||
<div class="modal-body">
|
||||
<table class="table table-middle" style="margin-bottom: 0px;">
|
||||
<colgroup>
|
||||
<col width="35%"/>
|
||||
<col width="35%"/>
|
||||
<col width="30%"/>
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-left">用户列表</th>
|
||||
<th class="text-right">
|
||||
<form class="form-inline">
|
||||
<div class="form-group" style="margin-bottom: 0px;">
|
||||
<label class="sr-only" for="search">搜用户</label>
|
||||
<div class="input-group input-group-sm">
|
||||
<input type="text" class="form-control" style="font-size: 1.2rem;"
|
||||
v-model='keyword' placeholder="客服昵称或手机号">
|
||||
<div class="input-group-btn">
|
||||
<button type="button" @click='getUsers(1);' class="btn btn-default">搜
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
<table class="table table-middle" style="margin-bottom: 0px;border-top: 0px;">
|
||||
<tbody>
|
||||
<tr v-for="(b,i) in users">
|
||||
<td>{{b.nickname}}({{b.mobile}})</td>
|
||||
<td class="text-right">
|
||||
<a v-if="b.is_checked==0" href="javascript:void(0);" @click="setUser(i,1)"
|
||||
class="btn btn-primary btn-sm">选择</a>
|
||||
<a v-else-if="b.is_checked==1" href="javascript:void(0);" @click="setUser(i,0)"
|
||||
class="btn btn-default btn-sm">移除</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="clearfix">
|
||||
<span class="pull-left text-muted">第{{userPage.page}}页(每页{{userPage.pageLimit}}条,共{{userPage.pageCount}}条)</span>
|
||||
<nav class="pull-right" aria-label="Page navigation">
|
||||
<ul class="pagination pagination-sm">
|
||||
<li v-if="userPage.page > 1">
|
||||
<a href="javascript:void(0);" @click="beforeUserPage();" aria-label="上一页">
|
||||
<span class="glyphicon glyphicon-menu-left"></span>
|
||||
</a>
|
||||
</li>
|
||||
<li v-if="userPage.hasNext">
|
||||
<a href="javascript:void(0);" @click="afterUserPage();" aria-label="下一页">
|
||||
<span class="glyphicon glyphicon-menu-right"></span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
var vue_app;
|
||||
var loading = false;
|
||||
$(function(){
|
||||
vue_app = new Vue({
|
||||
el: '#vue-app',
|
||||
data: {
|
||||
info:<?=$info ? json_encode($info, JSON_UNESCAPED_UNICODE) : '{}'?>,
|
||||
users: [],
|
||||
max_num: 0,
|
||||
keyword: '',
|
||||
userPage:[],
|
||||
app_id:'<?=$app_id?>'
|
||||
},
|
||||
computed: {},
|
||||
created: function () {
|
||||
},
|
||||
updated: function () {
|
||||
},
|
||||
methods: {
|
||||
userModal: function (index) {
|
||||
var vm = this;
|
||||
vm.keyword = vm.info.majia.nickname;
|
||||
vm.getUsers(1);
|
||||
layer.open({
|
||||
type: 1,
|
||||
area: '500px', //宽高
|
||||
content: $('#user-modal'),
|
||||
title: '选取用户',
|
||||
shade: false,
|
||||
btn: ['选好了'],
|
||||
yes: function (index) {
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
},
|
||||
getUsers: function (page, size=5) {
|
||||
var vm = this;
|
||||
$.ajax({
|
||||
url: '/common/appusers',
|
||||
type: 'get',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
page: page,
|
||||
size: size,
|
||||
app_id:vm.app_id,
|
||||
keyword: vm.keyword
|
||||
},
|
||||
success: function (re) {
|
||||
if(re.data.total > 0){
|
||||
for(var i in re.data.list){
|
||||
if (vm.info.majia.uid == re.data.list[i].id) {
|
||||
re.data.list[i].is_checked = 1;
|
||||
} else {
|
||||
re.data.list[i].is_checked = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
vm.users = re.data.list;
|
||||
max_page = Math.ceil(re.data.total/size);
|
||||
vm.userPage = {page:page, pageLimit:size, pageCount:re.data.total, hasNext: page <max_page ? 1 : 0};
|
||||
}
|
||||
});
|
||||
},
|
||||
setUser: function (index, checked) {
|
||||
//设置门店是否选中
|
||||
var vm = this;
|
||||
vm.removeUser();
|
||||
if (checked == 1) {
|
||||
vm.users[index]['is_checked'] = checked;
|
||||
vm.info.majia.uid = vm.users[index]['id'];
|
||||
vm.info.majia.nickname = vm.users[index]['nickname'];
|
||||
vm.info.majia.mobile = vm.users[index]['mobile'];
|
||||
}
|
||||
},
|
||||
removeUser: function (index) {
|
||||
var vm = this;
|
||||
for (var i = 0; i < vm.users.length; i++) {
|
||||
vm.users[i]['is_checked'] = 0;
|
||||
}
|
||||
vm.info.majia = {};
|
||||
},
|
||||
beforeUserPage: function () {
|
||||
var vm = this;
|
||||
if (vm.userPage.page == 1) {
|
||||
layer.msg("已经是第一页了");
|
||||
return;
|
||||
}
|
||||
vm.userPage.page--;
|
||||
vm.getUsers(vm.userPage.page);
|
||||
},
|
||||
afterUserPage: function () {
|
||||
var vm = this;
|
||||
if (vm.userPage.page == vm.userPage.pageCount) {
|
||||
layer.msg("已经是末页了");
|
||||
return;
|
||||
}
|
||||
vm.userPage.page++;
|
||||
vm.getUsers(vm.userPage.page);
|
||||
},
|
||||
saveEdit: function () {
|
||||
if (loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
var vm = this;
|
||||
|
||||
loading = true;
|
||||
$.ajax({
|
||||
url: '/app/appusual/umajia/edit',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
info: vm.info,
|
||||
app_id:vm.app_id
|
||||
},
|
||||
beforeSend: function () {
|
||||
layer.load(1, {
|
||||
shade: [0.1, '#fff'] //0.1透明度的白色背景
|
||||
});
|
||||
},
|
||||
success: function (data) {
|
||||
loading = false;
|
||||
if (data['code']) {
|
||||
layer.msg(data.msg, {
|
||||
icon: 1,
|
||||
time: 2000
|
||||
}, function () {
|
||||
layer.closeAll();
|
||||
$.form.reload();
|
||||
});
|
||||
} else {
|
||||
layer.msg(data.msg, {icon: 2});
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
loading = false;
|
||||
layer.closeAll('loading');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -28,6 +28,7 @@
|
||||
<th width="20%"><span>手机号码</span></th>
|
||||
<th width="5%"><span>是否分销</span></th>
|
||||
<th width="20%"><span>创建时间</span></th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -40,6 +41,15 @@
|
||||
<input type="checkbox" class="mui-switch mui-switch-anim va-mid" true-value="1" false-value="0" <?=$v['dealer']&&!$v['up_uid']?'checked':''?> onchange="set_publish(this,<?=$v['id']?>)"/>
|
||||
</td>
|
||||
<td><?= date('Y-m-d H:i:s',$v['c_time']) ?></td>
|
||||
<td>
|
||||
<?if($v['umajia']){?>
|
||||
<a class="am-btn am-btn-primary am-btn-xs" data-open="/app/appusual/umajia/get?uid=<?=$v['id']?>&app_id=<?=$app_id?>" data-title="编辑马甲">编辑马甲</a>
|
||||
<a href="javascript:void(0)" data-ajax="post" data-action="/app/appusual/umajia/del?app_id=<?=$app_id?>"
|
||||
data-params-uid="<?=$v['id']?>" class="am-btn am-btn-xs am-btn-danger">脱去马甲</a>
|
||||
<?}elseif(isset($v['umajia'])){?>
|
||||
<a class="am-btn am-btn-primary am-btn-xs" data-open="/app/appusual/umajia/get?uid=<?=$v['id']?>&app_id=<?=$app_id?>" data-title="披上马甲">披上马甲</a>
|
||||
<?}?>
|
||||
</td>
|
||||
</tr>
|
||||
<!--
|
||||
<tr>
|
||||
|
||||
@@ -47,6 +47,13 @@
|
||||
<tr>
|
||||
<td colspan="6" class="align-r">
|
||||
<a data-modal="/app/licheb/member/get?id=<?=$v['id']?>" class="am-btn am-btn-primary am-btn-xs">修改</a>
|
||||
<?if($v['umajia']){?>
|
||||
<a class="am-btn am-btn-primary am-btn-xs" data-open="/app/appusual/umajia/get?uid=<?=$v['id']?>&app_id=<?=$app_id?>" data-title="编辑马甲">编辑马甲</a>
|
||||
<a href="javascript:void(0)" data-ajax="post" data-action="/app/appusual/umajia/del?app_id=<?=$app_id?>"
|
||||
data-params-uid="<?=$v['id']?>" class="am-btn am-btn-xs am-btn-danger">脱去马甲</a>
|
||||
<?}elseif(isset($v['umajia'])){?>
|
||||
<a class="am-btn am-btn-primary am-btn-xs" data-open="/app/appusual/umajia/get?uid=<?=$v['id']?>&app_id=<?=$app_id?>" data-title="披上马甲">披上马甲</a>
|
||||
<?}?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
@@ -21,4 +21,5 @@ create table lc_app_licheb_users (
|
||||
u_time timestamp not null default current_timestamp on update current_timestamp,
|
||||
primary key (id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='狸车宝用户表';
|
||||
alter table lc_app_licheb_users add column jsondata json default null comment '其他信息' after biz_id;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user