初始化

This commit is contained in:
谢宇宁
2026-09-15 15:44:13 +07:00
commit a23ba685e9
1065 changed files with 101122 additions and 0 deletions
@@ -0,0 +1,77 @@
import 'package:get/get.dart';
import 'package:hgdj/hj_utils/api_service/ai_service.dart';
import 'package:hgdj/tools_base/debug_log.dart';
import 'package:hgdj/tools_base/loading/loading_alert_widget.dart';
import 'package:hgdj/tools_base/toast.dart';
import '../models/ai_girl_resp_model.dart';
import '../widgets/ai_girl_sheet.dart';
import 'ai_h5_page.dart';
class AIGrilFriendLogic extends GetxController {
AIGirlFriendBalanceModel? balanceModel;
AIGirlFriendUrlModel? urlModel;
AIGirlFriendCurrencys? currencys;
RxBool open = true.obs;
RxString tips = ''.obs;
@override
void onReady() {
super.onReady();
loadData();
onFetchChargeList();
}
loadData() async {
try {
balanceModel = await AIService.getBalance({});
open.value = true;
} catch (e) {
debugLog(e);
open.value = false;
}
update(['balance']);
}
//跳转url
onFetchJumpUrl() async {
try {
LoadingAlertWidget.show();
urlModel = await AIService.getMateUrl();
LoadingAlertWidget.cancel();
} catch (e) {
LoadingAlertWidget.cancel();
debugLog(e);
}
if (urlModel?.url != null) {
await Get.to(AiH5Page(webUrl: urlModel?.url));
loadData();
} else {
showToast('未知链接');
}
}
//充值操作
onRechargeBottomSheet() async {
if (currencys != null && currencys?.list?.isNotEmpty == true) {
Get.bottomSheet(AIGirlSheet(list: currencys?.list),
isScrollControlled: true);
} else {
await onFetchChargeList();
if (currencys?.list?.isNotEmpty != true) {
showToast("暂未配置充值数据");
}
}
}
//获取充值列表
Future onFetchChargeList({bool showLoading = false}) async {
if (showLoading) LoadingAlertWidget.show();
try {
currencys = await AIService.getMateCurrencies();
} catch (e) {
debugLog(e);
}
if (showLoading) LoadingAlertWidget.cancel();
}
}
@@ -0,0 +1,155 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:hgdj/assets_tool/images.dart';
import '../../../hj_utils/widget_util.dart';
import '../../../tools_base/unique_tag_mixin.dart';
import 'ai_girl_friend_logic.dart';
// Ai女友
class AIGrilFriendPage extends StatefulWidget {
const AIGrilFriendPage({super.key});
@override
State<AIGrilFriendPage> createState() => _AIGrilFriendPageState();
}
class _AIGrilFriendPageState extends State<AIGrilFriendPage>
with UniqueTagMixin {
@override
Widget build(BuildContext context) {
return GetBuilder<AIGrilFriendLogic>(
tag: uniqueTag,
init: AIGrilFriendLogic(),
builder: (logic) => Scaffold(
body: Stack(
alignment: Alignment.center,
children: [
Image.asset(
'ai_girl_friend_bg.webp'.aiPath,
fit: BoxFit.fill,
width: Get.width,
height: Get.height,
),
Positioned(
bottom: 125,
left: 10,
right: 10,
child: GestureDetector(
onTap: () => logic.onFetchJumpUrl(),
child: Image.asset(
'ai_girl_friend_btn.webp'.aiPath,
),
),
),
Positioned(
top: 0,
height: 101,
child: Stack(
children: [
Image.asset(
'ai_girl_friend_top.webp'.aiPath,
width: Get.width,
fit: BoxFit.fitWidth,
),
_buildBanlance(logic),
],
),
),
Positioned.fill(
child: Obx(() => logic.open.value
? Container()
: Stack(
children: [
Container(
color: Colors.black.withValues(alpha: .75),
child: Center(
child: Obx(
() => Text(
logic.tips.value,
style:
textStyle(17, Colors.white, FontWeight.w500),
),
)),
),
Positioned(
left: 10,
top: 60,
child: GestureDetector(
child: GestureDetector(
onTap: () => Get.back(),
child: const Icon(Icons.arrow_back_ios,
size: 24, color: Colors.white),
),
),
)
],
)),
),
],
),
),
);
}
Widget _buildBanlance(AIGrilFriendLogic logic) {
return Positioned(
left: 10,
right: 10,
bottom: 14,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
GestureDetector(
child: GestureDetector(
onTap: () => Get.back(),
child: const Icon(Icons.arrow_back_ios,
size: 24, color: Colors.white),
),
),
Container(
padding: EdgeInsets.all(1),
decoration: BoxDecoration(
color: Colors.black,
borderRadius: BorderRadius.circular(100),
border: Border.all(color: Color(0xff2A5298)),
),
child: Row(
children: [
const SizedBox(width: 12),
GetBuilder<AIGrilFriendLogic>(
id: 'balance',
builder: (_) {
if (_.balanceModel != null) {
return Text(
'积分:${_.balanceModel?.balance ?? 0}',
style: textStyle(18, Colors.white, FontWeight.w400),
);
} else {
return const SizedBox(
width: 22,
child: CupertinoActivityIndicator(
color: Colors.white,
radius: 8,
),
);
}
},
),
const SizedBox(width: 10),
GestureDetector(
onTap: () => logic.onRechargeBottomSheet(),
child: Image.asset(
'ai_girl_friend_topup.webp'.aiPath,
width: 76,
),
)
],
),
)
],
),
);
}
}
+60
View File
@@ -0,0 +1,60 @@
import 'dart:collection';
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:get/get.dart';
import 'package:hgdj/assets_tool/app_colors.dart';
import '../../../hj_utils/widget_util.dart';
import '../../web_page/h5_webview_settings.dart';
class AiH5Page extends StatefulWidget {
final String? webUrl;
const AiH5Page({super.key, this.webUrl});
@override
State<StatefulWidget> createState() {
return _YHYSH5ViewState();
}
}
class _YHYSH5ViewState extends State<AiH5Page> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Stack(
fit: StackFit.expand,
children: [
InAppWebView(
initialUrlRequest:
URLRequest(url: WebUri(widget.webUrl ?? "")), //h5的url
initialSettings: h5WebViewSettings,
initialUserScripts: UnmodifiableListView<UserScript>([]),
),
Positioned(
bottom: 70,
right: 10,
width: 44,
height: 44,
child: GestureDetector(
onTap: () => Get.back(),
child: Container(
alignment: Alignment.center,
decoration: BoxDecoration(
color: AppColors.primaryHighColor,
borderRadius: BorderRadius.circular(22),
),
child: Text(
'退出',
style: textStyle(14, Colors.black, FontWeight.w500),
),
),
),
),
],
),
),
);
}
}