You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.4 KiB
65 lines
1.4 KiB
import 'package:get/get.dart';
|
|
import '../../../routes/app_routes.dart';
|
|
|
|
class AIItem {
|
|
final String id;
|
|
final String title;
|
|
final String description;
|
|
final double price;
|
|
final String productId;
|
|
|
|
AIItem({
|
|
required this.id,
|
|
required this.title,
|
|
required this.description,
|
|
required this.price,
|
|
required this.productId,
|
|
});
|
|
}
|
|
|
|
class GoodsaiController extends GetxController {
|
|
final RxList<AIItem> items = <AIItem>[].obs;
|
|
final RxBool loading = false.obs;
|
|
final RxString error = ''.obs;
|
|
|
|
@override
|
|
void onInit() {
|
|
super.onInit();
|
|
_loadProducts();
|
|
}
|
|
|
|
Future<void> _loadProducts() async {
|
|
loading.value = true;
|
|
error.value = '';
|
|
try {
|
|
items.assignAll([
|
|
AIItem(
|
|
id: 'ai_chat',
|
|
title: '通用AI聊天包',
|
|
description: '更长对话额度与工具调用',
|
|
price: 19.9,
|
|
productId: 'ai_chat_101',
|
|
),
|
|
AIItem(
|
|
id: 'ai_tools',
|
|
title: 'AI工具扩展',
|
|
description: '额外工具能力与上下文长度',
|
|
price: 39.9,
|
|
productId: 'ai_tools_201',
|
|
),
|
|
]);
|
|
} catch (e) {
|
|
error.value = e.toString();
|
|
} finally {
|
|
loading.value = false;
|
|
}
|
|
}
|
|
|
|
void purchase(AIItem item) {
|
|
Get.toNamed(Routes.payment, arguments: {
|
|
'productId': item.productId,
|
|
'amount': item.price,
|
|
'description': item.title,
|
|
});
|
|
}
|
|
}
|