新增账号注销和接口

This commit is contained in:
gongfuxiang 2022-11-20 21:29:44 +08:00
parent 826f07b188
commit 8cef73671b
22 changed files with 290 additions and 52 deletions

View File

@ -52,6 +52,10 @@ class Agreement extends Base
[
'name' => '用户隐私政策',
'type' => 'privacy',
],
[
'name' => '账号注销协议',
'type' => 'logout',
]
];
$assign['nav_data'] = $nav_data;

View File

@ -0,0 +1,33 @@
{{include file="public/header" /}}
<!-- right content start -->
<div class="content-right">
<!-- table nav start -->
{{include file="agreement/nav" /}}
<!-- table nav end -->
<div class="content">
<!-- form start -->
<form class="am-form form-validation" action="{{:MyUrl('admin/agreement/save')}}" method="POST" request-type="ajax-url" request-value="{{:MyUrl('admin/agreement/index', ['nav_type'=>$nav_type])}}">
<div class="am-form-group">
<div class="am-cf">
<label><span class="am-form-group-label-tips am-margin-left-0">{{$data.common_agreement_userlogout.describe}}</span></label>
<a href="{{:MyUrl('index/agreement/index', ['document'=>'userlogout'])}}" target="_blank" class="am-fr">查看详情</a>
</div>
<textarea class="am-radius am-validate" name="{{$data.common_agreement_userlogout.only_tag}}" maxlength="105000" id="editor-tag" data-validation-message="{{$data.common_agreement_userlogout.error_tips}}">{{if !empty($data)}}{{$data.common_agreement_userlogout.value|raw}}{{/if}}</textarea>
</div>
<div class="am-form-group am-form-group-refreshing am-margin-top-lg am-padding-left-0">
<button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm am-btn-block" data-am-loading="{loadingText:'处理中...'}">保存</button>
<a href="{{:MyUrl('index/agreement/index', ['document'=>'userlogout'])}}" target="_blank">
<button type="button" class="am-btn am-btn-default am-btn-xs am-btn-block am-margin-top-sm">查看详情</button>
</a>
</div>
</form>
<!-- form end -->
</div>
</div>
<!-- right content end -->
<!-- footer start -->
{{include file="public/footer" /}}
<!-- footer end -->

View File

@ -0,0 +1,55 @@
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2099 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( https://opensource.org/licenses/mit-license.php )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\api\controller;
use app\service\ApiService;
use app\service\SafetyService;
/**
* 安全
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-03-02T22:48:35+0800
*/
class Safety extends Common
{
/**
* 构造方法
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-03T12:39:08+0800
*/
public function __construct()
{
// 调用父类前置方法
parent::__construct();
// 是否登录
$this->IsLogin();
}
/**
* 账号注销
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-03-28T17:04:36+0800
*/
public function Logout()
{
$params = $this->data_post;
$params['user'] = $this->user;
return ApiService::ApiDataReturn(SafetyService::AccountsLogout($params));
}
}
?>

View File

@ -14,6 +14,7 @@ use app\service\ApiService;
use app\service\SeoService;
use app\service\SafetyService;
use app\service\NavigationService;
use app\service\AgreementService;
/**
* 安全
@ -155,6 +156,29 @@ class Safety extends Common
return MyView();
}
/**
* 账号注销页面
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-03-28T10:12:20+0800
*/
public function LogoutInfo()
{
// 协议
$document = AgreementService::AgreementData(['document'=>'userlogout']);
// 模板数据
$assign = [
// 协议内容
'document_data' => $document['data'],
// 浏览器名称
'home_seo_site_title' => SeoService::BrowserSeoTitle('账号注销 - 安全设置', 1),
];
MyViewAssign($assign);
return MyView();
}
/**
* 验证码显示
* @author Devil
@ -218,7 +242,7 @@ class Safety extends Common
}
/**
* 更新
* 更新
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
@ -230,5 +254,19 @@ class Safety extends Common
$params['user'] = $this->user;
return ApiService::ApiDataReturn(SafetyService::AccountsUpdate($params));
}
/**
* 账号注销
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2017-03-28T17:04:36+0800
*/
public function Logout()
{
$params = $this->data_post;
$params['user'] = $this->user;
return ApiService::ApiDataReturn(SafetyService::AccountsLogout($params));
}
}
?>

View File

@ -25,8 +25,8 @@
<!-- form start -->
<form class="am-form form-validation" action="{{:MyUrl('index/safety/verifycheck')}}" method="POST" request-type="ajax-url" request-value="{{:MyUrl('index/safety/newemailinfo')}}">
<legend>
<span class="legend-title">原电子邮箱校验</span>
<a href="{{:MyUrl('index/safety/index')}}" class="am-fr am-margin-top-sm am-icon-mail-reply"> 返回</a>
<span class="am-text-default">原电子邮箱校验</span>
<a href="{{:MyUrl('index/safety/index')}}" class="am-fr am-text-xs am-margin-top-sm am-icon-mail-reply"> 返回</a>
</legend>
<div class="am-form-group">
<label>电子邮箱</label>

