wechat_auth_repository.dart
993 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import 'package:appframe/config/locator.dart';
import 'package:appframe/services/api_service.dart';
import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
class WechatAuthRepository {
late final ApiService _apiService;
WechatAuthRepository() {
_apiService = getIt<ApiService>(instanceName: 'bxeApiService');
}
Future<dynamic> codeToSk(String code) async {
Response resp = await _apiService.post(
'/login/applet/wkbxe/codeToSkByApp?version=1.0.0',
{
"appCode": "bxeapp",
"params": {"code": code},
},
);
debugPrint('登录结果: $resp');
return resp.statusCode == 200 ? resp.data : null;
}
Future<dynamic> getTicket() async {
Response resp = await _apiService.post(
'/login/applet/wkbxe/getTicketByApp?version=1.0.0',
{
"appCode": "bxeapp",
"params": {},
},
);
debugPrint('获取ticket: $resp');
return resp.statusCode == 200 ? resp.data : null;
}
}