AccountModel.java
5.4 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package com.hh.xuetubao.model;
import com.hh.xuetubao.MyServer;
import com.hh.xuetubao.Utils.BaseObsever;
import com.hh.xuetubao.Utils.HttpUtils;
import com.hh.xuetubao.Utils.NetConfig;
import com.hh.xuetubao.mvp.ICommonModel;
import com.hh.xuetubao.mvp.ICommonView;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
public class AccountModel implements ICommonModel {
private MyServer mServers;
@Override
public void getModel(ICommonView commonView, int api, int intent, String... params) {
mServers = HttpUtils.getInstance().getServer(NetConfig.accountUrl);
if (api == 1 && intent == 1) { // - > 验证码
sendValidateCode(commonView, api, intent, params);
}
if (api == 1 && intent == 2) { // - > 验证码登录
mobileLogin(commonView, api, intent, params);
}
if (api == 1 && intent == 3) { // - > 微信绑定手机号
bd_phone(commonView, api, intent, params);
}
if (api == 1 && intent == 4) { // - > 机构登录
jg_login(commonView, api, intent, params);
}
if (api == 1 && intent == 5) { // 忘记密码
forget_pas(commonView, api, intent, params);
}
if (api == 1 && intent == 6) { // 微信登录
weixin_login(commonView, api, intent, params);
}
}
/* 获取验证码 */
private void sendValidateCode(final ICommonView commonView, final int api, final int intent, String... params) {
if (api == 1 && intent == 1)
mServers.sendValidateCode(params[0], Integer.valueOf(params[1]))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new BaseObsever() {
@Override
public void onNext(Object value) {
super.onNext(value);
commonView.getData(value, api, intent);
}
});
}
/* 验证码登录 */
private void mobileLogin(final ICommonView commonView, final int api, final int intent, String... params) {
if (api == 1 && intent == 2)
mServers.mobileLogin(params[0], params[1], Integer.valueOf(params[2]))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new BaseObsever() {
@Override
public void onNext(Object value) {
super.onNext(value);
commonView.getData(value, api, intent);
}
});
}
/* 微信绑定手机号 */
private void bd_phone(final ICommonView commonView, final int api, final int tag, String... params) {
if (api == 1 && tag == 3) {
mServers.bd_phone(params[0], params[1], params[2])
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new BaseObsever() {
@Override
public void onNext(Object value) {
super.onNext(value);
commonView.getData(value, api, tag);
}
});
}
}
/* 机构登录 */
private void jg_login(final ICommonView commonView, final int api, final int tag, String... params) {
if (api == 1 && tag == 4) {
mServers.AccountLogin(params[0], params[1], Integer.valueOf(params[2]))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new BaseObsever() {
@Override
public void onNext(Object value) {
super.onNext(value);
commonView.getData(value, api, tag);
}
});
}
}
/* 忘记密码 */
private void forget_pas(final ICommonView commonView, final int api, final int tag, String... params) {
if (api == 1 && tag == 5) {
mServers.Forget_Pas(params[0], params[1], params[2])
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new BaseObsever() {
@Override
public void onNext(Object value) {
super.onNext(value);
commonView.getData(value, api, tag);
}
});
}
}
/* 微信登录 */
private void weixin_login(final ICommonView commonView, final int api, final int tag, String... params) {
if(api ==1 && tag == 6){
mServers.WeixinLogin(params[0], Integer.valueOf(params[1]))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new BaseObsever() {
@Override
public void onNext(Object value) {
super.onNext(value);
commonView.getData(value, api, tag);
}
});
}
}
}