View File

@ -23,7 +23,7 @@
<div class="user-content">
<div class="user-content-body">
{{foreach $safety_panel_list as $v}}
<section class="am-panel am-panel-default am-radius am-panel-{{if empty($data[$v['type']]) and empty($v['msg'])}}danger{{else /}}default{{/if}}">
<section class="am-panel am-panel-default am-radius am-panel-{{if (empty($data[$v['type']]) and empty($v['msg'])) or ($v['type'] eq 'logout')}}danger{{else /}}default{{/if}}">
<header class="am-panel-hd">
<h3 class="am-panel-title">{{$v.title}}</h3>
</header>
@ -33,9 +33,11 @@
<span>{{$v.msg}}</span>
{{/if}}
{{if empty($data[$v['type']]) and !empty($v['tips'])}}
{{$v.no_msg}}
{{if !empty($v['no_msg'])}}
{{$v.no_msg}}
{{/if}}
{{else /}}
{{if !empty($data[$v['type']])}}
{{if !empty($v['ok_msg']) and !empty($data[$v['type']])}}
{{:str_replace('#accounts#', $data[$v['type']], $v['ok_msg'])}}
{{/if}}
{{/if}}
@ -43,11 +45,7 @@
<p class="am-text-xs am-margin-bottom-xs">{{$v.tips}}</p>
{{/if}}
</div>
{{if empty($data[$v['type']]) and empty($v['msg'])}}
<a href="{{$v.url}}" class="am-btn am-btn-danger am-radius am-btn-xs am-fr">绑定</a>
{{else /}}
<a href="{{$v.url}}" class="am-btn am-btn-secondary am-radius am-btn-xs am-fr">修改</a>
{{/if}}
<a href="{{$v.url}}" class="am-btn am-btn-secondary am-radius am-btn-xs am-fr">{{if empty($v['submit_text'])}}{{if empty($data[$v['type']]) and empty($v['msg'])}}绑定{{else /}}修改{{/if}}{{else /}}{{$v.submit_text}}{{/if}}</a>
</div>
</section>
{{/foreach}}

View File

@ -25,8 +25,8 @@
<!-- form start -->
<form class="am-form form-validation" action="{{:MyUrl('index/safety/loginpwdupdate')}}" method="POST" request-type="ajax-url" request-value="{{:MyUrl('index/safety/index')}}">
<legend>
<span class="legend-title">登录密码修改</span>
<a href="{{:MyUrl('index/safety/index')}}" class="am-fr am-margin-top-sm am-icon-mail-reply"> 返回</a>
<span class="am-text-default">登录密码修改</span>
<a href="{{:MyUrl('index/safety/index')}}" class="am-fr am-text-xs am-margin-top-sm am-icon-mail-reply"> 返回</a>
</legend>
<div class="am-form-group">
<label>当前密码</label>

View File

@ -0,0 +1,51 @@
{{include file="public/header" /}}
<!-- header top nav -->
{{include file="public/header_top_nav" /}}
<!-- search -->
{{include file="public/nav_search" /}}
<!-- header nav -->
{{include file="public/header_nav" /}}
<!-- goods category -->
{{include file="public/goods_category" /}}
<!-- content -->
<div class="am-container user-main">
<!-- user menu start -->
{{include file="public/user_menu" /}}
<!-- user menu end -->
<!-- content start -->
<div class="user-content">
<div class="user-content-body">
<legend>
<span class="am-text-default">账号注销</span>
<a href="{{:MyUrl('index/safety/index')}}" class="am-fr am-text-xs am-margin-top-sm am-icon-mail-reply"> 返回</a>
</legend>
<div class="am-text-center am-margin-top-lg">
<p class="am-text-sm">{{$document_data.name}}</p>
<p class="am-text-grey">{{$document_data.upd_time_time}}</p>
</div>
<div class="am-panel am-panel-default am-scrollable-vertical am-margin-top am-radius document-content">
<div class="am-panel-bd">{{$document_data.value|raw}}</div>
</div>
<div class="am-text-center am-margin-vertical-lg">
<button type="submit" class="am-btn am-btn-default am-radius am-btn-xs am-margin-right-lg submit-ajax" data-url="{{:MyUrl('index/safety/logout')}}" data-view="jump" data-value="{{$home_url}}" data-msg="账号注销后不可恢复、确定继续吗?">确认注销</button>
<a href="{{:MyUrl('index/safety/index')}}" class="am-btn am-btn-primary am-radius am-btn-xs am-margin-left-lg">取消</a>
</div>
</div>
</div>
<!-- content end -->
</div>
<!-- footer start -->
{{include file="public/footer" /}}
<!-- footer end -->
<!-- footer end -->

