other_login_provider.dart
3.43 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import 'package:flutter/material.dart';
import 'package:one_key/constant/constant.dart';
import 'package:one_key/constant/state.dart';
import 'package:one_key/models/check_seller_acc_model.dart';
import 'package:one_key/models/checkbind_phone_model.dart';
import 'package:one_key/models/phone_code_model.dart';
import 'package:one_key/net/base_resp.dart';
import 'package:one_key/net/dio_util.dart';
import 'package:one_key/net/http_url.dart';
import 'package:one_key/utils/utils.dart';
/**
* 第三方登陆
*/
class OtherLoginProvider extends ChangeNotifier {
String code; //验证码
PhoneCodeSunModel phoneCodeSunModel;
PageState pageState = PageState.Loading; //是否有店铺
List<CheckSellerAccSunModel> sellerList = []; //绑定微信或者手机号码的商家列表
/// 给手机发送短信验证码
Future<bool> getPhoneCode(BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<Map<String, dynamic>> baseResp = await DioUtil()
.request<Map<String, dynamic>>(
context, Method.get, HttpUrl.send_vc_code,
data: params, showLoading: false)
.catchError((error) {});
if (baseResp.code == Constant.status_success) {
if (baseResp.data.isEmpty) {
return false;
} else {
//解析解析
phoneCodeSunModel = PhoneCodeModel.fromJson(baseResp.responseData).data;
return true;
}
} else {
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
return false;
}
}
/// APP微信登录后检测是否存在商家
Future<List<CheckSellerAccSunModel>> checkSellerAcc(
BuildContext context, Map<String, String> params,
{isShowLoading = true, showLoading = false}) async {
BaseResp<dynamic> baseResp = await DioUtil()
.request<dynamic>(context, Method.get, HttpUrl.check_seller_acc,
data: params,
showLoading: pageState == PageState.Loading ? false : showLoading)
.catchError((error) {
print(error);
});
if (baseResp.code == Constant.status_success) {
if (baseResp.data != null) {
//解析解析
pageState = PageState.Success;
sellerList = CheckSellerAccModel.fromJson(baseResp.responseData).data;
} else {
pageState = PageState.Empty;
}
} else {
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
pageState = PageState.ConnectivityError;
}
notifyListeners();
return sellerList;
}
/// APP微信登录后检测是否绑定过手机号
Future<CheckbindPhoneSunModel> checkbindPhone(
BuildContext context, Map<String, String> params,
{isShowLoading = true}) async {
BaseResp<Map<String, dynamic>> baseResp = await DioUtil()
.request<Map<String, dynamic>>(
context, Method.get, HttpUrl.check_bind_phone,
data: params, showLoading: false)
.catchError((error) {});
CheckbindPhoneSunModel checkbindPhoneSunModel;
if (baseResp.code == Constant.status_success) {
if (baseResp.data == null) {
return checkbindPhoneSunModel;
} else {
//解析解析
checkbindPhoneSunModel =
CheckbindPhoneModel.fromJson(baseResp.responseData).data;
return checkbindPhoneSunModel;
}
} else {
if (baseResp != null) {
Utils.showToast(baseResp.msg ?? "");
}
return checkbindPhoneSunModel;
}
}
}