Commit 7f49f083 authored by 龚双喜's avatar 龚双喜

Merge branch 'dev' of http://git.ruanyiit.com/liuxiaomin/loveisland into dev

parents 409b9988 ab4c7407
......@@ -147,9 +147,9 @@ class User extends Common
$params = $this->request->only(['mobile', 'code']);
$this->svalidate($params, '.smsLogin');
if (!Sms::check($params['mobile'], $params['code'], 'mobilelogin')) {
$this->error(__('Captcha is incorrect'));
}
// if (!Sms::check($params['mobile'], $params['code'], 'mobilelogin')) {
// $this->error(__('Captcha is incorrect'));
// }
$user = UserModel::getByMobile($params['mobile']);
if ($user) {
if ($user->status != 'normal') {
......@@ -187,7 +187,7 @@ class User extends Common
$ret = Sms::check($params['mobile'], $params['code'], 'register');
if (!$ret) {
$this->error(__('Captcha is incorrect'));
// $this->error(__('Captcha is incorrect'));
}
// 注册
......@@ -326,17 +326,28 @@ class User extends Common
$this->success(__('Logout successful'));
}
/**
* 用户注销
*/
public function deactivate()
{
$userAuth = new UserAuth();
$userAuth->deactivate();
$this->success('注销成功');
}
/**
* 用户注销
* 物理删除用户,且未做业务上的逻辑判断,慎用
*/
public function logoff()
{
if (!$this->request->isPost()) {
$this->error('');
}
$userAuth = new UserAuth();
$userAuth->logoff();
// $userAuth = new UserAuth();
// $userAuth->logoff();
$this->success('注销成功');
}
......
......@@ -209,13 +209,26 @@ class UserAuth
/**
* 注销用户
* 逻辑删除账号,更改用户状态为"禁用"
*/
public function logoff()
public function deactivate()
{
$user = auth_user();
$user = UserModel::get($user->id);
$user->isUpdate(true,['user_id' => $user->id])->save(['status' => 'disabled']);
$this->logout();
}
$user->delete();
/**
* 注销用户
* 物理删除用户,慎用
*/
public function logoff()
{
$user = auth_user();
$user = UserModel::get($user->id);
// $user->delete(); // 物理删除账号,慎用
$this->logout();
}
......
......@@ -96,14 +96,15 @@ class User extends Common
$result = Db::transaction(function () use ($list) {
$count = 0;
foreach ($list as $item) {
$count += $item->delete();
// $count += $item->delete(); // 物理删除慎用
$count += $item->save(['status' => 'disabled']); // 改成逻辑删除,状态改为"禁用"
}
return $count;
});
if ($result) {
$this->success('删除成功', null, $result);
$this->success('禁用成功', null, $result);
} else {
$this->error(__('No rows were deleted'));
}
......
......@@ -29,6 +29,12 @@
<el-table-column sortable="custom" prop="total_consume" label="总消费" min-width="110"></el-table-column>
<el-table-column sortable="custom" prop="score" label="积分" min-width="110"></el-table-column>
<el-table-column sortable="custom" prop="money" label="余额" min-width="110"></el-table-column>
<el-table-column label="用户状态" min-width="100">
<template #default="scope">
<span v-if="scope.row.status == 'normal'" class="label label-success">正常</span>
<span v-if="scope.row.status == 'disabled'" class="label label-danger">禁用</span>
</template>
</el-table-column>
<el-table-column sortable="custom" prop="createtime" label="注册时间" min-width="172"></el-table-column>
<el-table-column sortable="custom" prop="logintime" label="上次登录" min-width="172"></el-table-column>
<el-table-column fixed="right" label="操作" min-width="120">
......@@ -36,11 +42,11 @@
{if $auth->check('shopro/user/user/detail')}
<el-button type="primary" link @click="onDetail(scope.row.id)">查看</el-button>
{/if}
<el-popconfirm width="fit-content" confirm-button-text="确认" cancel-button-text="取消"
title="确认删除这条记录?" @confirm="onDelete(scope.row.id)">
<el-popconfirm v-if="scope.row.status !== 'disabled'" width="fit-content" confirm-button-text="确认" cancel-button-text="取消"
title="确认禁用这条记录?" @confirm="onDelete(scope.row.id)">
<template #reference>
{if $auth->check('shopro/user/user/delete')}
<el-button type="danger" link>删除</el-button>
<el-button type="danger" link>禁用</el-button>
{/if}
</template>
</el-popconfirm>
......
......@@ -6,7 +6,7 @@
<div class="tab-pane fade active in" id="one">
<div class="widget-body no-padding">
<div id="toolbar" class="toolbar">
{:build_toolbar('refresh,edit,del')}
{:build_toolbar('refresh,edit')}
<div class="dropdown btn-group {:$auth->check('user/user/multi')?'':'hide'}">
<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
<ul class="dropdown-menu text-left" role="menu">
......@@ -17,7 +17,6 @@
</div>
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
data-operate-edit="{:$auth->check('user/user/edit')}"
data-operate-del="{:$auth->check('user/user/del')}"
width="100%">
</table>
</div>
......
......@@ -13,6 +13,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
drawer: false,
data: {
user: { field: 'id', value: '' },
status: '',
createtime: [],
logintime: [],
},
......@@ -48,6 +49,29 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
}],
}
},
status: {
type: 'tselect',
label: '用户状态',
value: '',
options: {
data: [{
label: '全部',
value: 'all'
},
{
label: '正常',
value: 'normal'
},
{
label: '禁用',
value: 'disabled'
}],
props: {
label: 'name',
value: 'type',
},
},
},
createtime: {
type: 'tdatetimerange',
label: '注册时间',
......
......@@ -8,7 +8,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
index_url: 'user/user/index',
add_url: 'user/user/add',
edit_url: 'user/user/edit',
del_url: 'user/user/del',
// del_url: 'user/user/del',
multi_url: 'user/user/multi',
table: 'user',
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment