123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- <?php
- namespace store\Admin;
- use Dever;
- class User extends Core
- {
- # 获取基本信息
- public function getData()
- {
- $id = Dever::input('id');
- if ($id) {
- $data = Dever::db('store/member')->find($id);
- } else {
- $data = false;
- }
-
- return $data;
- }
- # 获取角色
- public function getRole()
- {
- $role = Dever::db('store/member')->config['role'];
- $html = '<input update_type="checked" class="checkbox-checkall update_role_id update_value" type="checkbox" name="temp_update_role_id[]" value="0_update_role_id"/> 全选';
- $info = $this->getData();
- foreach ($role as $k => $v) {
- $checked = '';
- if ($info && $info['role_id']) {
- $temp = explode(',', $info['role_id']);
- if (in_array($k, $temp)) {
- $checked = 'checked';
- }
- }
- $html .= ' <input update_type="checked" class="autoload checkbox-checkall-0_update_role_id update_role_id update_value validate[required]" type="checkbox" name="update_role_id[]" value="'.$k.'" '.$checked.' /> '.$v.' ';
- }
- return $html;
- }
- # 订单列表
- public function getList()
- {
- $data = Dever::db('store/member')->list(array('store_id' => $this->id));
- $html = '';
- if ($data) {
- $role = Dever::db('store/member')->config['role'];
- foreach ($data as $k => $v) {
- $edit = Dever::url('user_edit?id=' . $v['id'], 'store');
- $temp = explode(',', $v['role_id']);
- $v['role_name'] = array();
- foreach ($temp as $k1 => $v1) {
- if (isset($role[$v1])) {
- $v['role_name'][] = $role[$v1];
- }
- }
- $v['role_name'] = implode(',', $v['role_name']);
- $cdate = date('Y-m-d H:i', $v['cdate']);
- $button = '<a href="javascript:;" onclick="fastEdit($(this), \''.$edit.'\', \'编辑\', \'\', 1)"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-xs">编辑</button></a>';
- if ($v['state'] == 1) {
- $state = 2;
- } else {
- $state = 1;
- }
- $del = Dever::url('admin/user.del?id=' . $v['id'] . '&state=' . $state, 'store');
- if ($state == 2) {
- $button .= ' <a href="'.$del.'" class="oper_delete"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-danger layui-btn-xs"><span class="am-icon-trash-o"></span>封禁</button></a>';
- } else {
- $button .= ' <a href="'.$del.'" class="oper_delete"><button type="button" class="btn btn-info btn-rounded waves-effect waves-light m-b-5 layui-btn layui-btn-danger layui-btn-xs"><span class="am-icon-trash-o"></span>恢复</button></a>';
- }
-
- $html .= '<tr><td>'.$v['name'].'</td><td>'.$v['mobile'].'</td><td>'.$v['role_name'].'</td><td>'.$cdate.'</td><td>'.$button.'</td></tr>';
- }
- }
- return $html;
- }
- # 获取基本信息
- public function getConfig()
- {
- $data['update'] = Dever::url('admin/user.update', 'store');
- $data['add'] = Dever::url('user_edit', 'store');
- $data['add'] = 'fastEdit($(this), \''.$data['add'].'\', \'添加新员工\', \'\', 1)';
- $data['search'] = Dever::url('user', 'store');
- $data['delete'] = Dever::url('admin/del', 'store');
- return $data;
- }
- # 认证
- public function update_api()
- {
- $input = Dever::input();
- $update['name'] = $input['update_name'];
- $update['avatar'] = $input['update_avatar'];
- $update['mobile'] = $input['update_mobile'];
- $update['role_id'] = $input['update_role_id'];
- $update['store_id'] = $this->id;
- $update['where_id'] = Dever::input('update_where_id');
- if ($update['where_id']) {
- Dever::db('store/member')->update($update);
- } else {
- Dever::db('store/member')->insert($update);
- }
- return 'reload';
- }
- # 删除
- public function del_api()
- {
- $update['where_id'] = Dever::input('id');
- if ($update['where_id']) {
- $update['state'] = Dever::input('state');
- Dever::db('store/member')->update($update);
- }
- return 'reload';
- }
- }
|