feat: 新增服务号注册授权页面并优化注册提示信息
This commit is contained in:
@@ -179,6 +179,7 @@ public class FuwuhaoService : ApplicationService
|
||||
{
|
||||
throw new ApplicationException("获取用户id异常,请重试");
|
||||
}
|
||||
|
||||
var loginInfo = await _accountService.PostLoginAsync(cache.UserId!.Value);
|
||||
output.Token = loginInfo.Token;
|
||||
output.RefreshToken = loginInfo.RefreshToken;
|
||||
@@ -194,19 +195,35 @@ public class FuwuhaoService : ApplicationService
|
||||
/// <param name="code"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("fuwuhao/register")]
|
||||
public async Task<string> RegisterByCodeAsync([FromQuery] string code)
|
||||
public async Task<IActionResult> RegisterByCodeAsync([FromQuery] string code)
|
||||
{
|
||||
var message = await RegisterByCodeForMessageAsync(code);
|
||||
//var message = "恭喜注册";
|
||||
var filePath = Path.Combine("wwwroot", "aihub", "auth.html");
|
||||
var html = await File.ReadAllTextAsync(filePath);
|
||||
var result = new ContentResult
|
||||
{
|
||||
Content = html.Replace("{{message}}", message),
|
||||
ContentType = "text/html",
|
||||
StatusCode = 200
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private async Task<string> RegisterByCodeForMessageAsync(string code)
|
||||
{
|
||||
//根据code获取到openid、微信用户昵称、头像
|
||||
var userInfo = await _fuwuhaoManager.GetUserInfoByCodeAsync(code);
|
||||
if (userInfo is null)
|
||||
{
|
||||
return "当前注册已经失效,请重新扫码注册";
|
||||
return "当前注册已经失效,请重新扫码注册!";
|
||||
}
|
||||
|
||||
var scene = await _openIdToSceneCache.GetAsync($"{FuwuhaoConst.OpenIdToSceneCacheKey}{userInfo.OpenId}");
|
||||
if (scene is null)
|
||||
{
|
||||
return "当前注册已经过期,请重新扫码注册";
|
||||
return "当前注册已经过期,请重新扫码注册!";
|
||||
}
|
||||
|
||||
var files = new FormFileCollection();
|
||||
@@ -230,15 +247,18 @@ public class FuwuhaoService : ApplicationService
|
||||
var result = await _fileService.Post(files);
|
||||
|
||||
//由于存在查询/编辑在同一个事务操作,上锁防止并发
|
||||
await using (await DistributedLock.AcquireLockAsync($"fuwuhao:RegisterLock:{userInfo.OpenId}", TimeSpan.FromMinutes(1)))
|
||||
await using (await DistributedLock.AcquireLockAsync($"fuwuhao:RegisterLock:{userInfo.OpenId}",
|
||||
TimeSpan.FromMinutes(1)))
|
||||
{
|
||||
if (await _userRepository.IsAnyAsync(x => x.FuwuhaoOpenId == userInfo.OpenId))
|
||||
{
|
||||
throw new UserFriendlyException("你已注册过意社区账号");
|
||||
return "你已注册过意社区账号!";
|
||||
}
|
||||
|
||||
|
||||
var userId = await _accountService.PostSystemRegisterAsync(new RegisterDto
|
||||
Guid userId;
|
||||
try
|
||||
{
|
||||
userId = await _accountService.PostSystemRegisterAsync(new RegisterDto
|
||||
{
|
||||
UserName = $"wx{Random.Shared.Next(100000, 999999)}",
|
||||
Password = Guid.NewGuid().ToString("N"),
|
||||
@@ -247,6 +267,12 @@ public class FuwuhaoService : ApplicationService
|
||||
Nick = userInfo.Nickname,
|
||||
Icon = result.FirstOrDefault()?.Id.ToString()
|
||||
});
|
||||
}
|
||||
catch (UserFriendlyException e)
|
||||
{
|
||||
return e.Message;
|
||||
}
|
||||
|
||||
|
||||
await _userRepository.InsertAsync(new AiUserExtraInfoEntity(userId, userInfo.OpenId));
|
||||
await _sceneCache.SetAsync($"{FuwuhaoConst.SceneCacheKey}{scene}", new SceneCacheDto
|
||||
@@ -257,7 +283,7 @@ public class FuwuhaoService : ApplicationService
|
||||
new DistributedCacheEntryOptions() { AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(120) });
|
||||
}
|
||||
|
||||
return "恭喜你已注册成功意社区账号!";
|
||||
return "恭喜你成功注册意社区账号!";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -313,7 +313,7 @@ namespace Yi.Framework.Rbac.Domain.Managers
|
||||
{
|
||||
if (handle is null)
|
||||
{
|
||||
throw new UserFriendlyException($"{userName}用户正在注册中,请稍等");
|
||||
throw new UserFriendlyException($"{userName}用户正在注册中,请稍等。。。");
|
||||
}
|
||||
|
||||
var userUpName = userName.ToUpper();
|
||||
|
||||
@@ -57,6 +57,9 @@
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Remove="logs\**" />
|
||||
<Content Update="wwwroot\aihub\auth.html">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
282
Yi.Abp.Net8/src/Yi.Abp.Web/wwwroot/aihub/auth.html
Normal file
282
Yi.Abp.Net8/src/Yi.Abp.Web/wwwroot/aihub/auth.html
Normal file
@@ -0,0 +1,282 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>意社区授权页</title>
|
||||
<style>
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||
background: linear-gradient(135deg, rgb(10, 10, 10) 0%, rgb(13, 21, 32) 30%, rgb(10, 10, 10) 70%, rgb(15, 21, 32) 100%),
|
||||
linear-gradient(135deg, rgba(0, 255, 136, 0.03) 0%, rgba(0, 0, 0, 0.8) 50%, rgba(0, 255, 136, 0.02) 100%);
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* 页头 */
|
||||
.header {
|
||||
background: rgba(10, 10, 10, 0.9);
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
border-bottom: 1px solid rgba(0, 255, 136, 0.2);
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
color: #ffffff;
|
||||
font-size: 28px;
|
||||
line-height: 30px;
|
||||
}
|
||||
|
||||
/* 主要内容区域 */
|
||||
.main-content {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 40px 20px;
|
||||
}
|
||||
|
||||
.auth-container {
|
||||
max-width: 600px;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* 大标题 */
|
||||
.main-title {
|
||||
color: #ffffff;
|
||||
font-size: 68px;
|
||||
line-height: 74px;
|
||||
margin-bottom: 30px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* 授权结果卡片 */
|
||||
.auth-result-card {
|
||||
padding: 20px;
|
||||
background-color: #04080B;
|
||||
border-radius: 0px;
|
||||
box-shadow: none;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-self: stretch;
|
||||
border: 1px solid rgba(0, 255, 136, 0.2);
|
||||
margin-bottom: 40px;
|
||||
transition: border-color 0.3s ease;
|
||||
}
|
||||
|
||||
.auth-result-card:hover {
|
||||
border-color: rgba(0, 255, 136, 0.4);
|
||||
}
|
||||
|
||||
.success-icon {
|
||||
font-size: 60px;
|
||||
color: #00ff88;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.auth-message {
|
||||
color: #ffffff;
|
||||
font-size: 28px;
|
||||
line-height: 30px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.auth-description {
|
||||
color: #a0a0a0;
|
||||
line-height: 22px;
|
||||
font-size: 16px;
|
||||
font-weight: 400;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.highlight-text {
|
||||
color: #00ff88;
|
||||
}
|
||||
|
||||
/* 按钮样式 */
|
||||
.btn {
|
||||
font-weight: 600;
|
||||
border: none;
|
||||
padding: 14px 28px;
|
||||
font-size: 1rem;
|
||||
line-height: 1.5rem;
|
||||
border-radius: 0px;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
margin: 10px;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
color: #000;
|
||||
background: #00D36E;
|
||||
animation: pulse 2s infinite;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
box-shadow: 0 10px 25px rgba(0, 255, 136, 0.3);
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
color: #ffffff;
|
||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
border-color: rgba(255, 255, 255, 0.3);
|
||||
}
|
||||
|
||||
/* 脉冲动画 */
|
||||
@keyframes pulse {
|
||||
0% {
|
||||
transform: scale(1);
|
||||
}
|
||||
50% {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
100% {
|
||||
transform: scale(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* 链接样式 */
|
||||
.link {
|
||||
color: #00ff88;
|
||||
text-decoration: none;
|
||||
border-bottom: 1px solid transparent;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.link:hover {
|
||||
color: #ffffff;
|
||||
border-bottom-color: #00ff88;
|
||||
}
|
||||
|
||||
/* 备注内容 */
|
||||
.note {
|
||||
color: #666;
|
||||
font-size: 12px;
|
||||
line-height: 18px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
/* 页脚 */
|
||||
.footer {
|
||||
background: rgba(10, 10, 10, 0.9);
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
border-top: 1px solid rgba(0, 255, 136, 0.2);
|
||||
}
|
||||
|
||||
.footer p {
|
||||
color: #a0a0a0;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
/* 响应式设计 */
|
||||
@media (max-width: 768px) {
|
||||
.main-title {
|
||||
font-size: 48px;
|
||||
line-height: 54px;
|
||||
}
|
||||
|
||||
.auth-message {
|
||||
font-size: 24px;
|
||||
line-height: 28px;
|
||||
}
|
||||
|
||||
.main-content {
|
||||
padding: 20px 15px;
|
||||
}
|
||||
|
||||
.auth-result-card {
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 12px 24px;
|
||||
font-size: 0.9rem;
|
||||
margin: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.main-title {
|
||||
font-size: 36px;
|
||||
line-height: 42px;
|
||||
}
|
||||
|
||||
.auth-message {
|
||||
font-size: 20px;
|
||||
line-height: 24px;
|
||||
}
|
||||
|
||||
.success-icon {
|
||||
font-size: 40px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
width: 100%;
|
||||
margin: 5px 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<!-- 页头 -->
|
||||
<header class="header">
|
||||
<h1>SharpDance-意社区</h1>
|
||||
</header>
|
||||
|
||||
<!-- 主要内容 -->
|
||||
<main class="main-content">
|
||||
<div class="auth-container">
|
||||
<h1 class="main-title">授权页</h1>
|
||||
|
||||
<div class="auth-result-card">
|
||||
<div class="success-icon">✓</div>
|
||||
<h2 class="auth-message"><span class="highlight-text">{{message}}</span></h2>
|
||||
<p class="auth-description">
|
||||
您已经完成我们的授权全部流程<br/>现在可返回扫码页面继续操作
|
||||
</p>
|
||||
|
||||
<div class="button-group">
|
||||
<a href="https://ccnetcore.com" class="btn btn-primary">进入意社区</a>
|
||||
<a href="https://sharpdance.cn" class="btn btn-secondary">了解SharpDance</a>
|
||||
</div>
|
||||
|
||||
<div class="note">
|
||||
<p>如有任何问题,请联系 <a href="#" class="link">wx:chengzilaoge520</a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="additional-info">
|
||||
<p class="auth-description">
|
||||
您的账号已受意社区账号体系全面保护。现在您可以享受SharpDance产品矩阵提供的所有功能和服务。
|
||||
</p>
|
||||
<!-- <p class="auth-description">
|
||||
|
||||
感谢您加入意社区!构建智能未来的开发者社区。
|
||||
</p> -->
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<!-- 页脚 -->
|
||||
<footer class="footer">
|
||||
<p>© 2025 意社区. 保留所有权利.</p>
|
||||
<p><a href="#" class="link">隐私政策</a> | <a href="#" class="link">服务条款</a> | <a href="#" class="link">帮助中心</a></p>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user