Jolie 3 months ago
parent
commit
dd759aff35
7 changed files with 83 additions and 8 deletions
  1. 2
      lib/controller/discover/room_controller.dart
  2. 4
      lib/controller/mine/my_friend_controller.dart
  3. 7
      lib/controller/setting/spread_controller.dart
  4. 4
      lib/network/api_urls.dart
  5. 20
      lib/network/network_config.dart
  6. 10
      lib/network/user_api.dart
  7. 44
      lib/network/user_api.g.dart

2
lib/controller/discover/room_controller.dart

@ -183,6 +183,8 @@ class RoomController extends GetxController with WidgetsBindingObserver {
}
Future<void> joinChat(CurrentRole role) async {
final granted = await _ensureRtcPermissions();
if (!granted) return;
final data = {
'channelId': RTCManager.instance.currentChannelId,
'seatNumber': role == CurrentRole.maleAudience ? 1 : 2,

4
lib/controller/mine/my_friend_controller.dart

@ -14,4 +14,8 @@ class MyFriendController extends GetxController with GetSingleTickerProviderStat
tabController = TabController(length: 4, vsync: this);
}
getFriendList() async {
}
}

7
lib/controller/setting/spread_controller.dart

@ -139,8 +139,11 @@ class SpreadController extends GetxController with WidgetsBindingObserver {
final response = await _userApi.getChatStaticsInfo();
if (response.data.isSuccess && response.data.data != null) {
final data = response.data.data!;
if(data.liveDurationMins >= 600 && !matchmakerFlag.value){
canApply = true;
if(roseList[activePay.value].liveDurationHours != null){
int hours = int.parse(roseList[activePay.value].liveDurationHours!);
if(hours > 0 && data.liveDurationMins >= 60 * hours && !matchmakerFlag.value){
canApply = true;
}
}
}
} catch (e) {

4
lib/network/api_urls.dart

@ -87,7 +87,9 @@ class ApiUrls {
static const String getDongwoMarriageInformationDetail =
'dating-agency-service/user/get/dongwo/marriage-information-detail';
static const String getPaymentOrderDetail =
'/dating-agency-mall/user/get/payment-order/detail';
'dating-agency-mall/user/get/payment-order/detail';
static const String userPageFriendRelation =
'dating-agency-chat-audio/user/page/friend-relation';
//
static const String getMarriageList =

20
lib/network/network_config.dart

@ -1,3 +1,6 @@
import 'package:dating_touchme_app/controller/global.dart';
import 'package:dating_touchme_app/controller/message/conversation_controller.dart';
import 'package:dating_touchme_app/im/im_manager.dart';
import 'package:dio/dio.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart' hide Response;
@ -91,6 +94,9 @@ class ResponseInterceptor extends Interceptor {
if (code == 0) {
//
handler.next(response);
} else if(code == 401) {
_showError("登录已过期,请重新登录");
_handleTokenExpired();
} else {
//
final message = data['message'] ?? '请求失败';
@ -150,10 +156,20 @@ class ResponseInterceptor extends Interceptor {
SmartDialog.showToast(message, displayTime: const Duration(seconds: 2));
}
void _handleTokenExpired() {
void _handleTokenExpired() async {
// token过期逻辑
// 使Get.offAllNamed('/login')
GetStorage().remove('token');
// 退 IM
await IMManager.instance.logout();
//
if (Get.isRegistered<ConversationController>()) {
final conversationController = Get.find<ConversationController>();
conversationController.clearConversations();
}
//
GetStorage().erase();
//
GlobalData().logout();
Get.offAll(() => LoginPage());
}
}

10
lib/network/user_api.dart

@ -201,7 +201,15 @@ abstract class UserApi {
}
);
@GET(ApiUrls.getHxUserToken)
@GET(ApiUrls.getChatVideoStatics)
Future<HttpResponse<BaseResponse<ChatStaticData>>> getChatStaticsInfo();
@GET(ApiUrls.userPageFriendRelation)
Future<HttpResponse<BaseResponse<WithdrawAuditData>>> userPageFriendRelation(
{
@Query('pageNum') required int pageNum,
@Query('pageSize') required int pageSize,
}
);
}

44
lib/network/user_api.g.dart

@ -1211,7 +1211,7 @@ class _UserApi implements UserApi {
Options(method: 'GET', headers: _headers, extra: _extra)
.compose(
_dio.options,
'/dating-agency-mall/user/get/payment-order/detail',
'dating-agency-mall/user/get/payment-order/detail',
queryParameters: queryParameters,
data: _data,
)
@ -1245,7 +1245,7 @@ class _UserApi implements UserApi {
Options(method: 'GET', headers: _headers, extra: _extra)
.compose(
_dio.options,
'dating-agency-chat-audio/user/get/hx/user/token',
'dating-agency-chat-audio/user/get/own-user-management',
queryParameters: queryParameters,
data: _data,
)
@ -1266,6 +1266,46 @@ class _UserApi implements UserApi {
return httpResponse;
}
@override
Future<HttpResponse<BaseResponse<WithdrawAuditData>>> userPageFriendRelation({
required int pageNum,
required int pageSize,
}) async {
final _extra = <String, dynamic>{};
final queryParameters = <String, dynamic>{
r'pageNum': pageNum,
r'pageSize': pageSize,
};
final _headers = <String, dynamic>{};
const Map<String, dynamic>? _data = null;
final _options =
_setStreamType<HttpResponse<BaseResponse<WithdrawAuditData>>>(
Options(method: 'GET', headers: _headers, extra: _extra)
.compose(
_dio.options,
'dating-agency-chat-audio/user/page/friend-relation',
queryParameters: queryParameters,
data: _data,
)
.copyWith(
baseUrl: _combineBaseUrls(_dio.options.baseUrl, baseUrl),
),
);
final _result = await _dio.fetch<Map<String, dynamic>>(_options);
late BaseResponse<WithdrawAuditData> _value;
try {
_value = BaseResponse<WithdrawAuditData>.fromJson(
_result.data!,
(json) => WithdrawAuditData.fromJson(json as Map<String, dynamic>),
);
} on Object catch (e, s) {
errorLogger?.logError(e, s, _options);
rethrow;
}
final httpResponse = HttpResponse(_value, _result);
return httpResponse;
}
RequestOptions _setStreamType<T>(RequestOptions requestOptions) {
if (T != dynamic &&
!(requestOptions.responseType == ResponseType.bytes ||

Loading…
Cancel
Save