feat(invite): 规则说明弹窗改为动态内容,从后端配置读取

- 新增invite_rule业务配置项
- ISystemService/SystemService新增GetInviteRuleAsync方法
- SystemController新增getInviteRule接口
- 前端规则说明弹窗改为纯文本展示,匹配设计图样式
This commit is contained in:
zpc 2026-03-25 10:06:27 +08:00
parent 6e19d3c821
commit c4a3d5d5a2
5 changed files with 80 additions and 31 deletions

View File

@ -141,13 +141,6 @@ public class SystemController : ControllerBase
/// <summary> /// <summary>
/// 获取小程序信息 /// 获取小程序信息
/// </summary> /// </summary>
/// <remarks>
/// GET /api/system/getMiniappInfo
///
/// 从配置表读取小程序名称和简介
/// 不需要用户登录认证
/// </remarks>
/// <returns>小程序名称和简介</returns>
[HttpGet("getMiniappInfo")] [HttpGet("getMiniappInfo")]
[ProducesResponseType(typeof(ApiResponse<MiniappInfoDto>), StatusCodes.Status200OK)] [ProducesResponseType(typeof(ApiResponse<MiniappInfoDto>), StatusCodes.Status200OK)]
public async Task<ApiResponse<MiniappInfoDto>> GetMiniappInfo() public async Task<ApiResponse<MiniappInfoDto>> GetMiniappInfo()
@ -163,4 +156,29 @@ public class SystemController : ControllerBase
return ApiResponse<MiniappInfoDto>.Fail("获取小程序信息失败"); return ApiResponse<MiniappInfoDto>.Fail("获取小程序信息失败");
} }
} }
/// <summary>
/// 获取邀请规则说明
/// </summary>
/// <remarks>
/// GET /api/system/getInviteRule
///
/// 从配置表读取邀请规则说明内容
/// 不需要用户登录认证
/// </remarks>
/// <returns>邀请规则说明内容</returns>
[HttpGet("getInviteRule")]
public async Task<ApiResponse<string>> GetInviteRule()
{
try
{
var content = await _systemService.GetInviteRuleAsync();
return ApiResponse<string>.Success(content);
}
catch (Exception ex)
{
_logger.LogError(ex, "Failed to get invite rule");
return ApiResponse<string>.Fail("获取邀请规则失败");
}
}
} }

View File

@ -51,4 +51,13 @@ public interface ISystemService
/// </remarks> /// </remarks>
/// <returns>小程序信息数据</returns> /// <returns>小程序信息数据</returns>
Task<MiniappInfoDto> GetMiniappInfoAsync(); Task<MiniappInfoDto> GetMiniappInfoAsync();
/// <summary>
/// 获取邀请规则说明
/// </summary>
/// <remarks>
/// 从配置表读取邀请规则说明内容config_key: invite_rule
/// </remarks>
/// <returns>邀请规则说明内容</returns>
Task<string> GetInviteRuleAsync();
} }

View File

@ -20,6 +20,7 @@ public class SystemService : ISystemService
private const string ServiceQrcodeKey = "service_qrcode"; private const string ServiceQrcodeKey = "service_qrcode";
private const string MiniappNameKey = "miniapp_name"; private const string MiniappNameKey = "miniapp_name";
private const string MiniappIntroKey = "miniapp_intro"; private const string MiniappIntroKey = "miniapp_intro";
private const string InviteRuleKey = "invite_rule";
// 默认版本号 // 默认版本号
private const string DefaultVersion = "1.0.0"; private const string DefaultVersion = "1.0.0";
@ -127,4 +128,15 @@ public class SystemService : ISystemService
Intro = intro ?? string.Empty Intro = intro ?? string.Empty
}; };
} }
/// <inheritdoc />
public async Task<string> GetInviteRuleAsync()
{
_logger.LogDebug("获取邀请规则说明");
var content = await _configService.GetConfigValueAsync(InviteRuleKey);
return content ?? string.Empty;
}
} }

View File

@ -44,10 +44,19 @@ export function getMiniappInfo() {
return get('/system/getMiniappInfo') return get('/system/getMiniappInfo')
} }
/**
* 获取邀请规则说明
* @returns {Promise<Object>}
*/
export function getInviteRule() {
return get('/system/getInviteRule')
}
export default { export default {
getAgreement, getAgreement,
getPrivacy, getPrivacy,
getAbout, getAbout,
getContactInfo, getContactInfo,
getMiniappInfo getMiniappInfo,
getInviteRule
} }

View File

@ -16,7 +16,7 @@ import {
applyWithdraw, applyWithdraw,
getWithdrawList getWithdrawList
} from '@/api/invite.js' } from '@/api/invite.js'
import { getMiniappInfo } from '@/api/system.js' import { getMiniappInfo, getInviteRule } from '@/api/system.js'
import Empty from '@/components/Empty/index.vue' import Empty from '@/components/Empty/index.vue'
import Loading from '@/components/Loading/index.vue' import Loading from '@/components/Loading/index.vue'
@ -64,6 +64,9 @@ const qrcodeLoading = ref(false)
const miniappName = ref('') const miniappName = ref('')
const miniappIntro = ref('') const miniappIntro = ref('')
//
const ruleContent = ref('')
// //
const withdrawAmount = ref('') const withdrawAmount = ref('')
const withdrawLoading = ref(false) const withdrawLoading = ref(false)
@ -150,6 +153,20 @@ async function loadMiniappInfo() {
} }
} }
/**
* 加载邀请规则说明
*/
async function loadInviteRule() {
try {
const res = await getInviteRule()
if (res.code === 0 && res.data) {
ruleContent.value = res.data
}
} catch (error) {
console.error('获取邀请规则失败:', error)
}
}
/** /**
* 加载邀请记录列表 * 加载邀请记录列表
*/ */
@ -361,6 +378,7 @@ onShow(() => {
loadRecordList(true) loadRecordList(true)
loadMiniappInfo() loadMiniappInfo()
loadQrcodeUrl() loadQrcodeUrl()
loadInviteRule()
}) })
onMounted(() => { userStore.restoreFromStorage() }) onMounted(() => { userStore.restoreFromStorage() })
@ -463,16 +481,7 @@ onMounted(() => { userStore.restoreFromStorage() })
</view> </view>
<scroll-view class="popup-body" scroll-y> <scroll-view class="popup-body" scroll-y>
<view class="rule-content"> <view class="rule-content">
<view class="rule-item" v-for="(rule, idx) in [ <text class="rule-text">{{ ruleContent || '暂无规则说明' }}</text>
'合伙人及以上用户可通过专属链接或二维码邀请新用户注册。',
'被邀请用户通过您的链接注册后,将自动绑定为您的下级用户。',
'下级用户在小程序内成功支付后您可获得每笔订单40%的佣金。',
'若您有上级用户每笔订单您获得30%佣金您的上级获得10%佣金。',
'佣金可申请提现最低提现金额为1元仅支持整数金额。',
'提现申请提交后将在1-3个工作日内处理。'
]" :key="idx">
<text class="rule-text">{{ idx + 1 }}. {{ rule }}</text>
</view>
</view> </view>
</scroll-view> </scroll-view>
</view> </view>
@ -908,18 +917,10 @@ onMounted(() => { userStore.restoreFromStorage() })
} }
.rule-content { .rule-content {
.rule-item { .rule-text {
margin-bottom: $spacing-md; font-size: $font-size-md;
color: $text-color;
&:last-child { line-height: 1.8;
margin-bottom: 0;
}
.rule-text {
font-size: $font-size-md;
color: $text-color;
line-height: 1.6;
}
} }
} }
} }