94342c3f
Key
feat: user util
|
1
|
import 'package:wow_english/common/core/user_util.dart';
|
05f9b20a
Key
fixed: api调用方式,未完善
|
2
3
|
import 'package:wow_english/models/user_entity.dart';
|
056970d8
Key
feat: api
|
4
|
import '../apis.dart';
|
056970d8
Key
feat: api
|
5
6
7
|
import '../request_client.dart';
class UserDao {
|
c95453ce
Key
feat: User界面完善
|
8
|
/// 登录
|
94342c3f
Key
feat: user util
|
9
|
static Future<UserEntity?> login(phoneNumber, type, checkKey, checkNumber) async {
|
05f9b20a
Key
fixed: api调用方式,未完善
|
10
|
var params = {'phoneNum': phoneNumber, 'type': type, checkKey: checkNumber};
|
94342c3f
Key
feat: user util
|
11
|
var data = await requestClient.post<UserEntity>(
|
05f9b20a
Key
fixed: api调用方式,未完善
|
12
13
14
|
Apis.login,
data: params,
);
|
94342c3f
Key
feat: user util
|
15
16
17
|
if (data != null && data.token.isNotEmpty) {
UserUtil.saveUser(data);
}
|
05f9b20a
Key
fixed: api调用方式,未完善
|
18
|
return data;
|
056970d8
Key
feat: api
|
19
|
}
|
39e06486
liangchengyou
feat:获取验证码逻辑处理
|
20
|
|
c95453ce
Key
feat: User界面完善
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
/// 登出
static Future logout() async {
var result = await requestClient.post(Apis.logout);
print('logout result=$result');
UserUtil.logout();
return result;
}
/// 发送验证码
static Future sendCode(phoneNumber, {smsType = 'login'}) async {
final params = {'phoneNum': phoneNumber, 'smsType': smsType};
await requestClient.post(Apis.sendSmsCode, data: params);
}
/// 获取用户信息
static Future<UserEntity?> getUserInfo() async {
return await requestClient.post(Apis.getUserInfo);
}
/// 更新用户信息,返回即成功,无body
static Future updateUserInfo(UserEntity userEntity) async {
return await requestClient.put(Apis.setUserInfo, data: userEntity.toUpdateJson());
|
39e06486
liangchengyou
feat:获取验证码逻辑处理
|
43
|
}
|
056970d8
Key
feat: api
|
44
|
}
|