120 lines
3.9 KiB
Dart
120 lines
3.9 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_native_splash/flutter_native_splash.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:getx_scaffold/common/components/index.dart';
|
|
import 'package:getx_scaffold/common/widgets/rich_text_x.dart';
|
|
import 'package:ln_jq_app/pages/home/view.dart';
|
|
import 'package:ln_jq_app/pages/login/view.dart';
|
|
import 'package:ln_jq_app/storage_service.dart';
|
|
|
|
import '../common/webview/view.dart';
|
|
|
|
class WelcomeController extends GetxController {
|
|
@override
|
|
void onReady() {
|
|
super.onReady();
|
|
// 移除原生闪屏页(如果有的话)
|
|
FlutterNativeSplash.remove();
|
|
|
|
if (Platform.isAndroid) {
|
|
if (StorageService.to.isPrivacyAgreed) {
|
|
_startTimer();
|
|
} else {
|
|
showPrivacyDialog();
|
|
}
|
|
} else if (Platform.isIOS) {
|
|
_startTimer();
|
|
}
|
|
}
|
|
|
|
void showPrivacyDialog() {
|
|
DialogX.to.showConfirmDialog(
|
|
title: "个人信息保护提示",
|
|
content: _buildDialogContent(),
|
|
confirmText: '同意',
|
|
cancelText: '不同意',
|
|
onConfirm: () async {
|
|
await StorageService.to.savePrivacyAgreed(true);
|
|
Get.offAll(() => const HomePage());
|
|
},
|
|
onCancel: () {
|
|
DialogX.to.showConfirmDialog(
|
|
title: "温馨提示",
|
|
content: RichTextX(
|
|
children: [
|
|
TextSpanItem('如果您不同意'),
|
|
TextSpanItem(
|
|
'《隐私协议》',
|
|
onTap: () => openPage("隐私政策", "https://lnh2e.com/privacy_agreement.html"),
|
|
),
|
|
TextSpanItem('和'),
|
|
TextSpanItem(
|
|
'《用户政策》',
|
|
onTap: () => openPage("用户协议", "https://lnh2e.com/user_agreement.html"),
|
|
),
|
|
TextSpanItem(
|
|
',很遗憾我们将无法为您提供服务。您需要同意以上协议后,才能使用本应用。\n\n我们将严格按照相关法律法规要求,坚决保护您的个人隐私和信息安全。',
|
|
),
|
|
TextSpanItem('\n点击“同意”按钮,表示您已知情并同意以上协议。'),
|
|
],
|
|
),
|
|
confirmText: '同意并继续',
|
|
cancelText: '不同意',
|
|
onConfirm: () async {
|
|
await StorageService.to.savePrivacyAgreed(true);
|
|
Get.offAll(() => const HomePage());
|
|
},
|
|
onCancel: () {
|
|
SystemNavigator.pop();
|
|
},
|
|
);
|
|
},
|
|
);
|
|
}
|
|
|
|
Widget _buildDialogContent() {
|
|
return RichTextX(
|
|
children: [
|
|
TextSpanItem('欢迎使用小羚羚!\n我们将通过'),
|
|
TextSpanItem(
|
|
'《隐私协议》',
|
|
onTap: () => openPage("隐私政策", "https://lnh2e.com/privacy_agreement.html"),
|
|
),
|
|
TextSpanItem('和'),
|
|
TextSpanItem(
|
|
'《用户政策》',
|
|
onTap: () => openPage("用户协议", "https://lnh2e.com/user_agreement.html"),
|
|
),
|
|
TextSpanItem(
|
|
',帮助您了解我们为您提供的服务、我们如何处理个人信息以及您享有的权利。我们会严格按照相关法律法规要求,采取各种安全措施来保护您的个人信息。',
|
|
),
|
|
TextSpanItem('\n点击“同意”按钮,表示您已知情并同意以上协议。'),
|
|
],
|
|
);
|
|
}
|
|
|
|
void openPage(String title, String url) {
|
|
Get.to(() => const WebViewPage(), arguments: {'title': title, 'url': url});
|
|
}
|
|
|
|
void _startTimer() {
|
|
// 1.5秒后执行跳转逻辑
|
|
Future.delayed(const Duration(milliseconds: 1500), () {
|
|
Get.offAll(() => const HomePage());
|
|
});
|
|
}
|
|
|
|
void _jumpToNextPage() {
|
|
if (StorageService.to.isLoggedIn) {
|
|
// 已登录,跳转到首页
|
|
Get.offAll(() => const HomePage());
|
|
} else {
|
|
// 未登录,跳转到登录页
|
|
Get.offAll(() => const LoginPage());
|
|
}
|
|
}
|
|
}
|