View File

@ -25,8 +25,8 @@
<!-- form start -->
<form class="am-form form-validation" action="{{:MyUrl('index/safety/verifycheck')}}" method="POST" request-type="ajax-url" request-value="{{:MyUrl('index/safety/newmobileinfo')}}">
<legend>
<span class="legend-title">原手机号码校验</span>
<a href="{{:MyUrl('index/safety/index')}}" class="am-fr am-margin-top-sm am-icon-mail-reply"> 返回</a>
<span class="am-text-default">原手机号码校验</span>
<a href="{{:MyUrl('index/safety/index')}}" class="am-fr am-text-xs am-margin-top-sm am-icon-mail-reply"> 返回</a>
</legend>
<div class="am-form-group">
<label>手机号码</label>

View File

@ -25,8 +25,8 @@
<!-- form start -->
<form class="am-form form-validation" action="{{:MyUrl('index/safety/accountsupdate')}}" method="POST" request-type="ajax-url" request-value="{{:MyUrl('index/safety/index')}}">
<legend>
<span class="legend-title">新电子邮箱校验</span>
<a href="{{:MyUrl('index/safety/index')}}" class="am-fr am-margin-top-sm am-icon-mail-reply"> 返回</a>
<span class="am-text-default">新电子邮箱校验</span>
<a href="{{:MyUrl('index/safety/index')}}" class="am-fr am-text-xs am-margin-top-sm am-icon-mail-reply"> 返回</a>
</legend>
<div class="am-form-group">
<label>电子邮箱</label>

View File

@ -25,8 +25,8 @@
<!-- form start -->
<form class="am-form form-validation" action="{{:MyUrl('index/safety/accountsupdate')}}" method="POST" request-type="ajax-url" request-value="{{:MyUrl('index/safety/index')}}">
<legend>
<span class="legend-title">新手机号码校验</span>
<a href="{{:MyUrl('index/safety/index')}}" class="am-fr am-margin-top-sm am-icon-mail-reply"> 返回</a>
<span class="am-text-default">新手机号码校验</span>
<a href="{{:MyUrl('index/safety/index')}}" class="am-fr am-text-xs am-margin-top-sm am-icon-mail-reply"> 返回</a>
</legend>
<div class="am-form-group">
<label>手机号码</label>

View File

@ -119,6 +119,8 @@ return [
'loading_success' => '加载成功',
'request_fail' => '请求失败',
'request_success' => '请求成功',
'logout_fail' => '注销失败',
'logout_success' => '注销成功',
'no_data' => '没有相关数据',
],
];

View File

