作者 杨育虎

2

@@ -23,6 +23,8 @@ class User extends Backend @@ -23,6 +23,8 @@ class User extends Backend
23 parent::_initialize(); 23 parent::_initialize();
24 $this->model = new \app\admin\model\User; 24 $this->model = new \app\admin\model\User;
25 $this->view->assign("vipList", $this->model->getVipList()); 25 $this->view->assign("vipList", $this->model->getVipList());
  26 + $this->view->assign("isBlackList", $this->model->getIsBlackList());
  27 + $this->view->assign("typeList", $this->model->getTypeList());
26 } 28 }
27 29
28 /** 30 /**
@@ -32,45 +34,4 @@ class User extends Backend @@ -32,45 +34,4 @@ class User extends Backend
32 */ 34 */
33 35
34 36
35 - /**  
36 - * 查看  
37 - */  
38 - public function index()  
39 - {  
40 - //当前是否为关联查询  
41 - $this->relationSearch = false;  
42 - //设置过滤方法  
43 - $this->request->filter(['strip_tags', 'trim']);  
44 - if ($this->request->isAjax())  
45 - {  
46 - //如果发送的来源是Selectpage,则转发到Selectpage  
47 - if ($this->request->request('keyField'))  
48 - {  
49 - return $this->selectpage();  
50 - }  
51 - list($where, $sort, $order, $offset, $limit) = $this->buildparams();  
52 - $total = $this->model  
53 -  
54 - ->where($where)  
55 - ->order($sort, $order)  
56 - ->count();  
57 -  
58 - $list = $this->model  
59 -  
60 - ->where($where)  
61 - ->order($sort, $order)  
62 - ->limit($offset, $limit)  
63 - ->select();  
64 -  
65 - foreach ($list as $row) {  
66 - $row->visible(['id','avatar','nickname','mobile','address','address_con','car_num','color','car_type','createtime','updatetime','vip','exptime']);  
67 -  
68 - }  
69 - $list = collection($list)->toArray();  
70 - $result = array("total" => $total, "rows" => $list);  
71 -  
72 - return json($result);  
73 - }  
74 - return $this->view->fetch();  
75 - }  
76 } 37 }
@@ -19,5 +19,12 @@ return [ @@ -19,5 +19,12 @@ return [
19 'Vip' => '会员状态', 19 'Vip' => '会员状态',
20 'Vip 1' => '会员', 20 'Vip 1' => '会员',
21 'Vip 0' => '非会员', 21 'Vip 0' => '非会员',
22 - 'Exptime' => '会员到期时间' 22 + 'Exptime' => '会员到期时间',
  23 + 'Is_black' => '拉黑',
  24 + 'Is_black 1' => '是',
  25 + 'Is_black 0' => '否',
  26 + 'Type' => '身份',
  27 + 'Type 1' => '用户',
  28 + 'Type 2' => '找车工',
  29 + 'Type 3' => '洗车工'
23 ]; 30 ];
@@ -26,7 +26,9 @@ class User extends Model @@ -26,7 +26,9 @@ class User extends Model
26 // 追加属性 26 // 追加属性
27 protected $append = [ 27 protected $append = [
28 'vip_text', 28 'vip_text',
29 - 'exptime_text' 29 + 'exptime_text',
  30 + 'is_black_text',
  31 + 'type_text'
30 ]; 32 ];
31 33
32 34
@@ -36,6 +38,16 @@ class User extends Model @@ -36,6 +38,16 @@ class User extends Model
36 return ['1' => __('Vip 1'), '0' => __('Vip 0')]; 38 return ['1' => __('Vip 1'), '0' => __('Vip 0')];
37 } 39 }
38 40
  41 + public function getIsBlackList()
  42 + {
  43 + return ['1' => __('Is_black 1'), '0' => __('Is_black 0')];
  44 + }
  45 +
  46 + public function getTypeList()
  47 + {
  48 + return ['1' => __('Type 1'), '2' => __('Type 2'), '3' => __('Type 3')];
  49 + }
  50 +
39 51
40 public function getVipTextAttr($value, $data) 52 public function getVipTextAttr($value, $data)
41 { 53 {
@@ -51,6 +63,22 @@ class User extends Model @@ -51,6 +63,22 @@ class User extends Model
51 return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value; 63 return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
52 } 64 }
53 65
  66 +
  67 + public function getIsBlackTextAttr($value, $data)
  68 + {
  69 + $value = $value ? $value : (isset($data['is_black']) ? $data['is_black'] : '');
  70 + $list = $this->getIsBlackList();
  71 + return isset($list[$value]) ? $list[$value] : '';
  72 + }
  73 +
  74 +
  75 + public function getTypeTextAttr($value, $data)
  76 + {
  77 + $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
  78 + $list = $this->getTypeList();
  79 + return isset($list[$value]) ? $list[$value] : '';
  80 + }
  81 +
54 protected function setExptimeAttr($value) 82 protected function setExptimeAttr($value)
55 { 83 {
56 return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value); 84 return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
1 <form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> 1 <form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
2 2
3 - <!--<div class="form-group">-->  
4 - <!--<label class="control-label col-xs-12 col-sm-2">{:__('Openid')}:</label>-->  
5 - <!--<div class="col-xs-12 col-sm-8">-->  
6 - <!--<input id="c-openid" data-rule="required" class="form-control" name="row[openid]" type="text">-->  
7 - <!--</div>--> 3 + <div class="form-group">
  4 + <label class="control-label col-xs-12 col-sm-2">{:__('Openid')}:</label>
  5 + <div class="col-xs-12 col-sm-8">
  6 + <input id="c-openid" data-rule="required" class="form-control" name="row[openid]" type="text">
  7 + </div>
8 </div> 8 </div>
9 <div class="form-group"> 9 <div class="form-group">
10 <label class="control-label col-xs-12 col-sm-2">{:__('Avatar')}:</label> 10 <label class="control-label col-xs-12 col-sm-2">{:__('Avatar')}:</label>
@@ -74,12 +74,12 @@ @@ -74,12 +74,12 @@
74 <input id="c-car_type" class="form-control" name="row[car_type]" type="text"> 74 <input id="c-car_type" class="form-control" name="row[car_type]" type="text">
75 </div> 75 </div>
76 </div> 76 </div>
77 - <!--<div class="form-group">-->  
78 - <!--<label class="control-label col-xs-12 col-sm-2">{:__('Token')}:</label>-->  
79 - <!--<div class="col-xs-12 col-sm-8">-->  
80 - <!--<input id="c-token" class="form-control" name="row[token]" type="text">-->  
81 - <!--</div>-->  
82 - <!--</div>--> 77 + <div class="form-group">
  78 + <label class="control-label col-xs-12 col-sm-2">{:__('Token')}:</label>
  79 + <div class="col-xs-12 col-sm-8">
  80 + <input id="c-token" class="form-control" name="row[token]" type="text">
  81 + </div>
  82 + </div>
83 <div class="form-group"> 83 <div class="form-group">
84 <label class="control-label col-xs-12 col-sm-2">{:__('Vip')}:</label> 84 <label class="control-label col-xs-12 col-sm-2">{:__('Vip')}:</label>
85 <div class="col-xs-12 col-sm-8"> 85 <div class="col-xs-12 col-sm-8">
@@ -98,6 +98,30 @@ @@ -98,6 +98,30 @@
98 <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')}"> 98 <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')}">
99 </div> 99 </div>
100 </div> 100 </div>
  101 + <div class="form-group">
  102 + <label class="control-label col-xs-12 col-sm-2">{:__('Is_black')}:</label>
  103 + <div class="col-xs-12 col-sm-8">
  104 +
  105 + <select id="c-is_black" data-rule="required" class="form-control selectpicker" name="row[is_black]">
  106 + {foreach name="isBlackList" item="vo"}
  107 + <option value="{$key}" {in name="key" value=""}selected{/in}>{$vo}</option>
  108 + {/foreach}
  109 + </select>
  110 +
  111 + </div>
  112 + </div>
  113 + <div class="form-group">
  114 + <label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
  115 + <div class="col-xs-12 col-sm-8">
  116 +
  117 + <select id="c-type" data-rule="required" class="form-control selectpicker" name="row[type]">
  118 + {foreach name="typeList" item="vo"}
  119 + <option value="{$key}" {in name="key" value=""}selected{/in}>{$vo}</option>
  120 + {/foreach}
  121 + </select>
  122 +
  123 + </div>
  124 + </div>
101 <div class="form-group layer-footer"> 125 <div class="form-group layer-footer">
102 <label class="control-label col-xs-12 col-sm-2"></label> 126 <label class="control-label col-xs-12 col-sm-2"></label>
103 <div class="col-xs-12 col-sm-8"> 127 <div class="col-xs-12 col-sm-8">
1 <form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> 1 <form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
2 2
3 - <!--<div class="form-group">-->  
4 - <!--<label class="control-label col-xs-12 col-sm-2">{:__('Openid')}:</label>-->  
5 - <!--<div class="col-xs-12 col-sm-8">-->  
6 - <!--<input id="c-openid" data-rule="required" class="form-control" name="row[openid]" type="text" value="{$row.openid|htmlentities}">-->  
7 - <!--</div>-->  
8 - <!--</div>--> 3 + <div class="form-group">
  4 + <label class="control-label col-xs-12 col-sm-2">{:__('Openid')}:</label>
  5 + <div class="col-xs-12 col-sm-8">
  6 + <input id="c-openid" data-rule="required" class="form-control" name="row[openid]" type="text" value="{$row.openid|htmlentities}">
  7 + </div>
  8 + </div>
