作者 杨育虎

2

... ... @@ -23,6 +23,8 @@ class User extends Backend
parent::_initialize();
$this->model = new \app\admin\model\User;
$this->view->assign("vipList", $this->model->getVipList());
$this->view->assign("isBlackList", $this->model->getIsBlackList());
$this->view->assign("typeList", $this->model->getTypeList());
}
/**
... ... @@ -32,45 +34,4 @@ class User extends Backend
*/
/**
* 查看
*/
public function index()
{
//当前是否为关联查询
$this->relationSearch = false;
//设置过滤方法
$this->request->filter(['strip_tags', 'trim']);
if ($this->request->isAjax())
{
//如果发送的来源是Selectpage,则转发到Selectpage
if ($this->request->request('keyField'))
{
return $this->selectpage();
}
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
$total = $this->model
->where($where)
->order($sort, $order)
->count();
$list = $this->model
->where($where)
->order($sort, $order)
->limit($offset, $limit)
->select();
foreach ($list as $row) {
$row->visible(['id','avatar','nickname','mobile','address','address_con','car_num','color','car_type','createtime','updatetime','vip','exptime']);
}
$list = collection($list)->toArray();
$result = array("total" => $total, "rows" => $list);
return json($result);
}
return $this->view->fetch();
}
}
... ...
... ... @@ -19,5 +19,12 @@ return [
'Vip' => '会员状态',
'Vip 1' => '会员',
'Vip 0' => '非会员',
'Exptime' => '会员到期时间'
'Exptime' => '会员到期时间',
'Is_black' => '拉黑',
'Is_black 1' => '是',
'Is_black 0' => '否',
'Type' => '身份',
'Type 1' => '用户',
'Type 2' => '找车工',
'Type 3' => '洗车工'
];
... ...
... ... @@ -26,7 +26,9 @@ class User extends Model
// 追加属性
protected $append = [
'vip_text',
'exptime_text'
'exptime_text',
'is_black_text',
'type_text'
];
... ... @@ -36,6 +38,16 @@ class User extends Model
return ['1' => __('Vip 1'), '0' => __('Vip 0')];
}
public function getIsBlackList()
{
return ['1' => __('Is_black 1'), '0' => __('Is_black 0')];
}
public function getTypeList()
{
return ['1' => __('Type 1'), '2' => __('Type 2'), '3' => __('Type 3')];
}
public function getVipTextAttr($value, $data)
{
... ... @@ -51,6 +63,22 @@ class User extends Model
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
}
public function getIsBlackTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['is_black']) ? $data['is_black'] : '');
$list = $this->getIsBlackList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getTypeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
$list = $this->getTypeList();
return isset($list[$value]) ? $list[$value] : '';
}
protected function setExptimeAttr($value)
{
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
... ...
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<!--<div class="form-group">-->
<!--<label class="control-label col-xs-12 col-sm-2">{:__('Openid')}:</label>-->
<!--<div class="col-xs-12 col-sm-8">-->
<!--<input id="c-openid" data-rule="required" class="form-control" name="row[openid]" type="text">-->
<!--</div>-->
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Openid')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-openid" data-rule="required" class="form-control" name="row[openid]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Avatar')}:</label>
... ... @@ -74,12 +74,12 @@
<input id="c-car_type" class="form-control" name="row[car_type]" type="text">
</div>
</div>
<!--<div class="form-group">-->
<!--<label class="control-label col-xs-12 col-sm-2">{:__('Token')}:</label>-->
<!--<div class="col-xs-12 col-sm-8">-->
<!--<input id="c-token" class="form-control" name="row[token]" type="text">-->
<!--</div>-->
<!--</div>-->
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Token')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-token" class="form-control" name="row[token]" type="text">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Vip')}:</label>
<div class="col-xs-12 col-sm-8">
... ... @@ -98,6 +98,30 @@
<input id="c-exptime" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[exptime]" type="text" value="{:date('Y-m-d H:i:s')}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Is_black')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-is_black" data-rule="required" class="form-control selectpicker" name="row[is_black]">
{foreach name="isBlackList" item="vo"}
<option value="{$key}" {in name="key" value=""}selected{/in}>{$vo}</option>
{/foreach}
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-type" data-rule="required" class="form-control selectpicker" name="row[type]">
{foreach name="typeList" item="vo"}
<option value="{$key}" {in name="key" value=""}selected{/in}>{$vo}</option>
{/foreach}
</select>
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
... ...
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<!--<div class="form-group">-->
<!--<label class="control-label col-xs-12 col-sm-2">{:__('Openid')}:</label>-->
<!--<div class="col-xs-12 col-sm-8">-->
<!--<input id="c-openid" data-rule="required" class="form-control" name="row[openid]" type="text" value="{$row.openid|htmlentities}">-->
<!--</div>-->
<!--</div>-->
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Openid')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-openid" data-rule="required" class="form-control" name="row[openid]" type="text" value="{$row.openid|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Avatar')}:</label>
<div class="col-xs-12 col-sm-8">
... ... @@ -74,12 +74,12 @@
<input id="c-car_type" class="form-control" name="row[car_type]" type="text" value="{$row.car_type|htmlentities}">
</div>
</div>
<!--<div class="form-group">-->
<!--<label class="control-label col-xs-12 col-sm-2">{:__('Token')}:</label>-->
<!--<div class="col-xs-12 col-sm-8">-->
<!--<input id="c-token" class="form-control" name="row[token]" type="text" value="{$row.token|htmlentities}">-->
<!--</div>-->
<!--</div>-->
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Token')}:</label>
<div class="col-xs-12 col-sm-8">
<input id="c-token" class="form-control" name="row[token]" type="text" value="{$row.token|htmlentities}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Vip')}:</label>
<div class="col-xs-12 col-sm-8">
... ... @@ -98,6 +98,30 @@
<input id="c-exptime" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[exptime]" type="text" value="{:$row.exptime?datetime($row.exptime):''}">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Is_black')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-is_black" data-rule="required" class="form-control selectpicker" name="row[is_black]">
{foreach name="isBlackList" item="vo"}
<option value="{$key}" {in name="key" value="$row.is_black"}selected{/in}>{$vo}</option>
{/foreach}
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
<div class="col-xs-12 col-sm-8">
<select id="c-type" data-rule="required" class="form-control selectpicker" name="row[type]">
{foreach name="typeList" item="vo"}
<option value="{$key}" {in name="key" value="$row.type"}selected{/in}>{$vo}</option>
{/foreach}
</select>
</div>
</div>
<div class="form-group layer-footer">
<label class="control-label col-xs-12 col-sm-2"></label>
<div class="col-xs-12 col-sm-8">
... ...
... ... @@ -25,18 +25,24 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'openid', title: __('Openid')},
{field: 'avatar', title: __('Avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image},
{field: 'nickname', title: __('Nickname')},
{field: 'mobile', title: __('Mobile')},
{field: 'address', title: __('Address')},
{field: 'address_con', title: __('Address_con')},
{field: 'lat', title: __('Lat')},
{field: 'lng', title: __('Lng')},
{field: 'car_num', title: __('Car_num')},
{field: 'color', title: __('Color')},
{field: 'car_type', title: __('Car_type')},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'token', title: __('Token')},
{field: 'vip', title: __('Vip'), searchList: {"1":__('Vip 1'),"0":__('Vip 0')}, formatter: Table.api.formatter.normal},
{field: 'exptime', title: __('Exptime')},
{field: 'is_black', title: __('Is_black'), searchList: {"1":__('Is_black 1'),"0":__('Is_black 0')}, formatter: Table.api.formatter.normal},
{field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2'),"3":__('Type 3')}, formatter: Table.api.formatter.normal},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
... ...