@ -27,12 +27,14 @@ class ConfigService
public static $not_cache_field_list = [
'common_agreement_userregister',
'common_agreement_userprivacy',
'common_agreement_userlogout',
];
// 富文本,不实例化的字段
public static $rich_text_list = [
'common_agreement_userregister',
'common_agreement_userprivacy',
'common_agreement_userlogout',
'common_email_currency_template',
'home_footer_info',
'home_email_user_reg',

View File

@ -800,26 +800,33 @@ class NavigationService
{
$data = [
[
'title' => '登录密码',
'msg' => '互联网存在被盗风险,建议您定期更改密码以保护安全。',
'url' => MyUrl('index/safety/loginpwdinfo'),
'type' => 'loginpwd',
'title' => '登录密码',
'msg' => '互联网存在被盗风险,建议您定期更改密码以保护安全。',
'url' => MyUrl('index/safety/loginpwdinfo'),
'type' => 'loginpwd',
],
[
'title' => '手机号码',
'no_msg' => '您还没有绑定手机号码',
'ok_msg' => '已绑定手机 #accounts#',
'tips' => '可用于登录,密码找回,账户安全管理校验,接受账户提醒通知。',
'url' => MyUrl('index/safety/mobileinfo'),
'type' => 'mobile',
'title' => '手机号码',
'no_msg' => '您还没有绑定手机号码',
'ok_msg' => '已绑定手机 #accounts#',
'tips' => '可用于登录,密码找回,账户安全管理校验,接受账户提醒通知。',
'url' => MyUrl('index/safety/mobileinfo'),
'type' => 'mobile',
],
[
'title' => '电子邮箱',
'no_msg' => '您还没有绑定电子邮箱',
'ok_msg' => '已绑定电子邮箱 #accounts#',
'tips' => '可用于登录,密码找回,账户安全管理校验,接受账户提醒邮件。',
'url' => MyUrl('index/safety/emailinfo'),
'type' => 'email',
'title' => '电子邮箱',
'no_msg' => '您还没有绑定电子邮箱',
'ok_msg' => '已绑定电子邮箱 #accounts#',
'tips' => '可用于登录,密码找回,账户安全管理校验,接受账户提醒邮件。',
'url' => MyUrl('index/safety/emailinfo'),
'type' => 'email',
],
[
'title' => '账号注销',
'tips' => '不可存在未完成的订单',
'url' => MyUrl('index/safety/logoutinfo'),
'type' => 'logout',
'submit_text' => '注销',
],
];
@ -937,7 +944,7 @@ class NavigationService
[
'name' => '安全设置',
'url' => MyUrl('index/safety/index'),
'contains' => ['indexsafetyindex', 'indexsafetyloginpwdinfo', 'indexsafetymobileinfo', 'indexsafetynewmobileinfo', 'indexsafetyemailinfo', 'indexsafetynewemailinfo'],
'contains' => ['indexsafetyindex', 'indexsafetyloginpwdinfo', 'indexsafetymobileinfo', 'indexsafetynewmobileinfo', 'indexsafetyemailinfo', 'indexsafetynewemailinfo', 'indexsafetylogoutinfo'],
'is_show' => 1,
'icon' => 'am-icon-user-secret',
'is_system' => 1,

View File

@ -349,7 +349,7 @@ class SafetyService
}
/**
* 更新
* 更新
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
@ -455,5 +455,55 @@ class SafetyService
}
return DataReturn(MyLang('common.operate_fail'), -100);
}
/**
* 账号注销
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2022-11-20
* @desc description
* @param [array] $params [输入参数]
*/
public static function AccountsLogout($params = [])
{
// 数据验证
$p = [
[
'checked_type' => 'empty',
'key_name' => 'user',
'error_msg' => '用户信息有误',
],
];
$ret = ParamsChecked($params, $p);
if($ret !== true)
{
return DataReturn($ret, -1);
}
// 是否还有未完成的订单
$where = [
['user_id', '=', $params['user']['id']],
['status', '<=', 3]
];
$count = Db::name('Order')->where($where)->count();
if($count > 0)
{
return DataReturn('存在'.$count.'个订单未完成', -1);
}
// 账号注销
$data = [
'status' => 2,
'is_logout_time' => time(),
'upd_time' => time(),
];
if(Db::name('User')->where(['id'=>$params['user']['id']])->update($data))
{
UserService::Logout();
return DataReturn(MyLang('common.logout_success'), 0);
}
return DataReturn(MyLang('common.logout_fail'), -1);
}
}
?>

View File

@ -45,9 +45,10 @@ class SystemBaseService
'common_site_type' => self::SiteTypeValue(),
'common_shop_notice' => MyC('common_shop_notice', null, true),
// 协议、注册协议、隐私协议
// 协议、注册协议、隐私协议、注销协议
'agreement_userregister_url' => MyUrl('index/agreement/index', ['document'=>'userregister', 'is_content'=>1]),
'agreement_userprivacy_url' => MyUrl('index/agreement/index', ['document'=>'userprivacy', 'is_content'=>1]),
'agreement_userlogout_url' => MyUrl('index/agreement/index', ['document'=>'userlogout', 'is_content'=>1]),
// 手机端相关配置
'common_app_is_enable_search' => (int) MyC('common_app_is_enable_search', 1),

View File

@ -2202,11 +2202,12 @@ class UserService
{
return '';
}
$where = [
['system_type', '=', SystemService::SystemTypeValue()],
[$where_field, '=', $where_value],
['is_delete_time', '=', 0],
['is_logout_time', '=', 0],
];
return Db::name('User')->where($where)->field($field)->find();
}
@ -2444,13 +2445,13 @@ class UserService
// 手机号码格式
if(!CheckMobile($params['mobile']))
{
return DataReturn('手机号码格式错误', -2);
return DataReturn('手机号码格式错误', -2);
}
// 验证码校验
$verify_params = [
'key_prefix' => 'user_bind_'.md5($params['mobile']),
'expire_time' => MyC('common_verify_expire_time')
'key_prefix' => 'user_bind_'.md5($params['mobile']),
'expire_time' => MyC('common_verify_expire_time')
];
$obj = new \base\Sms($verify_params);

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 856 B

View File

@ -1012,6 +1012,7 @@ legend .legend-title {
legend a.am-fr {
color: #e7747f;
margin-top: 10px;
text-decoration: none;
}
.items-value-empty {
color: #999;

View File

@ -13,14 +13,9 @@
.user-content-body #verify-win .am-modal-bd .base .verify-tips { font-size: 12px; }
.user-content-body #verify-img { vertical-align: middle; border: 1px solid #ccc; }
.user-content-body legend {
padding-bottom: 0.2rem;
margin-bottom: 1rem;
border-bottom: 1px solid #e5e5e5;
}
.user-content-body .legend-title {
font-size: 16px;
}
.user-content-body a {
color: #e7747f;
/**
* 协议内容
*/
.user-content-body .document-content {
height: 350px;
}