9 <div class="form-group"> 9 <div class="form-group">
10 <label class="control-label col-xs-12 col-sm-2">{:__('Avatar')}:</label> 10 <label class="control-label col-xs-12 col-sm-2">{:__('Avatar')}:</label>
11 <div class="col-xs-12 col-sm-8"> 11 <div class="col-xs-12 col-sm-8">
@@ -74,12 +74,12 @@ @@ -74,12 +74,12 @@
74 <input id="c-car_type" class="form-control" name="row[car_type]" type="text" value="{$row.car_type|htmlentities}"> 74 <input id="c-car_type" class="form-control" name="row[car_type]" type="text" value="{$row.car_type|htmlentities}">
75 </div> 75 </div>
76 </div> 76 </div>
77 - <!--<div class="form-group">-->  
78 - <!--<label class="control-label col-xs-12 col-sm-2">{:__('Token')}:</label>-->  
79 - <!--<div class="col-xs-12 col-sm-8">-->  
80 - <!--<input id="c-token" class="form-control" name="row[token]" type="text" value="{$row.token|htmlentities}">-->  
81 - <!--</div>-->  
82 - <!--</div>--> 77 + <div class="form-group">
  78 + <label class="control-label col-xs-12 col-sm-2">{:__('Token')}:</label>
  79 + <div class="col-xs-12 col-sm-8">
  80 + <input id="c-token" class="form-control" name="row[token]" type="text" value="{$row.token|htmlentities}">
  81 + </div>
  82 + </div>
83 <div class="form-group"> 83 <div class="form-group">
84 <label class="control-label col-xs-12 col-sm-2">{:__('Vip')}:</label> 84 <label class="control-label col-xs-12 col-sm-2">{:__('Vip')}:</label>
85 <div class="col-xs-12 col-sm-8"> 85 <div class="col-xs-12 col-sm-8">
@@ -98,6 +98,30 @@ @@ -98,6 +98,30 @@
98 <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):''}"> 98 <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):''}">
99 </div> 99 </div>
100 </div> 100 </div>
  101 + <div class="form-group">
  102 + <label class="control-label col-xs-12 col-sm-2">{:__('Is_black')}:</label>
  103 + <div class="col-xs-12 col-sm-8">
  104 +
  105 + <select id="c-is_black" data-rule="required" class="form-control selectpicker" name="row[is_black]">
  106 + {foreach name="isBlackList" item="vo"}
  107 + <option value="{$key}" {in name="key" value="$row.is_black"}selected{/in}>{$vo}</option>
  108 + {/foreach}
  109 + </select>
  110 +
  111 + </div>
  112 + </div>
  113 + <div class="form-group">
  114 + <label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
  115 + <div class="col-xs-12 col-sm-8">
  116 +
  117 + <select id="c-type" data-rule="required" class="form-control selectpicker" name="row[type]">
  118 + {foreach name="typeList" item="vo"}
  119 + <option value="{$key}" {in name="key" value="$row.type"}selected{/in}>{$vo}</option>
  120 + {/foreach}
  121 + </select>
  122 +
  123 + </div>
  124 + </div>
101 <div class="form-group layer-footer"> 125 <div class="form-group layer-footer">
102 <label class="control-label col-xs-12 col-sm-2"></label> 126 <label class="control-label col-xs-12 col-sm-2"></label>
103 <div class="col-xs-12 col-sm-8"> 127 <div class="col-xs-12 col-sm-8">
@@ -25,18 +25,24 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin @@ -25,18 +25,24 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
25 [ 25 [
26 {checkbox: true}, 26 {checkbox: true},
27 {field: 'id', title: __('Id')}, 27 {field: 'id', title: __('Id')},
  28 + {field: 'openid', title: __('Openid')},
28 {field: 'avatar', title: __('Avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image}, 29 {field: 'avatar', title: __('Avatar'), events: Table.api.events.image, formatter: Table.api.formatter.image},
29 {field: 'nickname', title: __('Nickname')}, 30 {field: 'nickname', title: __('Nickname')},
30 {field: 'mobile', title: __('Mobile')}, 31 {field: 'mobile', title: __('Mobile')},
31 {field: 'address', title: __('Address')}, 32 {field: 'address', title: __('Address')},
32 {field: 'address_con', title: __('Address_con')}, 33 {field: 'address_con', title: __('Address_con')},
  34 + {field: 'lat', title: __('Lat')},
  35 + {field: 'lng', title: __('Lng')},
33 {field: 'car_num', title: __('Car_num')}, 36 {field: 'car_num', title: __('Car_num')},
34 {field: 'color', title: __('Color')}, 37 {field: 'color', title: __('Color')},
35 {field: 'car_type', title: __('Car_type')}, 38 {field: 'car_type', title: __('Car_type')},
36 {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, 39 {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
37 {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime}, 40 {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  41 + {field: 'token', title: __('Token')},
38 {field: 'vip', title: __('Vip'), searchList: {"1":__('Vip 1'),"0":__('Vip 0')}, formatter: Table.api.formatter.normal}, 42 {field: 'vip', title: __('Vip'), searchList: {"1":__('Vip 1'),"0":__('Vip 0')}, formatter: Table.api.formatter.normal},
39 {field: 'exptime', title: __('Exptime')}, 43 {field: 'exptime', title: __('Exptime')},
  44 + {field: 'is_black', title: __('Is_black'), searchList: {"1":__('Is_black 1'),"0":__('Is_black 0')}, formatter: Table.api.formatter.normal},
  45 + {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2'),"3":__('Type 3')}, formatter: Table.api.formatter.normal},
40 {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} 46 {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
41 ] 47 ]
42 ] 48 ]