Commit fa129e94 authored by 关振斌's avatar 关振斌

update

parent 992c2f82
import 'package:chart/common/entities/classFyDetail.dart';
import 'package:chart/common/entities/convers.dart';
import 'package:chart/common/entities/entities.dart';
import 'package:chart/common/entities/good.dart';
import 'package:chart/common/utils/utils.dart';
......@@ -11,10 +12,11 @@ import '../../entity/square_entity.dart';
class NewsAPI {
/// 翻页
/// refresh 是否刷新
static Future<NewsPageListResponseEntity> newsPageList(
static Future<NewsPageListResponseEntity> getConversionByUserId(
Map<String, int> params) async {
var response = await HttpUtil().get(
'/searchRecord/getSearchRecord/${params['page']}/${params['size']}',
// /api/openAi/getConversionByUserId
'/openAi/getConversionByUserId/${params['page']}/${params['size']}',
);
return NewsPageListResponseEntity.fromJson(response['data']);
// searchRecordEntityFromList(response.data);
......@@ -25,6 +27,20 @@ class NewsAPI {
return response['data'];
}
static Future<dynamic> getConversionById(int conversionId) async {
var response = await HttpUtil().get(
'/openAi/getConversionById/${conversionId}',
);
return response['data']
.map(((item) => ConversEntity.fromJson(item)))
.toList();
// response
// .map<ChannelResponseEntity>(
// (item) => ChannelResponseEntity.fromJson(item))
// .toList()
}
static Future<int> aiAnswerWithStream(Map<String, String> params) async {
var response =
await HttpUtil().post('/openAi/aiAnswerWithStream', data: params);
......
......@@ -47,6 +47,48 @@ class UserAPI {
// UserLoginResponseEntity.fromJson(response);
}
//创建会话
static Future<int> createConversion() async {
var response = await HttpUtil().get(
'/openAi/createConversion',
);
return response['data'];
}
static Future<int> endConversion(Map<String, dynamic> parameters) async {
var response = await HttpUtil().get(
'/openAi/endConversion?conversionId=${parameters['conversionId']}',
);
return response['status'];
}
//对话
static Future<int> aiAnswerWithConversion(
Map<String, dynamic> parameters) async {
var response = await HttpUtil().post(
'/openAi/aiAnswerWithConversion',
data: parameters,
);
return response['status'];
// return ApplePayEntity.fromMap(response['data']);
}
///api/ 保存问题
static Future<int> saveResp(Map<String, dynamic> parameters) async {
var response = await HttpUtil().post(
'/openAi/saveResp',
data: parameters,
);
return response['status'];
// return ApplePayEntity.fromMap(response['data']);
}
// /api/
// openAi/createConversion
static Future<UserInfoEntity> getUserInfo() async {
var response = await HttpUtil().get(
'/user/info',
......
class ConversEntity {
int? id;
String? sendTime;
String? role;
String? content;
int? conversionId;
ConversEntity(
{this.id, this.sendTime, this.role, this.content, this.conversionId});
ConversEntity.fromJson(Map<String, dynamic> json) {
id = json['id'];
sendTime = json['sendTime'];
role = json['role'];
content = json['content'];
conversionId = json['conversionId'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['sendTime'] = this.sendTime;
data['role'] = this.role;
data['content'] = this.content;
data['conversionId'] = this.conversionId;
return data;
}
}
......@@ -69,6 +69,7 @@ class NewsItem {
int? id;
String? question;
String? answer;
String? name;
String? thumbnail;
int? likes;
int? forward;
......@@ -78,6 +79,7 @@ class NewsItem {
this.id,
this.question,
this.answer,
this.name,
this.thumbnail,
this.likes,
this.forward,
......@@ -91,6 +93,7 @@ class NewsItem {
thumbnail: json["thumbnail"],
likes: json["likes"],
forward: json["forward"],
name: json['name'],
// DateTime.parse(),
createTime: DateTime.parse(json["createTime"]),
);
......@@ -100,6 +103,7 @@ class NewsItem {
"question": question,
"answer": answer,
"thumbnail": thumbnail,
"name": name,
"likes": likes,
"forward": forward,
"createTime": createTime?.toIso8601String(),
......
......@@ -123,7 +123,7 @@ class HttpUtil {
EasyLoading.showError(eInfo.message);
break;
default:
EasyLoading.showError('未知错误');
EasyLoading.showError('网络异常');
break;
}
}
......@@ -179,7 +179,7 @@ class HttpUtil {
}
}
} on Exception catch (_) {
return ErrorEntity(code: -1, message: "未知错误");
return ErrorEntity(code: -1, message: "网络异常");
}
}
default:
......
// baidu yapi
// const SERVER_API_URL = 'https://yapi.baidu.com/mock/41008';
// const SERVER_API_URL = 'http://192.168.110.127:8083/api';
// const SERVER_API_URL = 'http://101.34.153.228:8083/api';//线上
const SERVER_API_URL = "http://192.168.120.108:8083/api";
const SERVER_API_URL = 'http://101.34.153.228:8083/api';//线上
// const SERVER_API_URL = 'http://192.168.2.178:8083/api';//线上
//http://192.168.2.178:8083/api/doc.html
// const SERVER_API_URL = "http://192.168.120.108:8083/api";
// http://192.168.110.127:8083/api/doc.html
// http://192.168.110.66:8083/api/doc.html
// const SERVER_API_URL = 'http://192.168.110.66:8083/api';
......
import 'dart:async';
// import 'package:vibration/vibration.dart';
import 'package:chart/pages/frame/notfound/index.dart';
import 'package:flutter_vibrate/flutter_vibrate.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
......@@ -108,8 +109,9 @@ class ApplicationController extends GetxController {
// 跳转 注册界面
handleChat() async {
Vibrate.feedback(FeedbackType.impact);
Get.toNamed(AppRoutes.CHAT_PAGE);
await ChatNewController.to.createConversionId();
// Vibrate.feedback(FeedbackType.impact);
// Get.toNamed(AppRoutes.CHAT_PAGE);
// await ConfigStore.to.saveAlreadyOpen();
// Get.offAndToNamed(AppRoutes.CHAT_PAGE);
}
......@@ -124,7 +126,7 @@ class ApplicationController extends GetxController {
// handleIncomingLinks();
// 准备一些静态数据
tabTitles = ['首页', '信息广场', '个人中心'];
tabTitles = ['首页', '我的聊天', '个人中心'];
bottomTabs = <BottomNavigationBarItem>[
new BottomNavigationBarItem(
icon: Icon(
......@@ -147,7 +149,7 @@ class ApplicationController extends GetxController {
Iconfont.grid,
color: AppColors.secondaryElementText,
),
label: '信息广场',
label: '我的聊天',
backgroundColor: AppColors.primaryBackground,
),
// new BottomNavigationBarItem(
......
import 'package:chart/common/apis/apis.dart';
import 'package:chart/common/entities/convers.dart';
import 'package:chart/common/entities/entities.dart';
import 'package:chart/pages/frame/notfound/index.dart';
import 'package:get/get.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
......@@ -32,6 +34,12 @@ class CategoryController extends GetxController {
});
}
getMessageList(dynamic id) async {
final res = await NewsAPI.getConversionById(id);
ChatNewController.to.getMessageList(res, id);
}
void onLoading() {
if (state.newsList.length < total) {
fetchNewsList().then((_) {
......@@ -48,8 +56,9 @@ class CategoryController extends GetxController {
// 拉取数据
Future<void> fetchNewsList({bool isRefresh = false}) async {
var result =
await NewsAPI.newsPageList({'page': curPage, "size": pageSize});
//
var result = await NewsAPI.getConversionByUserId(
{'page': curPage, "size": pageSize});
if (isRefresh == true) {
curPage = 1;
......
// import 'package:chart/utils/common_util.dart';
import 'package:chart/pages/category/index.dart';
import 'package:flutter/material.dart';
import 'package:chart/common/entities/entities.dart';
import 'package:chart/common/utils/utils.dart';
import 'package:chart/common/values/values.dart';
import 'package:chart/common/widgets/widgets.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:glassmorphism/glassmorphism.dart';
// Widget newsListItem(NewsItem item) {
......@@ -143,13 +145,19 @@ import 'package:glassmorphism/glassmorphism.dart';
// }
Widget newsListItem(NewsItem item) {
final c = Get.find<CategoryController>();
// getConversionById
// double textScaleFactor = MediaQuery.textScaleFactorOf(context);
return GlassmorphicContainer(
height: 220,
return InkWell(
onTap: () {
c.getMessageList(item.id);
},
child: GlassmorphicContainer(
height: 66,
width: double.infinity,
// flex: 1,
borderRadius: 16,
padding: EdgeInsets.only(bottom: 16),
// padding: EdgeInsets.only(bottom: 16),
blur: 14,
alignment: Alignment.bottomCenter,
border: 2,
......@@ -175,38 +183,43 @@ Widget newsListItem(NewsItem item) {
// mainAxisAlignment: MainAxisAlignment.spaceAround,
// ignore: prefer_const_literals_to_create_immutables
children: [
// Center(
// child: Text(
// "${item.name}",
// style: const TextStyle(
// color: Colors.white,
// height: 2,
// fontSize: 20,
// fontWeight: FontWeight.w600),
// ),
// )
// ignore: prefer_const_constructors
Container(
// color: Colors.red,
height: 50,
height: 30,
width: double.infinity,
padding: EdgeInsets.symmetric(horizontal: 16),
child: Text(
"${item.question}",
"${item.name}",
style: const TextStyle(
color: Colors.white,
height: 2,
fontSize: 20,
fontSize: 14,
fontWeight: FontWeight.w600),
)),
// ignore: prefer_const_constructors
Container(
// color: Colors.red,
padding: EdgeInsets.symmetric(horizontal: 16),
height: 30,
width: double.infinity,
height: 150,
child: SingleChildScrollView(
padding: EdgeInsets.symmetric(horizontal: 16),
child: Text(
"${item.answer}",
style: TextStyle(color: Colors.white, fontSize: 12
// height: 0.8
),
// height: 2,
// fontSize: 20,
maxLines: 7,
),
),
),
]));
"${item.createTime!.toLocal().year}-${item.createTime!.toLocal().month}-${item.createTime!.toLocal().day} ${item.createTime!.toLocal().hour}:${item.createTime!.toLocal().minute}",
style: const TextStyle(
color: Colors.white,
height: 2,
fontSize: 14,
fontWeight: FontWeight.w600),
)),
// ignore: prefer_const_constructors
])),
);
}
......@@ -18,7 +18,7 @@ class _NewsPageListState extends State<NewsPageList>
@override
bool get wantKeepAlive => true;
final controller = Get.find<CategoryController>();
final controller = Get.put(CategoryController());
@override
Widget build(BuildContext context) {
......
......@@ -111,111 +111,131 @@ class PayItemWidget extends GetView<AndroidPayListController> {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Obx(() => controller.state.selected ==
'com.wudi.app.60stars'
? Column(
Obx(
() => Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: controller.state.items.length == 0
? []
: controller.state.items
.firstWhere((element) =>
element.appleProductId ==
controller.state.selected)
.goodsDesc!
.split('、')
.map(
(item) => Row(
// crossAxisAlignment
children: [
Icon(Icons.check, color: color),
Text("30次提问机会",
Text(item,
style: TextStyle(
color: color, fontSize: 16))
],
),
)
.toList(),
),
),
// Obx(() => controller.state.selected ==
// 'com.wudi.app.60stars'
// ? Column(
// crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisAlignment:
// MainAxisAlignment.spaceAround,
// children: [
// Row(
// // crossAxisAlignment
// children: [
// Icon(Icons.check, color: color),
// Text("无广告",
// Text("3022次提问机会",
// style: TextStyle(
// color: color, fontSize: 16))
// ],
// ),
Row(
children: [
Icon(Icons.check, color: color),
Text("解锁所有高级功能",
style: TextStyle(
color: color, fontSize: 16))
],
)
],
)
: controller.state.selected ==
'com.wudi.app.monthly_pass'
? Column(
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [
Row(
// crossAxisAlignment
// Row(
// children: [
// Icon(Icons.check, color: color),
// Text("解锁所有高级功能",
// style: TextStyle(
// color: color, fontSize: 16))
// ],
// )
// ],
// )
// : controller.state.selected ==
// 'com.wudi.app.monthly_pass'
// ? Column(
// crossAxisAlignment:
// CrossAxisAlignment.start,
// mainAxisAlignment:
// MainAxisAlignment.spaceAround,
// children: [
// Row(
// // crossAxisAlignment
children: [
Icon(Icons.check, color: color),
Text("月卡会员",
style: TextStyle(
color: color, fontSize: 16))
],
),
Row(
children: [
Icon(Icons.check, color: color),
Text("无限聊天",
style: TextStyle(
color: color, fontSize: 16))
],
),
Row(
children: [
Icon(Icons.check, color: color),
Text("解锁所有高级功能",
style: TextStyle(
color: color, fontSize: 16))
],
)
],
)
: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [
Row(
// crossAxisAlignment
// children: [
// Icon(Icons.check, color: color),
// Text("月卡会员",
// style: TextStyle(
// color: color, fontSize: 16))
// ],
// ),
// Row(
// children: [
// Icon(Icons.check, color: color),
// Text("无限聊天",
// style: TextStyle(
// color: color, fontSize: 16))
// ],
// ),
// Row(
// children: [
// Icon(Icons.check, color: color),
// Text("解锁所有高级功能",
// style: TextStyle(
// color: color, fontSize: 16))
// ],
// )
// ],
// )
// : Column(
// crossAxisAlignment:
// CrossAxisAlignment.start,
// mainAxisAlignment:
// MainAxisAlignment.spaceAround,
// children: [
// Row(
// // crossAxisAlignment
children: [
Icon(Icons.check, color: color),
Text("周卡会员",
style: TextStyle(
color: color, fontSize: 16))
],
),
Row(
children: [
Icon(Icons.check, color: color),
Text("无限聊天",
style: TextStyle(
color: color, fontSize: 16))
],
),
Row(
children: [
Icon(Icons.check, color: color),
Text("解锁所有高级功能",
style: TextStyle(
color: color, fontSize: 16))
],
)
],
)),
// children: [
// Icon(Icons.check, color: color),
// Text("周卡会员",
// style: TextStyle(
// color: color, fontSize: 16))
// ],
// ),
// Row(
// children: [
// Icon(Icons.check, color: color),
// Text("无限聊天",
// style: TextStyle(
// color: color, fontSize: 16))
// ],
// ),
// Row(
// children: [
// Icon(Icons.check, color: color),
// Text("解锁所有高级功能",
// style: TextStyle(
// color: color, fontSize: 16))
// ],
// )
// ],
// )),
Image(
image: AssetImage("assets/images/center-1.png"),
width: Get.mediaQuery.size.height * 0.17,
......@@ -277,7 +297,7 @@ class PayItemWidget extends GetView<AndroidPayListController> {
color: Colors.white),
),
Text(
"${item == 0 ? '30次提问卡' : item == 1 ? '月卡' : '周卡'}",
"${controller.state.items[item].goodsName!}",
maxLines: 2,
overflow: TextOverflow.clip,
style: TextStyle(
......
import 'dart:async';
import 'package:chart/common/apis/apis.dart';
import 'package:chart/common/routers/routes.dart';
import 'package:chart/common/store/store.dart';
import 'package:chart/common/values/server.dart';
import 'package:chart/entity/user_entity.dart';
import 'package:chart/package/chat_dash/dash_chat_2.dart' as Chat;
import 'package:chart/package/chat_dash/dash_chat_2.dart';
import 'package:chart/pages/category/controller.dart';
import 'package:chart/pages/frame/product/controller.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
......@@ -63,7 +65,7 @@ class ChatNewController extends GetxController {
/// 事件
void sendMessage(Chat.ChatMessage message) async {
print("${message.text}321321321");
print("${message.text}");
Vibrate.feedback(FeedbackType.impact);
// if (state.messageList.isNotEmpty) {
// // data = !_messages.every((element) => element.status != Status.sending);
......@@ -108,8 +110,11 @@ class ChatNewController extends GetxController {
if (UserStore.to.profile.id != '') {
await initEventSource();
state.isLoading = true;
int? result =
await NewsAPI.aiAnswerWithStream({"question": message.text});
int? result = await UserAPI.aiAnswerWithConversion({
"question": message.text,
"conversionId": state.conversionId,
"next": state.isNext
});
// _cancelLoading();
// print(
// "eventSource.isPausedeventSource.isPausedeventSource.isPaused---------------${eventSource.isPaused}");
......@@ -190,6 +195,31 @@ class ChatNewController extends GetxController {
}
// 方法
closeChat() async {
// // final c = Get.put(ChatPageController());
final c = Get.put(CategoryController());
state.isNext = 1;
try {
await UserAPI.endConversion({
"conversionId": state.conversionId,
});
Vibrate.feedback(FeedbackType.impact);
state.messageList.value = [];
Get.back();
c.refresh();
} catch (e) {}
// Get.back();
// Get.defaultDialog(
// title: "提示",
// textConfirm:"",
// content: Container(
// child: Column(children: [Text("返回后查看当前回话记录请去我的信息页面!")
// ]),
// ));
}
// 拉取数据
Future<void> fetchNewsList({bool isRefresh = false}) async {
// var result =
......@@ -208,33 +238,99 @@ class ChatNewController extends GetxController {
// print("${state.newsList.length}");
}
getMessageList(messageList, id) {
// final list = messageList?.forEach((item) {
// // if (item['role'] == "user") {
// // return Chat.ChatMessage(
// // text: item['content'],
// // user: _user,
// // createdAt: DateTime.now(),
// // );
// // } else {
// // return ChatMessage(
// // user: receiveUser,
// // createdAt: DateTime.now(),
// // text: item['content'],
// // );
// // }
// });
final messages = List<ChatMessage>.generate(messageList.length, (index) {
final i = messageList[index];
var message;
if (i?.role == "user") {
message = Chat.ChatMessage(
text: i?.content,
user: _user,
createdAt: DateTime.parse(i.sendTime).toLocal(),
);
} else {
message = ChatMessage(
user: receiveUser,
createdAt: DateTime.parse(i.sendTime).toLocal(),
text: i?.content,
);
}
return message;
});
state.isNext = 2;
state.messageList.value = messages.reversed.toList();
state.conversionId = id;
Get.toNamed("${AppRoutes.CHAT_PAGE}");
}
sendMessageByBanner(String message) async {
await createConversionId();
// Vibrate.feedback(FeedbackType.impact);
// // message.question
Chat.ChatUser _user = Chat.ChatUser(
id: '1',
// firstName: 'Charles',
// lastName: 'Leclerc',
);
// // ?question=${message.question}
// Get.toNamed("${AppRoutes.CHAT_PAGE}");
sendMessage(Chat.ChatMessage(
text: "${message}",
user: _user,
createdAt: DateTime.now(),
));
}
initEventSource() async {
// if (UserStore.to.isLogin) {
sse = SSEClient.subscribeToSSE(
url: "$SERVER_API_URL/openAi/connect/${UserStore.to.profile.id}",
header: {}).listen((event) {
if (event.id == "[DONE]") {
header: {}).listen((event) async {
if (event.data!.trim().isEmpty) {
return;
} else if (event.id == "[DONE]") {
await UserAPI.saveResp({
"conversionId": state.conversionId,
"content": state.messageList[0].text,
});
state.isLoading = false;
// SSEClient.unsubscribeFromSSE();
// eventSource.cancel();
return;
}
print('Id: ' + event.id!);
print('Event: ' + event.event!);
print('Data: ' + event.data!);
Map<String, dynamic> jsonMap = jsonDecode("${event.data}");
if (jsonMap['askType'] == 1) {
_updateMessage("${jsonMap['content']}" as String);
} else {
// print("${jsonMap['content']}}");
print("${jsonMap['content']}");
ProductController.to.state.inderText =
ProductController.to.state.inderText + jsonMap['content'];
// state.genText
}
});
}
Future createConversionId() async {
Vibrate.feedback(FeedbackType.impact);
Get.toNamed(AppRoutes.CHAT_PAGE);
int id = await UserAPI.createConversion();
state.conversionId = id;
}
_updateMessage(String text) {
// state.messageList[0].text = state.messageList[0].text + text;
// state.messageList.forEach((element) {
......@@ -274,8 +370,8 @@ class ChatNewController extends GetxController {
tabMessage(message) {
Clipboard.setData(ClipboardData(text: message?.text));
Get.snackbar("复制成功", "", colorText: Colors.white);
EasyLoading.showSuccess("复制成功");
// Get.snackbar("复制成功", "", colorText: Colors.white);
}
@override
......
......@@ -11,12 +11,20 @@ class ChatPageState {
// get _messageList =>
final _page = "AI写作大师".obs;
set page(value) => this._page.value = value;
get page => this._page.value;
set page(value) => _page.value = value;
get page => _page.value;
RxBool _isLoading = false.obs;
final RxBool _isLoading = false.obs;
set isLoading(value) => _isLoading.value = value;
get isLoading => _isLoading.value;
final _conversionId = 0.obs;
set conversionId(value) => _conversionId.value = value;
get conversionId => _conversionId.value;
final _isNext = 1.obs;
set isNext(value) => _isNext.value = value;
get isNext => _isNext.value;
// RxList<NewsItem> newsList = <NewsItem>[].obs;
}
......@@ -45,7 +45,7 @@ class ChatNewPage extends GetView<ChatNewController> {
appBar: transparentAppBar(
actions: [
IconButton(
tooltip: '返回上一页',
tooltip: '分享',
icon: const Icon(
Icons.share,
color: AppColors.primaryElementText,
......@@ -81,7 +81,8 @@ class ChatNewPage extends GetView<ChatNewController> {
color: AppColors.primaryElementText,
),
onPressed: () {
Get.back();
// Get.back();
controller.closeChat();
// Get.offAll(ApplicationPage());
// await Get.off(ApplicationPage());
// Get.toNamed(AppRoutes.Application);
......
......@@ -70,17 +70,21 @@ class ProductController extends GetxController {
sse = SSEClient.subscribeToSSE(
url: "$SERVER_API_URL/openAi/connect/${UserStore.to.profile.id}",
header: {}).listen((event) {
try {
if (EasyLoading.isShow) {
EasyLoading.dismiss();
}
if (event.id == "[DONE]") {
state.isLoading = false;
return;
}
Map<String, dynamic> jsonMap = jsonDecode("${event.data}");
if (jsonMap['askType'] == 1) {
// _updateMessage("${jsonMap['content']}" as String);
} else {
Map<String, dynamic> jsonMap = jsonDecode(event.data as String);
state.inderText = state.inderText + jsonMap['content'];
// state.genText
} catch (e) {
EasyLoading.dismiss();
}
//
});
}
......@@ -102,7 +106,7 @@ class ProductController extends GetxController {
handleCopy() {
Clipboard.setData(ClipboardData(text: state.inderText));
Get.snackbar("复制成功", "", colorText: Colors.white);
EasyLoading.showSuccess("复制成功");
}
void handleGenText() async {
......@@ -125,19 +129,6 @@ class ProductController extends GetxController {
// GetX.pop.pop()
Get.back();
state.loading = true;
EasyLoading.show(status: "AI正在生成中...");
// "question": str + str1 + str3, "id": "${UserStore.to.profile.id}
// [
// {
// "id": 0,
// "label": "",
// "placeHolder": "",
// "value": ""
// }
// ]
// json.encode(map);
if (UserStore.to.isLogin) {
state.isLoading = true;
......@@ -156,9 +147,9 @@ class ProductController extends GetxController {
"sort": 2,
}
], params['detailId']!);
EasyLoading.show(status: "AI正在生成中...");
if (result == 200) {
EasyLoading.dismiss();
// EasyLoading.dismiss();
UserAPI.getUserInfo().then((value) async {
await UserStore.to.saveProfile(IntegralEntity(
id: UserStore.to.profile.id,
......@@ -185,10 +176,10 @@ class ProductController extends GetxController {
state.loading = false;
// Get.snackbar("错误提示", "您的问题还没有填完", colorText: Colors.white);
}
EasyLoading.dismiss();
// EasyLoading.dismiss();
} catch (e) {
state.loading = false;
EasyLoading.dismiss();
// EasyLoading.dismiss();
}
print("$str");
......
......@@ -94,22 +94,7 @@ class SiperBannerWidget extends GetView<MainController> {
padding: EdgeInsets.symmetric(horizontal: 16),
child: GestureDetector(
onTap: () {
Vibrate.feedback(FeedbackType.impact);
// message.question
Chat.ChatUser _user = Chat.ChatUser(
id: '1',
// firstName: 'Charles',
// lastName: 'Leclerc',
);
Get.toNamed(
"${AppRoutes.CHAT_PAGE}?question=${message.question}");
c.sendMessage(Chat.ChatMessage(
text: "${message.question}",
user: _user,
createdAt: DateTime.now(),
));
c.sendMessageByBanner(message.question);
},
child: Container(
height: 70,
......
import 'package:chart/common/entities/classFyDetail.dart';
import 'package:chart/pages/main/controller.dart';
import 'package:get/get.dart';
import '../../common/apis/apis.dart';
......@@ -24,7 +25,10 @@ class TemplateController extends GetxController {
}
handleSetActId(int id) {
final c = Get.find<MainController>();
final act = c.state.bannerPage!.firstWhere((element) => element.id == id);
actId = id;
state.title = act.classifyName;
}
/// 在 widget 内存中分配后立即调用。
......
......@@ -3,4 +3,8 @@ import 'package:get/get.dart';
class TemplateState {
RxMap mapItem = Map().obs;
final _title = '模版中心'.obs;
set title(value) => _title.value = value;
get title => _title.value;
}
......@@ -20,37 +20,6 @@ class TemplatePage extends GetView<TemplateController> {
fit: BoxFit.cover),
),
child: const HelloWidget(),
// GlassmorphicContainer(
// width: Get.mediaQuery.size.width * 1,
// height: Get.mediaQuery.size.height * 1,
// // margin: EdgeInsets.only(bottom: 60),
// // padding: EdgeInsets.all(20),
// // ignore: sort_child_properties_last
// child:
// borderRadius: 14,
// blur: 14,
// alignment: Alignment.bottomCenter,
// border: 2,
// linearGradient: LinearGradient(
// begin: Alignment.topLeft,
// end: Alignment.bottomRight,
// colors: [
// const Color(0xFF0FFFF).withOpacity(0.0),
// const Color(0xFF0FFFF).withOpacity(0.0),
// ],
// ),
// borderGradient: LinearGradient(
// begin: Alignment.topLeft,
// end: Alignment.bottomRight,
// colors: [
// const Color(0xFF0FFFF).withOpacity(1),
// const Color(0xFFFFFFF),
// const Color(0xFF0FFFF).withOpacity(1),
// ],
// ),
// // child: ,
// ),
);
}
......@@ -67,21 +36,14 @@ class TemplatePage extends GetView<TemplateController> {
color: AppColors.primaryElementText,
),
onPressed: () async {
// Get.back();
// Get.offAll(ApplicationPage());
// await Get.off(ApplicationPage());
// Get.toNamed(AppRoutes.Application);
Get.back();
// await Get.toNamed();
// Navigator.of(context).pop();
//_nextPage(-1);
},
),
title: const Text(
"模版中心",
title: Obx(() => Text(
controller.state.title,
style: TextStyle(color: Colors.white),
)),
),
body: _buildView());
},
);
......
......@@ -16,8 +16,6 @@ class HelloWidget extends GetView<TemplateController> {
const HelloWidget({Key? key}) : super(key: key);
Widget _renderList(int index) {
final c = Get.find<MainController>();
final productController = Get.put(ProductController());
return Obx(() => controller.state.mapItem[controller.actId] == null
? SizedBox.shrink()
......
......@@ -48,8 +48,8 @@ class UserDetailController extends GetxController {
// 拉取数据
Future<void> fetchNewsList({bool isRefresh = false}) async {
var result =
await NewsAPI.newsPageList({'page': curPage, "size": pageSize});
var result = await NewsAPI.getConversionByUserId(
{'page': curPage, "size": pageSize});
if (isRefresh == true) {
curPage = 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment