消息中心,待测试
This commit is contained in:
@@ -31,6 +31,7 @@ class MineController extends GetxController with BaseControllerMixin {
|
||||
}
|
||||
|
||||
String rate = "";
|
||||
String rating = "";
|
||||
String accident = "";
|
||||
String historyBreakRules = "";
|
||||
String vin = "";
|
||||
@@ -38,6 +39,7 @@ class MineController extends GetxController with BaseControllerMixin {
|
||||
String violationTotal = "0";
|
||||
String violationScore = "0";
|
||||
String violationDispose = "0";
|
||||
bool isNotice = false;
|
||||
|
||||
void renderData() async {
|
||||
if (StorageService.to.hasVehicleInfo) {
|
||||
@@ -56,6 +58,8 @@ class MineController extends GetxController with BaseControllerMixin {
|
||||
_fetchCompletionRate(), // 请求1:完成率
|
||||
_fetchAccidentCount(), // 请求2:事故数
|
||||
_fetchBreakRulesCount(), // 请求3:违章数
|
||||
_rating(), // 司机评分
|
||||
_msgNotice(), // 红点消息
|
||||
]);
|
||||
} catch (e, stackTrace) {
|
||||
showErrorToast("加载数据失败,请稍后重试 $e");
|
||||
@@ -65,6 +69,37 @@ class MineController extends GetxController with BaseControllerMixin {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _msgNotice() async {
|
||||
final Map<String, dynamic> requestData = {
|
||||
'appFlag': 1,
|
||||
'isRead': 1,
|
||||
'pageNum': 1,
|
||||
'pageSize': 5,
|
||||
};
|
||||
final response = await HttpService.to.get(
|
||||
'appointment/unread_notice/page',
|
||||
params: requestData,
|
||||
);
|
||||
if (response != null) {
|
||||
final result = BaseModel.fromJson(response.data);
|
||||
if (result.code == 0 && result.data != null) {
|
||||
int total = result.data["total"] ?? 0;
|
||||
isNotice = total > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _rating() async {
|
||||
final response = await HttpService.to.get('appointment/rating/driver');
|
||||
|
||||
if (response != null) {
|
||||
final result = BaseModel.fromJson(response.data);
|
||||
if (result.code == 0 && result.data != null) {
|
||||
rating = result.data.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _fetchCompletionRate() async {
|
||||
final response = await HttpService.to.get(
|
||||
'appointment/orderAddHyd/driverAppointmentCompletionRate?phone=${StorageService.to.phone}',
|
||||
|
||||
@@ -91,17 +91,19 @@ class MinePage extends GetView<MineController> {
|
||||
backgroundColor: Colors.grey[100],
|
||||
padding: const EdgeInsets.all(8),
|
||||
),
|
||||
icon: const Badge(
|
||||
icon: Badge(
|
||||
// label: Text('3'), // 如果你想显示数字,就加 label
|
||||
smallSize: 8, // 红点的大小
|
||||
backgroundColor: Colors.red, // 红点颜色
|
||||
smallSize: 8,
|
||||
// 红点的大小
|
||||
backgroundColor: controller.isNotice ? Colors.red : Colors.white,
|
||||
// 红点颜色
|
||||
child: Icon(
|
||||
Icons.notifications_outlined,
|
||||
color: Colors.black87,
|
||||
size: 25,
|
||||
),
|
||||
),
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -157,14 +159,14 @@ class MinePage extends GetView<MineController> {
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
CircularProgressIndicator(
|
||||
value: 10, // 假设得分80%
|
||||
value: (double.tryParse(controller.rating) ?? 0) / 10,
|
||||
strokeWidth: 8,
|
||||
backgroundColor: Colors.grey[200],
|
||||
valueColor: AlwaysStoppedAnimation<Color>(Colors.blue),
|
||||
),
|
||||
Center(
|
||||
child: Text(
|
||||
'10',
|
||||
controller.rating,
|
||||
style: TextStyle(
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.bold,
|
||||
@@ -329,7 +331,10 @@ class MinePage extends GetView<MineController> {
|
||||
|
||||
// 如果加载完成且有数据
|
||||
if (snapshot.hasData) {
|
||||
return TextX.labelSmall("当前版本: ${snapshot.data}",color: Colors.black54,);
|
||||
return TextX.labelSmall(
|
||||
"当前版本: ${snapshot.data}",
|
||||
color: Colors.black54,
|
||||
);
|
||||
}
|
||||
|
||||
// 错误处理
|
||||
@@ -338,7 +343,7 @@ class MinePage extends GetView<MineController> {
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user