feat(mobile-app): change share QR code to APK download link with referral code
QR code now contains: https://s3.szaiai.com/rwadurian/app-release.apk?ref={referralCode} - User scans QR to download APK directly - Guide page 5 already supports parsing ref parameter from URL 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
5a5e360e73
commit
cb9e520fb4
|
|
@ -38,7 +38,10 @@ class _SharePageState extends ConsumerState<SharePage> {
|
|||
_loadShareLink();
|
||||
}
|
||||
|
||||
/// 加载分享链接 (调用 API 生成短链)
|
||||
/// APK 下载基础链接
|
||||
static const String _apkDownloadUrl = 'https://s3.szaiai.com/rwadurian/app-release.apk';
|
||||
|
||||
/// 加载分享链接 (使用 APK 下载链接 + 推荐码)
|
||||
Future<void> _loadShareLink() async {
|
||||
try {
|
||||
setState(() {
|
||||
|
|
@ -48,15 +51,14 @@ class _SharePageState extends ConsumerState<SharePage> {
|
|||
|
||||
final referralService = ref.read(referralServiceProvider);
|
||||
|
||||
// 调用 API 生成短链
|
||||
// 调用 API 获取推荐码
|
||||
final linkResponse = await referralService.generateReferralLink();
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
// 优先使用短链,如果没有则使用完整链接
|
||||
_displayLink = linkResponse.shortUrl.isNotEmpty
|
||||
? linkResponse.shortUrl
|
||||
: linkResponse.fullUrl;
|
||||
// 使用 APK 下载链接 + 推荐码参数
|
||||
final referralCode = linkResponse.referralCode;
|
||||
_displayLink = '$_apkDownloadUrl?ref=$referralCode';
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
|
|
@ -65,9 +67,13 @@ class _SharePageState extends ConsumerState<SharePage> {
|
|||
if (mounted) {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
// 失败时使用传入的默认链接
|
||||
_displayLink = widget.shareLink;
|
||||
_errorMessage = '加载短链失败,使用默认链接';
|
||||
// 失败时使用传入的推荐码构造链接
|
||||
if (widget.referralCode != null && widget.referralCode!.isNotEmpty) {
|
||||
_displayLink = '$_apkDownloadUrl?ref=${widget.referralCode}';
|
||||
} else {
|
||||
_displayLink = _apkDownloadUrl;
|
||||
}
|
||||
_errorMessage = '加载失败,使用默认链接';
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue