- 同步商城 H5 登录态与原生 token - 完善商城/原生 tab 切换、动画及返回交互 - 修复七鱼客服键盘避让和状态栏恢复 - 调整开屏跳过按钮与登录入口交互
46 lines
1.2 KiB
Dart
46 lines
1.2 KiB
Dart
import 'package:dio/dio.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
|
|
import '../../../common/network/dio_provider.dart';
|
|
import '../../ads/data/ads_api_client.dart';
|
|
|
|
class AppMallAuthToken {
|
|
const AppMallAuthToken({
|
|
required this.authToken,
|
|
required this.expiresIn,
|
|
required this.sourceApp,
|
|
required this.scene,
|
|
});
|
|
|
|
final String authToken;
|
|
final int expiresIn;
|
|
final String sourceApp;
|
|
final String scene;
|
|
}
|
|
|
|
class MallAuthApi {
|
|
const MallAuthApi(this._dio);
|
|
final Dio _dio;
|
|
|
|
Future<AppMallAuthToken> issueAppMallAuthToken() async {
|
|
final response = await _dio.post<List<int>>(
|
|
'/api/v1/auth/mall/app-token',
|
|
data: const <int>[],
|
|
options: protobufOptions(),
|
|
);
|
|
final reply = ProtoMessage(response.data ?? const <int>[]);
|
|
final token = reply.string(1).trim();
|
|
if (token.isEmpty) throw const FormatException('Missing mall auth token');
|
|
return AppMallAuthToken(
|
|
authToken: token,
|
|
expiresIn: reply.integer(2),
|
|
sourceApp: reply.string(3),
|
|
scene: reply.string(4),
|
|
);
|
|
}
|
|
}
|
|
|
|
final mallAuthApiProvider = Provider(
|
|
(ref) => MallAuthApi(ref.watch(dioProvider)),
|
|
);
|