浏览代码

2024-2-28 代码备份
手机号验证码登录页面绑定邀请人功能完成
提现页面接口调整部分完成

zhangbing 2 年之前
父节点
当前提交
27e58e1f06

+ 8 - 0
app/src/main/java/com/yihucha/hbyhc/network/service/AuthService.java

@@ -4,6 +4,7 @@ import com.yihucha.hbyhc.network.BaseResponse;
4
 import com.yihucha.hbyhc.network.DataJavaResponse;
4
 import com.yihucha.hbyhc.network.DataJavaResponse;
5
 import com.yihucha.hbyhc.network.DataResponse;
5
 import com.yihucha.hbyhc.network.DataResponse;
6
 import com.yihucha.hbyhc.presentation.login.model.LoginModel;
6
 import com.yihucha.hbyhc.presentation.login.model.LoginModel;
7
+import com.yihucha.hbyhc.presentation.login.model.UidAndPhoneBean;
7
 import com.yihucha.hbyhc.presentation.mine.model.UpdateAccountBean;
8
 import com.yihucha.hbyhc.presentation.mine.model.UpdateAccountBean;
8
 import com.yihucha.hbyhc.presentation.mine.model.WechatOpenIdBean;
9
 import com.yihucha.hbyhc.presentation.mine.model.WechatOpenIdBean;
9
 
10
 
@@ -12,6 +13,7 @@ import java.util.Map;
12
 import io.reactivex.Observable;
13
 import io.reactivex.Observable;
13
 import retrofit2.http.GET;
14
 import retrofit2.http.GET;
14
 import retrofit2.http.POST;
15
 import retrofit2.http.POST;
16
+import retrofit2.http.Query;
15
 import retrofit2.http.QueryMap;
17
 import retrofit2.http.QueryMap;
16
 
18
 
17
 /**
19
 /**
@@ -95,6 +97,12 @@ public interface AuthService {
95
      */
97
      */
96
     @POST("api/user/updateAccount")
98
     @POST("api/user/updateAccount")
97
     Observable<DataResponse> getUpdateAccount(@QueryMap Map<String, Object> request);
99
     Observable<DataResponse> getUpdateAccount(@QueryMap Map<String, Object> request);
100
+
101
+    /**
102
+     *
103
+     */
104
+    @POST("api/auth/query_uid")
105
+    Observable<DataResponse<UidAndPhoneBean>> getUidByPhone(@Query("phone")String phone);
98
 }
106
 }
99
 
107
 
100
 
108
 

+ 3 - 1
app/src/main/java/com/yihucha/hbyhc/presentation/invitation/AddBankCardActivity.kt

@@ -44,7 +44,9 @@ class AddBankCardActivity : ViewBindingTitleBaseActivity<ActivityAddBankCardBind
44
     }
44
     }
45
 
45
 
46
     private fun initView() {
46
     private fun initView() {
47
-        bankCardBean = intent.getSerializableExtra("beans") as BankCardBean
47
+        intent.getSerializableExtra("beans")?.apply {
48
+            bankCardBean = this as BankCardBean
49
+        }
48
         mViewBinding.apply {
50
         mViewBinding.apply {
49
             EditTextListener.onTextListener(edtUserName) {
51
             EditTextListener.onTextListener(edtUserName) {
50
                 userNameEmpty = it
52
                 userNameEmpty = it

+ 81 - 98
app/src/main/java/com/yihucha/hbyhc/presentation/invitation/ImmediateWithdrawalActivity.java

@@ -38,6 +38,8 @@ import com.yihucha.hbyhc.presentation.mine.model.UpdateAccountBean;
38
 import com.yihucha.hbyhc.presentation.mine.model.UserAnnuityInfoBean;
38
 import com.yihucha.hbyhc.presentation.mine.model.UserAnnuityInfoBean;
39
 import com.yihucha.hbyhc.presentation.mine.model.UserInfoModel;
39
 import com.yihucha.hbyhc.presentation.mine.model.UserInfoModel;
40
 import com.yihucha.hbyhc.presentation.mine.view_model.BindingStateBViewModel;
40
 import com.yihucha.hbyhc.presentation.mine.view_model.BindingStateBViewModel;
41
+import com.yihucha.hbyhc.presentation.mine.view_model.MineSpreadInfo;
42
+import com.yihucha.hbyhc.presentation.mine.view_model.MineViewModel;
41
 import com.yihucha.hbyhc.utils.EmptyCheckUtils;
43
 import com.yihucha.hbyhc.utils.EmptyCheckUtils;
42
 import com.yihucha.hbyhc.utils.LogUtil;
44
 import com.yihucha.hbyhc.utils.LogUtil;
43
 import com.yihucha.hbyhc.utils.StringsUtil;
45
 import com.yihucha.hbyhc.utils.StringsUtil;
@@ -73,6 +75,8 @@ public class ImmediateWithdrawalActivity extends ViewBindingTitleBaseActivity<Ac
73
     private boolean isRed = false;
75
     private boolean isRed = false;
74
     private volatile boolean isShow = false;
76
     private volatile boolean isShow = false;
75
     private BindingStateBViewModel mBindingStateBViewModel;
77
     private BindingStateBViewModel mBindingStateBViewModel;
78
+    private MineViewModel mineViewModel;
79
+    private MineSpreadInfo mineSpreadInfo;//用户信息数据
76
     @SuppressLint("HandlerLeak")
80
     @SuppressLint("HandlerLeak")
77
     private Handler mHandler = new Handler() {
81
     private Handler mHandler = new Handler() {
78
         @SuppressWarnings("unused")
82
         @SuppressWarnings("unused")
@@ -124,10 +128,12 @@ public class ImmediateWithdrawalActivity extends ViewBindingTitleBaseActivity<Ac
124
     };
128
     };
125
 
129
 
126
 
130
 
131
+
127
     @Override
132
     @Override
128
     protected void onCreate(Bundle savedInstanceState) {
133
     protected void onCreate(Bundle savedInstanceState) {
129
         super.onCreate(savedInstanceState);
134
         super.onCreate(savedInstanceState);
130
         mInviteViewModel = new ViewModelProvider(this).get(InviteViewModel.class);
135
         mInviteViewModel = new ViewModelProvider(this).get(InviteViewModel.class);
136
+        mineViewModel = new ViewModelProvider(this).get(MineViewModel.class);
131
         mBindingStateBViewModel = new ViewModelProvider(this).get(BindingStateBViewModel.class);
137
         mBindingStateBViewModel = new ViewModelProvider(this).get(BindingStateBViewModel.class);
132
         Bundle data = getIntent().getBundleExtra("data");
138
         Bundle data = getIntent().getBundleExtra("data");
133
         //保持提现页面一致,暂时隐藏该部分
139
         //保持提现页面一致,暂时隐藏该部分
@@ -143,70 +149,61 @@ public class ImmediateWithdrawalActivity extends ViewBindingTitleBaseActivity<Ac
143
     private void initData() {
149
     private void initData() {
144
         //佣金信息
150
         //佣金信息
145
         mInviteViewModel.getSpreadInfo();
151
         mInviteViewModel.getSpreadInfo();
146
-        mInviteViewModel.mSpreadInfoData.observe(this, new Observer<SpreadInfoBean>() {
147
-            @Override
148
-            public void onChanged(SpreadInfoBean spreadInfoBean) {
149
-                mBrokeragePrice = spreadInfoBean.getBrokerage_price();
150
-                mViewBinding.tvBrokeragePrice.setText("可用余额:¥" + mBrokeragePrice);
151
-                mMemberBrokeragePrice = spreadInfoBean.getMember_brokerage_price();
152
-                mViewBinding.tvRedIntegral.setText("可提现金额:" + mMemberBrokeragePrice);
153
-                try {
154
-                    if (mWithdrawal_money != null && !isShow) {
155
-                        if ((Double.parseDouble(mBrokeragePrice) < Double.parseDouble(mWithdrawal_money))) {
156
-                            Toast toast = Toast.makeText(context, "满" + mWithdrawal_money + "才可以提现~", Toast.LENGTH_SHORT);
157
-                            toast.setGravity(Gravity.CENTER, 0, 0);
158
-                            toast.show();
159
-                        }
160
-                        isShow = true;
152
+        mInviteViewModel.mSpreadInfoData.observe(this, spreadInfoBean -> {
153
+            mBrokeragePrice = spreadInfoBean.getBrokerage_price();
154
+            mViewBinding.tvBrokeragePrice.setText("可用余额:¥" + mBrokeragePrice);
155
+            mMemberBrokeragePrice = spreadInfoBean.getMember_brokerage_price();
156
+            mViewBinding.tvRedIntegral.setText("可提现金额:" + mMemberBrokeragePrice);
157
+            try {
158
+                if (mWithdrawal_money != null && !isShow) {
159
+                    if ((Double.parseDouble(mBrokeragePrice) < Double.parseDouble(mWithdrawal_money))) {
160
+                        Toast toast = Toast.makeText(context, "满" + mWithdrawal_money + "才可以提现~", Toast.LENGTH_SHORT);
161
+                        toast.setGravity(Gravity.CENTER, 0, 0);
162
+                        toast.show();
161
                     }
163
                     }
162
-                } catch (Exception e) {
163
-
164
+                    isShow = true;
164
                 }
165
                 }
166
+            } catch (Exception e) {
167
+
165
             }
168
             }
166
         });
169
         });
167
         mBindingStateBViewModel.getBindingState();
170
         mBindingStateBViewModel.getBindingState();
168
 //        mInviteViewModel.getBandAccountInfo(type, "");
171
 //        mInviteViewModel.getBandAccountInfo(type, "");
169
-        mBindingStateBViewModel.mBindingStateBean.observe(this, new Observer<List<BindingStateBean>>() {
170
-            @Override
171
-            public void onChanged(List<BindingStateBean> bindingStateBeans) {
172
-                for (int i = 0; i < bindingStateBeans.size(); i++) {
173
-                    if (bindingStateBeans.get(i).getType().equals("1")) {
174
-                        type = "1";
175
-                        mViewBinding.tvClickToAccredit.setText("已授权,点击可修改");
172
+        mBindingStateBViewModel.mBindingStateBean.observe(this, bindingStateBeans -> {
173
+            for (int i = 0; i < bindingStateBeans.size(); i++) {
174
+                if (bindingStateBeans.get(i).getType().equals("1")) {
175
+                    type = "1";
176
+                    mViewBinding.tvClickToAccredit.setText("已授权,点击可修改");
176
 //                        mViewBinding.ivWx.setImageResource(R.mipmap.shopping_selected);
177
 //                        mViewBinding.ivWx.setImageResource(R.mipmap.shopping_selected);
177
 //                        mViewBinding.ivZfb.setImageResource(R.mipmap.shopping_unselected);
178
 //                        mViewBinding.ivZfb.setImageResource(R.mipmap.shopping_unselected);
178
-                    } else if (bindingStateBeans.get(i).getType().equals("2")) {
179
-                        type = "2";
179
+                } else if (bindingStateBeans.get(i).getType().equals("2")) {
180
+                    type = "2";
180
 //                        mViewBinding.ivZfb.setImageResource(R.mipmap.shopping_selected);
181
 //                        mViewBinding.ivZfb.setImageResource(R.mipmap.shopping_selected);
181
 //                        mViewBinding.ivWx.setImageResource(R.mipmap.shopping_unselected);
182
 //                        mViewBinding.ivWx.setImageResource(R.mipmap.shopping_unselected);
182
-                        break;
183
-                    }
183
+                    break;
184
                 }
184
                 }
185
             }
185
             }
186
         });
186
         });
187
         //提现配置
187
         //提现配置
188
         mInviteViewModel.getConfig();
188
         mInviteViewModel.getConfig();
189
-        mInviteViewModel.mWithdrawalConfigurationData.observe(this, new Observer<WithdrawalConfigurationBean>() {
190
-            @Override
191
-            public void onChanged(WithdrawalConfigurationBean withdrawalConfigurationBean) {
192
-                mWithdrawal_money = withdrawalConfigurationBean.getWithdrawal_money();
193
-                mWithdrawal_alipay = withdrawalConfigurationBean.getWithdrawal_alipay();
194
-                mWithdrawal_wchat = withdrawalConfigurationBean.getWithdrawal_wchat();
195
-                mWithdrawal_status = withdrawalConfigurationBean.getWithdrawal_status();
196
-                try {
197
-                    if (mBrokeragePrice != null && !isShow) {
198
-                        if ((Double.parseDouble(mBrokeragePrice) < Double.parseDouble(mWithdrawal_money))) {
199
-                            Toast toast = Toast.makeText(context, "满" + mWithdrawal_money + "才可以提现~", Toast.LENGTH_SHORT);
200
-                            toast.setGravity(Gravity.CENTER, 0, 0);
201
-                            toast.show();
202
-                        }
203
-                        isShow = true;
189
+        mInviteViewModel.mWithdrawalConfigurationData.observe(this, withdrawalConfigurationBean -> {
190
+            mWithdrawal_money = withdrawalConfigurationBean.getWithdrawal_money();
191
+            mWithdrawal_alipay = withdrawalConfigurationBean.getWithdrawal_alipay();
192
+            mWithdrawal_wchat = withdrawalConfigurationBean.getWithdrawal_wchat();
193
+            mWithdrawal_status = withdrawalConfigurationBean.getWithdrawal_status();
194
+            try {
195
+                if (mBrokeragePrice != null && !isShow) {
196
+                    if ((Double.parseDouble(mBrokeragePrice) < Double.parseDouble(mWithdrawal_money))) {
197
+                        Toast toast = Toast.makeText(context, "满" + mWithdrawal_money + "才可以提现~", Toast.LENGTH_SHORT);
198
+                        toast.setGravity(Gravity.CENTER, 0, 0);
199
+                        toast.show();
204
                     }
200
                     }
205
-                } catch (Exception e) {
206
-
201
+                    isShow = true;
207
                 }
202
                 }
203
+            } catch (Exception e) {
208
 
204
 
209
             }
205
             }
206
+
210
         });
207
         });
211
         //提现检测是否绑定提交账户接口数据
208
         //提现检测是否绑定提交账户接口数据
212
         mInviteViewModel.mBandAccountInfoSucceed.observe(this, s -> {
209
         mInviteViewModel.mBandAccountInfoSucceed.observe(this, s -> {
@@ -236,58 +233,39 @@ public class ImmediateWithdrawalActivity extends ViewBindingTitleBaseActivity<Ac
236
         });
233
         });
237
         mInviteViewModel.getWithdrawalService("0");
234
         mInviteViewModel.getWithdrawalService("0");
238
         //提现服务费计算
235
         //提现服务费计算
239
-        mInviteViewModel.mWithdrawalServiceData.observe(this, new Observer<WithdrawalServiceBean>() {
240
-            @Override
241
-            public void onChanged(WithdrawalServiceBean withdrawalServiceBean) {
242
-                mViewBinding.tvService.setText("平台服务费 ¥" + withdrawalServiceBean.getService());
243
-                mViewBinding.tvServiceMoney.setText("本次提取将扣除服务费 ¥" + withdrawalServiceBean.getService_money());
244
-                mViewBinding.tvMoney.setText("本次提取实际到账额度 ¥" + withdrawalServiceBean.getMoney());
245
-            }
236
+        mInviteViewModel.mWithdrawalServiceData.observe(this, withdrawalServiceBean -> {
237
+            mViewBinding.tvService.setText("平台服务费 ¥" + withdrawalServiceBean.getService());
238
+            mViewBinding.tvServiceMoney.setText("本次提取将扣除服务费 ¥" + withdrawalServiceBean.getService_money());
239
+            mViewBinding.tvMoney.setText("本次提取实际到账额度 ¥" + withdrawalServiceBean.getMoney());
246
         });
240
         });
247
         //支付宝授权链接
241
         //支付宝授权链接
248
-        mInviteViewModel.mAuthInfoSucceed.observe(this, new Observer<String>() {
249
-            @Override
250
-            public void onChanged(String s) {
251
-                Runnable authRunnable = new Runnable() {
252
-                    @Override
253
-                    public void run() {
254
-                        // 构造AuthTask 对象
255
-                        AuthTask authTask = new AuthTask(ImmediateWithdrawalActivity.this);
256
-                        // 调用授权接口,获取授权结果
257
-                        Map<String, String> result = authTask.authV2(s, true);
258
-                        Message msg = new Message();
259
-                        msg.what = SDK_AUTH_FLAG;
260
-                        msg.obj = result;
261
-                        mHandler.sendMessage(msg);
262
-                    }
263
-                };
242
+        mInviteViewModel.mAuthInfoSucceed.observe(this, s -> {
243
+            Runnable authRunnable = new Runnable() {
244
+                @Override
245
+                public void run() {
246
+                    // 构造AuthTask 对象
247
+                    AuthTask authTask = new AuthTask(ImmediateWithdrawalActivity.this);
248
+                    // 调用授权接口,获取授权结果
249
+                    Map<String, String> result = authTask.authV2(s, true);
250
+                    Message msg = new Message();
251
+                    msg.what = SDK_AUTH_FLAG;
252
+                    msg.obj = result;
253
+                    mHandler.sendMessage(msg);
254
+                }
255
+            };
264
 
256
 
265
-                // 必须异步调用
266
-                Thread authThread = new Thread(authRunnable);
267
-                authThread.start();
268
-            }
269
-        });
270
-        mInviteViewModel.mUpdateAccountData.observe(this, new Observer<UpdateAccountBean>() {
271
-            @Override
272
-            public void onChanged(UpdateAccountBean updateAccountBean) {
273
-                mInviteViewModel.getBandAccountInfo(type, "");
274
-            }
257
+            // 必须异步调用
258
+            Thread authThread = new Thread(authRunnable);
259
+            authThread.start();
275
         });
260
         });
261
+        mInviteViewModel.mUpdateAccountData.observe(this, updateAccountBean -> mInviteViewModel.getBandAccountInfo(type, ""));
276
         //养老金信息
262
         //养老金信息
277
-        mInviteViewModel.userAnnuityInfoBeanMutableLiveData.observe(this, new Observer<UserAnnuityInfoBean>() {
278
-            @Override
279
-            public void onChanged(UserAnnuityInfoBean userAnnuityInfoBean) {
280
-                is_certification = userAnnuityInfoBean.getIs_certification();
281
-            }
282
-        });
263
+        mInviteViewModel.userAnnuityInfoBeanMutableLiveData.observe(this, userAnnuityInfoBean -> is_certification = userAnnuityInfoBean.getIs_certification());
283
 
264
 
284
-        mInviteViewModel.mApplicationWithdrawal.observe(this, new Observer<String>() {
285
-            @Override
286
-            public void onChanged(String s) {
287
-                ToastUtils.showLong(s);
288
-                //提现成功
289
-                WithdrawalRecordActivity.launch(context);
290
-            }
265
+        mInviteViewModel.mApplicationWithdrawal.observe(this, s -> {
266
+            ToastUtils.showLong(s);
267
+            //提现成功
268
+            WithdrawalRecordActivity.launch(context);
291
         });
269
         });
292
         mInviteViewModel.bankCardList.observe(this, bankCardBeans -> {
270
         mInviteViewModel.bankCardList.observe(this, bankCardBeans -> {
293
             if (EmptyCheckUtils.isEmpty(bankCardBeans)) {
271
             if (EmptyCheckUtils.isEmpty(bankCardBeans)) {
@@ -300,6 +278,12 @@ public class ImmediateWithdrawalActivity extends ViewBindingTitleBaseActivity<Ac
300
                 mViewBinding.tvClickToSelectCard.setText("点击可修改银行卡信息");
278
                 mViewBinding.tvClickToSelectCard.setText("点击可修改银行卡信息");
301
             }
279
             }
302
         });
280
         });
281
+
282
+        mineViewModel.getSpreadInfoYhc();
283
+        mineViewModel.spreadInfo.observe(this,mineSpreadInfo -> {
284
+            this.mineSpreadInfo = mineSpreadInfo;
285
+        });
286
+
303
         mInviteViewModel.failed.observe(this, s -> ToastUtils.showLong(s));
287
         mInviteViewModel.failed.observe(this, s -> ToastUtils.showLong(s));
304
 
288
 
305
 
289
 
@@ -386,6 +370,10 @@ public class ImmediateWithdrawalActivity extends ViewBindingTitleBaseActivity<Ac
386
                 mViewBinding.etCashWithdrawalAmount.setText(mBrokeragePrice);
370
                 mViewBinding.etCashWithdrawalAmount.setText(mBrokeragePrice);
387
             }
371
             }
388
         } else if (v == mViewBinding.tvImmediateWithdrawal) {
372
         } else if (v == mViewBinding.tvImmediateWithdrawal) {
373
+            if ("0".equals(mineSpreadInfo.getIdentity())){
374
+                ToastUtils.showLong("需要您升级为合伙人");
375
+                return;
376
+            }
389
             if ("0".equals(mWithdrawal_status)) {
377
             if ("0".equals(mWithdrawal_status)) {
390
                 ToastUtils.showLong("提现功能关闭");
378
                 ToastUtils.showLong("提现功能关闭");
391
                 return;
379
                 return;
@@ -407,7 +395,7 @@ public class ImmediateWithdrawalActivity extends ViewBindingTitleBaseActivity<Ac
407
                 return;
395
                 return;
408
             }
396
             }
409
             if (type.equals("")) {
397
             if (type.equals("")) {
410
-                ToastUtils.showLong("选提现方式");
398
+                ToastUtils.showLong("请先勾选提现方式");
411
                 return;
399
                 return;
412
             }
400
             }
413
             double tixian = Double.parseDouble(mViewBinding.etCashWithdrawalAmount.getText().toString());
401
             double tixian = Double.parseDouble(mViewBinding.etCashWithdrawalAmount.getText().toString());
@@ -440,7 +428,7 @@ public class ImmediateWithdrawalActivity extends ViewBindingTitleBaseActivity<Ac
440
                 RealNameAuthenticationActivity.launch(context);
428
                 RealNameAuthenticationActivity.launch(context);
441
                 return;
429
                 return;
442
             }
430
             }
443
-
431
+            //TODO 这里如果是银行卡提现,需要弹窗获取验证码,然后输入验证码后进行提现此操作
444
             //立即提现
432
             //立即提现
445
             mInviteViewModel.getApplicationWithdrawal(mViewBinding.etCashWithdrawalAmount.getText().toString(), type, isRed);
433
             mInviteViewModel.getApplicationWithdrawal(mViewBinding.etCashWithdrawalAmount.getText().toString(), type, isRed);
446
         } else if (v == mViewBinding.llWx) {
434
         } else if (v == mViewBinding.llWx) {
@@ -470,11 +458,6 @@ public class ImmediateWithdrawalActivity extends ViewBindingTitleBaseActivity<Ac
470
             AddBankCardActivity.launch(this, bankCardBean);
458
             AddBankCardActivity.launch(this, bankCardBean);
471
         } else if (v == mViewBinding.llYhk) {
459
         } else if (v == mViewBinding.llYhk) {
472
             //选中银行卡
460
             //选中银行卡
473
-/*            if (EmptyCheckUtils.isNotEmpty(bankCardBean)) {
474
-
475
-            }else {
476
-
477
-            }*/
478
             type = "3";
461
             type = "3";
479
             mViewBinding.ivWx.setVisibility(View.INVISIBLE);
462
             mViewBinding.ivWx.setVisibility(View.INVISIBLE);
480
             mViewBinding.ivYhk.setVisibility(View.VISIBLE);
463
             mViewBinding.ivYhk.setVisibility(View.VISIBLE);

+ 78 - 66
app/src/main/java/com/yihucha/hbyhc/presentation/login/LoginActivity.java

@@ -15,6 +15,7 @@ import androidx.lifecycle.Observer;
15
 import androidx.lifecycle.ViewModelProvider;
15
 import androidx.lifecycle.ViewModelProvider;
16
 
16
 
17
 
17
 
18
+import com.blankj.utilcode.util.ToastUtils;
18
 import com.yihucha.hbyhc.R;
19
 import com.yihucha.hbyhc.R;
19
 import com.yihucha.hbyhc.base.ActivityStack;
20
 import com.yihucha.hbyhc.base.ActivityStack;
20
 import com.yihucha.hbyhc.base.ViewBindingTitleBaseActivity;
21
 import com.yihucha.hbyhc.base.ViewBindingTitleBaseActivity;
@@ -36,7 +37,7 @@ import java.util.ArrayList;
36
 import java.util.List;
37
 import java.util.List;
37
 
38
 
38
 public class LoginActivity extends ViewBindingTitleBaseActivity<ActivityLoginPhoneBinding> implements View.OnClickListener {
39
 public class LoginActivity extends ViewBindingTitleBaseActivity<ActivityLoginPhoneBinding> implements View.OnClickListener {
39
-    private static final String INTENT_OPEN_ID="intentOpenId";
40
+    private static final String INTENT_OPEN_ID = "intentOpenId";
40
     LoginViewModel loginViewModel;
41
     LoginViewModel loginViewModel;
41
     private CountDownTimeUtil mCountDownTimeUtil;
42
     private CountDownTimeUtil mCountDownTimeUtil;
42
 
43
 
@@ -44,17 +45,18 @@ public class LoginActivity extends ViewBindingTitleBaseActivity<ActivityLoginPho
44
     private String mPhone;//手机号
45
     private String mPhone;//手机号
45
 
46
 
46
     private LoginModel loginModel;
47
     private LoginModel loginModel;
47
-    private  String mOpenId;//微信code
48
+    private String mOpenId;//微信code
49
+
48
     @Override
50
     @Override
49
     protected void onCreate(Bundle savedInstanceState) {
51
     protected void onCreate(Bundle savedInstanceState) {
50
         super.onCreate(savedInstanceState);
52
         super.onCreate(savedInstanceState);
51
 //        setContentView(R.layout.activity_login_phone);
53
 //        setContentView(R.layout.activity_login_phone);
52
-         mOpenId=getIntent().getStringExtra(INTENT_OPEN_ID);
54
+        mOpenId = getIntent().getStringExtra(INTENT_OPEN_ID);
53
         //绑定
55
         //绑定
54
-        loginViewModel=new ViewModelProvider(this).get(LoginViewModel.class);
55
-         initView();
56
-         initClick();
57
-         initData();
56
+        loginViewModel = new ViewModelProvider(this).get(LoginViewModel.class);
57
+        initView();
58
+        initClick();
59
+        initData();
58
     }
60
     }
59
 
61
 
60
     private void initClick() {
62
     private void initClick() {
@@ -69,51 +71,45 @@ public class LoginActivity extends ViewBindingTitleBaseActivity<ActivityLoginPho
69
     }
71
     }
70
 
72
 
71
     private void initData() {
73
     private void initData() {
72
-      inputMonitor();
73
-      loginViewModel.verify.observe(this, new Observer<BaseResponse>() {
74
-          @Override
75
-          public void onChanged(BaseResponse baseResponse) {
74
+        inputMonitor();
75
+        loginViewModel.verify.observe(this, baseResponse -> {
76
 
76
 
77
-          }
78
-      });
79
-      loginViewModel.mPhone.observe(this, new Observer<String>() {
80
-          @Override
81
-          public void onChanged(String s) {
82
-              Log.v("qmzz",s);
83
-              mPhone=s;
84
-              //没有点击协议或者手机号密码为空
85
-                if (!mViewBinding.cbSelector.isSelected()|| TextUtils.isEmpty(mPhone)||TextUtils.isEmpty(mCode)){
86
-                    mViewBinding.tvLogin.setEnabled(false);
87
-                    mViewBinding.tvLogin.setTextColor(ContextCompat.getColor(LoginActivity.this, R.color.black_333333));
88
-                }else {
89
-                    mViewBinding.tvLogin.setEnabled(true);
90
-                    mViewBinding.tvLogin.setTextColor(ContextCompat.getColor(LoginActivity.this, R.color.white));
91
-                }
92
-          }
93
-      });
77
+        });
78
+        loginViewModel.mPhone.observe(this, s -> {
79
+            Log.v("qmzz", s);
80
+            mPhone = s;
81
+            //没有点击协议或者手机号密码为空
82
+            if (!mViewBinding.cbSelector.isSelected() || TextUtils.isEmpty(mPhone) || TextUtils.isEmpty(mCode)) {
83
+                mViewBinding.tvLogin.setEnabled(false);
84
+                mViewBinding.tvLogin.setTextColor(ContextCompat.getColor(LoginActivity.this, R.color.black_333333));
85
+            } else {
86
+                mViewBinding.tvLogin.setEnabled(true);
87
+                mViewBinding.tvLogin.setTextColor(ContextCompat.getColor(LoginActivity.this, R.color.white));
88
+            }
89
+        });
94
         loginViewModel.mPwd.observe(LoginActivity.this, new Observer<String>() {
90
         loginViewModel.mPwd.observe(LoginActivity.this, new Observer<String>() {
95
             @Override
91
             @Override
96
             public void onChanged(String s) {
92
             public void onChanged(String s) {
97
-                Log.v("qmzz",s);
98
-                mCode=s;
93
+                Log.v("qmzz", s);
94
+                mCode = s;
99
                 //没有点击协议或者手机号密码为空
95
                 //没有点击协议或者手机号密码为空
100
-                if (!mViewBinding.cbSelector.isSelected()|| TextUtils.isEmpty(mPhone)||TextUtils.isEmpty(mCode)){
96
+                if (!mViewBinding.cbSelector.isSelected() || TextUtils.isEmpty(mPhone) || TextUtils.isEmpty(mCode)) {
101
                     mViewBinding.tvLogin.setEnabled(false);
97
                     mViewBinding.tvLogin.setEnabled(false);
102
                     mViewBinding.tvLogin.setTextColor(ContextCompat.getColor(LoginActivity.this, R.color.black_333333));
98
                     mViewBinding.tvLogin.setTextColor(ContextCompat.getColor(LoginActivity.this, R.color.black_333333));
103
-                }else {
99
+                } else {
104
                     mViewBinding.tvLogin.setEnabled(true);
100
                     mViewBinding.tvLogin.setEnabled(true);
105
                     mViewBinding.tvLogin.setTextColor(ContextCompat.getColor(LoginActivity.this, R.color.white));
101
                     mViewBinding.tvLogin.setTextColor(ContextCompat.getColor(LoginActivity.this, R.color.white));
106
                 }
102
                 }
107
             }
103
             }
108
         });
104
         });
109
         loginViewModel.loginModel.observe(LoginActivity.this, loginModelDataResponse -> {
105
         loginViewModel.loginModel.observe(LoginActivity.this, loginModelDataResponse -> {
110
-            loginModel=  loginModelDataResponse.getData();
106
+            loginModel = loginModelDataResponse.getData();
111
             //保存token
107
             //保存token
112
-            MVUtils.put(Constants.TOKEN,loginModel.getToken());
113
-            MVUtils.put(Constants.PHONE,loginModel.getUser().getPhone());
114
-            MVUtils.put(Constants.USER_ID,loginModel.getUser().getUid());
115
-            MVUtils.put(Constants.AVATAR,loginModel.getUser().getAvatar());
116
-            MVUtils.put(Constants.NICK_NAME,loginModel.getUser().getNickname());
108
+            MVUtils.put(Constants.TOKEN, loginModel.getToken());
109
+            MVUtils.put(Constants.PHONE, loginModel.getUser().getPhone());
110
+            MVUtils.put(Constants.USER_ID, loginModel.getUser().getUid());
111
+            MVUtils.put(Constants.AVATAR, loginModel.getUser().getAvatar());
112
+            MVUtils.put(Constants.NICK_NAME, loginModel.getUser().getNickname());
117
 
113
 
118
 //                MainActivity.launch(LoginActivity.this);
114
 //                MainActivity.launch(LoginActivity.this);
119
 
115
 
@@ -122,16 +118,27 @@ public class LoginActivity extends ViewBindingTitleBaseActivity<ActivityLoginPho
122
             ActivityStack.getScreenManager().finishArrayActivity(activityList);
118
             ActivityStack.getScreenManager().finishArrayActivity(activityList);
123
             finish();
119
             finish();
124
         });
120
         });
125
-        loginViewModel.failed.observe(LoginActivity.this,msg->{
121
+        //查询到邀请人的UID后,继续登录操作
122
+        loginViewModel.uidAndPhoneBean.observe(this, uidAndPhoneBean -> {
123
+            if (TextUtils.isEmpty(mOpenId)) {
124
+                loginViewModel.getLogin(LoginActivity.this, mCode, uidAndPhoneBean.getUid());
125
+            } else {
126
+                //微信绑定手机号
127
+                loginViewModel.getWxBinding(LoginActivity.this, mCode, mOpenId, uidAndPhoneBean.getUid());
128
+            }
129
+        });
130
+        loginViewModel.failed.observe(LoginActivity.this, msg -> {
126
             //如果返回了400 表示需要填写邀请人信息,弹窗进行绑定
131
             //如果返回了400 表示需要填写邀请人信息,弹窗进行绑定
127
-            if ("400".equals(msg)){
128
-                CustomDialog.getEnterCodeWithTitle(this,"请输入邀请人手机号",phone->{
132
+            if ("400".equals(msg)) {
133
+                CustomDialog.getEnterCodeWithTitle(this, "请输入邀请人手机号", phone -> {
129
                     if (!StringUtils.isPhone(phone)) {
134
                     if (!StringUtils.isPhone(phone)) {
130
                         Toast.makeText(context, "手机号码格式输入错误", Toast.LENGTH_SHORT).show();
135
                         Toast.makeText(context, "手机号码格式输入错误", Toast.LENGTH_SHORT).show();
131
                         return;
136
                         return;
132
                     }
137
                     }
133
-                    //TODO 下面做绑定手机号流程,暂时不做处理
138
+                    loginViewModel.getUidByPhone(phone);
134
                 });
139
                 });
140
+            } else {
141
+                ToastUtils.showShort(msg);
135
             }
142
             }
136
         });
143
         });
137
     }
144
     }
@@ -145,18 +152,20 @@ public class LoginActivity extends ViewBindingTitleBaseActivity<ActivityLoginPho
145
      * 输入监听
152
      * 输入监听
146
      */
153
      */
147
     private void inputMonitor() {
154
     private void inputMonitor() {
148
-             //手机号输入监听
149
-            mViewBinding.etPhone.addTextChangedListener(new TextWatcher() {
155
+        //手机号输入监听
156
+        mViewBinding.etPhone.addTextChangedListener(new TextWatcher() {
150
             @Override
157
             @Override
151
             public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
158
             public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
152
-              //  loginViewModel.mPhone.postValue(mViewBinding.etPwd.getText().toString().trim());
159
+                //  loginViewModel.mPhone.postValue(mViewBinding.etPwd.getText().toString().trim());
153
 
160
 
154
             }
161
             }
162
+
155
             @Override
163
             @Override
156
             public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
164
             public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
157
                 //loginViewModel.mPhone.postValue(mViewBinding.etPwd.getText().toString().trim());
165
                 //loginViewModel.mPhone.postValue(mViewBinding.etPwd.getText().toString().trim());
158
 
166
 
159
             }
167
             }
168
+
160
             @Override
169
             @Override
161
             public void afterTextChanged(Editable editable) {
170
             public void afterTextChanged(Editable editable) {
162
                 loginViewModel.mPhone.postValue(mViewBinding.etPhone.getText().toString().trim());
171
                 loginViewModel.mPhone.postValue(mViewBinding.etPhone.getText().toString().trim());
@@ -166,12 +175,14 @@ public class LoginActivity extends ViewBindingTitleBaseActivity<ActivityLoginPho
166
         mViewBinding.etPwd.addTextChangedListener(new TextWatcher() {
175
         mViewBinding.etPwd.addTextChangedListener(new TextWatcher() {
167
             @Override
176
             @Override
168
             public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
177
             public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
169
-               // loginViewModel.mPwd.postValue(mViewBinding.etPwd.getText().toString().trim());
178
+                // loginViewModel.mPwd.postValue(mViewBinding.etPwd.getText().toString().trim());
170
             }
179
             }
180
+
171
             @Override
181
             @Override
172
             public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
182
             public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
173
-               // loginViewModel.mPwd.postValue(mViewBinding.etPwd.getText().toString().trim());
183
+                // loginViewModel.mPwd.postValue(mViewBinding.etPwd.getText().toString().trim());
174
             }
184
             }
185
+
175
             @Override
186
             @Override
176
             public void afterTextChanged(Editable editable) {
187
             public void afterTextChanged(Editable editable) {
177
                 loginViewModel.mPwd.postValue(mViewBinding.etPwd.getText().toString().trim());
188
                 loginViewModel.mPwd.postValue(mViewBinding.etPwd.getText().toString().trim());
@@ -182,21 +193,21 @@ public class LoginActivity extends ViewBindingTitleBaseActivity<ActivityLoginPho
182
     @Override
193
     @Override
183
     public void onClick(View v) {
194
     public void onClick(View v) {
184
         super.onClick(v);
195
         super.onClick(v);
185
-        if (v == mViewBinding.cbSelector){
196
+        if (v == mViewBinding.cbSelector) {
186
             //协议按钮
197
             //协议按钮
187
-            if (mViewBinding.cbSelector.isSelected()){
198
+            if (mViewBinding.cbSelector.isSelected()) {
188
                 mViewBinding.cbSelector.setSelected(false);
199
                 mViewBinding.cbSelector.setSelected(false);
189
-            }else {
200
+            } else {
190
                 mViewBinding.cbSelector.setSelected(true);
201
                 mViewBinding.cbSelector.setSelected(true);
191
             }
202
             }
192
-            if (!mViewBinding.cbSelector.isSelected()|| TextUtils.isEmpty(mPhone)||TextUtils.isEmpty(mCode)){
203
+            if (!mViewBinding.cbSelector.isSelected() || TextUtils.isEmpty(mPhone) || TextUtils.isEmpty(mCode)) {
193
                 mViewBinding.tvLogin.setEnabled(false);
204
                 mViewBinding.tvLogin.setEnabled(false);
194
                 mViewBinding.tvLogin.setTextColor(ContextCompat.getColor(LoginActivity.this, R.color.black_333333));
205
                 mViewBinding.tvLogin.setTextColor(ContextCompat.getColor(LoginActivity.this, R.color.black_333333));
195
-            }else {
206
+            } else {
196
                 mViewBinding.tvLogin.setEnabled(true);
207
                 mViewBinding.tvLogin.setEnabled(true);
197
                 mViewBinding.tvLogin.setTextColor(ContextCompat.getColor(LoginActivity.this, R.color.white));
208
                 mViewBinding.tvLogin.setTextColor(ContextCompat.getColor(LoginActivity.this, R.color.white));
198
             }
209
             }
199
-        }else if (v == mViewBinding.tvCode) {
210
+        } else if (v == mViewBinding.tvCode) {
200
             //获取验证码
211
             //获取验证码
201
             if (TextUtils.isEmpty(mPhone)) {
212
             if (TextUtils.isEmpty(mPhone)) {
202
                 MyToast.makeText(LoginActivity.this, "请输入手机号", Toast.LENGTH_LONG).show();
213
                 MyToast.makeText(LoginActivity.this, "请输入手机号", Toast.LENGTH_LONG).show();
@@ -209,34 +220,34 @@ public class LoginActivity extends ViewBindingTitleBaseActivity<ActivityLoginPho
209
             loginViewModel.getCode(LoginActivity.this);
220
             loginViewModel.getCode(LoginActivity.this);
210
             mCountDownTimeUtil = new CountDownTimeUtil(mViewBinding.tvCode);
221
             mCountDownTimeUtil = new CountDownTimeUtil(mViewBinding.tvCode);
211
             mCountDownTimeUtil.runTimer();
222
             mCountDownTimeUtil.runTimer();
212
-        }else if (v == mViewBinding.tvLogin) {
223
+        } else if (v == mViewBinding.tvLogin) {
213
             //请求接口
224
             //请求接口
214
             if (TextUtils.isEmpty(mPhone)) {
225
             if (TextUtils.isEmpty(mPhone)) {
215
                 MyToast.makeText(LoginActivity.this, "请输入手机号", Toast.LENGTH_LONG).show();
226
                 MyToast.makeText(LoginActivity.this, "请输入手机号", Toast.LENGTH_LONG).show();
216
                 return;
227
                 return;
217
             }
228
             }
218
-            if (TextUtils.isEmpty(mCode)){
229
+            if (TextUtils.isEmpty(mCode)) {
219
                 MyToast.makeText(LoginActivity.this, "请输入验证码", Toast.LENGTH_LONG).show();
230
                 MyToast.makeText(LoginActivity.this, "请输入验证码", Toast.LENGTH_LONG).show();
220
                 return;
231
                 return;
221
             }
232
             }
222
-            if (!mViewBinding.cbSelector.isSelected()){
233
+            if (!mViewBinding.cbSelector.isSelected()) {
223
                 MyToast.makeText(LoginActivity.this, "请点击同意协议", Toast.LENGTH_LONG).show();
234
                 MyToast.makeText(LoginActivity.this, "请点击同意协议", Toast.LENGTH_LONG).show();
224
                 return;
235
                 return;
225
             }
236
             }
226
-            if (TextUtils.isEmpty(mOpenId)){
227
-                loginViewModel.getLogin(LoginActivity.this,mCode);
228
-            }else {
237
+            if (TextUtils.isEmpty(mOpenId)) {
238
+                loginViewModel.getLogin(LoginActivity.this, mCode);
239
+            } else {
229
                 //微信绑定手机号
240
                 //微信绑定手机号
230
-                loginViewModel.getWxBinding(LoginActivity.this,mCode,mOpenId);
241
+                loginViewModel.getWxBinding(LoginActivity.this, mCode, mOpenId);
231
             }
242
             }
232
 
243
 
233
-        }else if (v == mViewBinding.tvRegistrationProtocol){
244
+        } else if (v == mViewBinding.tvRegistrationProtocol) {
234
             //注册协议
245
             //注册协议
235
-            WebViewTitleBaseActivity.launch(LoginActivity.this,getString(R.string.registration_protocol),
246
+            WebViewTitleBaseActivity.launch(LoginActivity.this, getString(R.string.registration_protocol),
236
                     Constants.PROTOCOL_YHC_REGIST);
247
                     Constants.PROTOCOL_YHC_REGIST);
237
-        }else if (v ==  mViewBinding.tvPrivacyAgreement){
248
+        } else if (v == mViewBinding.tvPrivacyAgreement) {
238
             //隐私协议
249
             //隐私协议
239
-            WebViewTitleBaseActivity.launch(LoginActivity.this,getString(R.string.privacy_agreement),
250
+            WebViewTitleBaseActivity.launch(LoginActivity.this, getString(R.string.privacy_agreement),
240
                     Constants.PROTOCOL_YHC_YINSI);
251
                     Constants.PROTOCOL_YHC_YINSI);
241
         }
252
         }
242
     }
253
     }
@@ -253,9 +264,10 @@ public class LoginActivity extends ViewBindingTitleBaseActivity<ActivityLoginPho
253
         Intent intent = new Intent(context, LoginActivity.class);
264
         Intent intent = new Intent(context, LoginActivity.class);
254
         context.startActivity(intent);
265
         context.startActivity(intent);
255
     }
266
     }
256
-    public static void launch(Context context,String openId) {
267
+
268
+    public static void launch(Context context, String openId) {
257
         Intent intent = new Intent(context, LoginActivity.class);
269
         Intent intent = new Intent(context, LoginActivity.class);
258
-        intent.putExtra(INTENT_OPEN_ID,openId);
270
+        intent.putExtra(INTENT_OPEN_ID, openId);
259
         context.startActivity(intent);
271
         context.startActivity(intent);
260
     }
272
     }
261
 }
273
 }

+ 27 - 0
app/src/main/java/com/yihucha/hbyhc/presentation/login/model/UidAndPhoneBean.java

@@ -0,0 +1,27 @@
1
+package com.yihucha.hbyhc.presentation.login.model;
2
+
3
+/**
4
+ * author : zhangbing
5
+ * time   : 2024/2/28 15:41
6
+ * com.yihucha.hbyhc.presentation.login.model
7
+ */
8
+public class UidAndPhoneBean {
9
+    private String phone;
10
+    private String uid;
11
+
12
+    public String getPhone() {
13
+        return phone;
14
+    }
15
+
16
+    public void setPhone(String phone) {
17
+        this.phone = phone;
18
+    }
19
+
20
+    public String getUid() {
21
+        return uid;
22
+    }
23
+
24
+    public void setUid(String uid) {
25
+        this.uid = uid;
26
+    }
27
+}

+ 87 - 39
app/src/main/java/com/yihucha/hbyhc/presentation/login/view_model/LoginViewModel.java

@@ -18,6 +18,8 @@ import com.yihucha.hbyhc.network.DataResponse;
18
 import com.yihucha.hbyhc.network.NetworkApi;
18
 import com.yihucha.hbyhc.network.NetworkApi;
19
 import com.yihucha.hbyhc.network.service.AuthService;
19
 import com.yihucha.hbyhc.network.service.AuthService;
20
 import com.yihucha.hbyhc.presentation.login.model.LoginModel;
20
 import com.yihucha.hbyhc.presentation.login.model.LoginModel;
21
+import com.yihucha.hbyhc.presentation.login.model.UidAndPhoneBean;
22
+import com.yihucha.hbyhc.utils.EmptyCheckUtils;
21
 import com.yihucha.hbyhc.utils.LogUtil;
23
 import com.yihucha.hbyhc.utils.LogUtil;
22
 import com.yihucha.hbyhc.view.MyToast;
24
 import com.yihucha.hbyhc.view.MyToast;
23
 
25
 
@@ -29,6 +31,7 @@ public class LoginViewModel extends BaseViewModel {
29
     public MutableLiveData<String> mPwd = new MutableLiveData<>();//密码
31
     public MutableLiveData<String> mPwd = new MutableLiveData<>();//密码
30
     public MutableLiveData<BaseResponse> verify = new MutableLiveData<>();//验证码获取成功
32
     public MutableLiveData<BaseResponse> verify = new MutableLiveData<>();//验证码获取成功
31
     public MutableLiveData<DataResponse<LoginModel>> loginModel = new MutableLiveData<>();//登录返回的数据
33
     public MutableLiveData<DataResponse<LoginModel>> loginModel = new MutableLiveData<>();//登录返回的数据
34
+    public MutableLiveData<UidAndPhoneBean> uidAndPhoneBean = new MutableLiveData<>(); //邀请人信息
32
 //    public MutableLiveData<DataResponse<LoginHomeXieyiModel>> xieyi = new MutableLiveData<>();//验证码获取成功
35
 //    public MutableLiveData<DataResponse<LoginHomeXieyiModel>> xieyi = new MutableLiveData<>();//验证码获取成功
33
 
36
 
34
 //    /**
37
 //    /**
@@ -54,50 +57,83 @@ public class LoginViewModel extends BaseViewModel {
54
 //            }
57
 //            }
55
 //        }));
58
 //        }));
56
 //    }
59
 //    }
60
+
61
+    /**
62
+     * 根据手机号,查询UID,查询邀请人信息
63
+     */
64
+    @SuppressLint("checkResult")
65
+    public void getUidByPhone(String phone) {
66
+        AuthService service = NetworkApi.createService(AuthService.class);
67
+        service.getUidByPhone(phone)
68
+                .compose(NetworkApi.applySchedulers(new BaseObserver<DataResponse<UidAndPhoneBean>>() {
69
+                    @Override
70
+                    public void onSuccess(DataResponse<UidAndPhoneBean> response) {
71
+                        if (response.responseCode == 200) {
72
+                            uidAndPhoneBean.postValue(response.getData());
73
+                        } else {
74
+                            failed.postValue(response.responseError);
75
+                        }
76
+                    }
77
+
78
+                    @Override
79
+                    public void onFailure(Throwable e) {
80
+                        failed.postValue("请求失败");
81
+                    }
82
+                }));
83
+    }
84
+
57
     /**
85
     /**
58
      * 获取验证码
86
      * 获取验证码
87
+     *
59
      * @param context
88
      * @param context
60
      */
89
      */
61
     @SuppressLint("CheckResult")
90
     @SuppressLint("CheckResult")
62
-    public void getCode(Context context){
91
+    public void getCode(Context context) {
63
         Map<String, Object> map = new HashMap<>();
92
         Map<String, Object> map = new HashMap<>();
64
-        map.put("phone",mPhone.getValue());
93
+        map.put("phone", mPhone.getValue());
65
         AuthService authService = NetworkApi.createService(AuthService.class);
94
         AuthService authService = NetworkApi.createService(AuthService.class);
66
         authService.verify(map).compose(NetworkApi.applySchedulers(new BaseObserver<BaseResponse>() {
95
         authService.verify(map).compose(NetworkApi.applySchedulers(new BaseObserver<BaseResponse>() {
67
 
96
 
68
             @Override
97
             @Override
69
             public void onSuccess(BaseResponse baseResponse) {
98
             public void onSuccess(BaseResponse baseResponse) {
70
-              MyToast.makeText(context, baseResponse.responseError, Toast.LENGTH_LONG).show();
71
-              verify.setValue(baseResponse);
99
+                MyToast.makeText(context, baseResponse.responseError, Toast.LENGTH_LONG).show();
100
+                verify.setValue(baseResponse);
72
             }
101
             }
73
 
102
 
74
             @Override
103
             @Override
75
             public void onFailure(Throwable e) {
104
             public void onFailure(Throwable e) {
76
                 LogUtil.LogInfo("Throwable", e.getMessage());
105
                 LogUtil.LogInfo("Throwable", e.getMessage());
77
-               // MyToast.makeText(context, getString(R.string.failed_string), Toast.LENGTH_LONG).show();
106
+                // MyToast.makeText(context, getString(R.string.failed_string), Toast.LENGTH_LONG).show();
78
             }
107
             }
79
         }));
108
         }));
80
     }
109
     }
81
 
110
 
82
     /**
111
     /**
83
      * 登录
112
      * 登录
113
+     *
84
      * @param context
114
      * @param context
85
      * @param sms_code 验证码
115
      * @param sms_code 验证码
86
      */
116
      */
117
+    public void getLogin(Context context, String sms_code) {
118
+        getLogin(context,sms_code,null);
119
+    }
120
+
87
     @SuppressLint("CheckResult")
121
     @SuppressLint("CheckResult")
88
-    public void  getLogin(Context context,String sms_code){
122
+    public void getLogin(Context context, String sms_code, String uid) {
89
         Map<String, Object> map = new HashMap<>();
123
         Map<String, Object> map = new HashMap<>();
90
-        map.put("phone",mPhone.getValue());
91
-        map.put("sms_code",sms_code);
124
+        map.put("phone", mPhone.getValue());
125
+        map.put("sms_code", sms_code);
126
+        if (EmptyCheckUtils.isNotEmpty(uid))
127
+            map.put("spread", uid);
92
         AuthService authService = NetworkApi.createService(AuthService.class);
128
         AuthService authService = NetworkApi.createService(AuthService.class);
93
         authService.smslogin(map).compose(NetworkApi.applySchedulers(new BaseObserver<DataResponse<LoginModel>>() {
129
         authService.smslogin(map).compose(NetworkApi.applySchedulers(new BaseObserver<DataResponse<LoginModel>>() {
94
             @Override
130
             @Override
95
             public void onSuccess(DataResponse<LoginModel> loginModelDataResponse) {
131
             public void onSuccess(DataResponse<LoginModel> loginModelDataResponse) {
96
-                if (loginModelDataResponse.responseCode==200){
132
+                if (loginModelDataResponse.responseCode == 200) {
97
                     loginModel.postValue(loginModelDataResponse);
133
                     loginModel.postValue(loginModelDataResponse);
98
-                }else if (loginModelDataResponse.responseCode == 400){
134
+                } else if (loginModelDataResponse.responseCode == 400) {
99
                     failed.postValue("400");
135
                     failed.postValue("400");
100
-                }else {
136
+                } else {
101
                     MyToast.makeText(context, loginModelDataResponse.responseError, Toast.LENGTH_LONG).show();
137
                     MyToast.makeText(context, loginModelDataResponse.responseError, Toast.LENGTH_LONG).show();
102
                 }
138
                 }
103
 
139
 
@@ -106,25 +142,26 @@ public class LoginViewModel extends BaseViewModel {
106
             @Override
142
             @Override
107
             public void onFailure(Throwable e) {
143
             public void onFailure(Throwable e) {
108
                 LogUtil.LogInfo("Throwable", e.getMessage());
144
                 LogUtil.LogInfo("Throwable", e.getMessage());
109
-              //  MyToast.makeText(context, getString(R.string.failed_string), Toast.LENGTH_LONG).show();
145
+                //  MyToast.makeText(context, getString(R.string.failed_string), Toast.LENGTH_LONG).show();
110
             }
146
             }
111
         }));
147
         }));
112
     }
148
     }
149
+
113
     /**
150
     /**
114
      * 登录
151
      * 登录
115
      */
152
      */
116
     @SuppressLint("CheckResult")
153
     @SuppressLint("CheckResult")
117
-    public void  getPhonePasswordLogin(String phone,String password){
154
+    public void getPhonePasswordLogin(String phone, String password) {
118
         Map<String, Object> map = new HashMap<>();
155
         Map<String, Object> map = new HashMap<>();
119
-        map.put("phone",phone);
120
-        map.put("password",password);
156
+        map.put("phone", phone);
157
+        map.put("password", password);
121
         AuthService authService = NetworkApi.createService(AuthService.class);
158
         AuthService authService = NetworkApi.createService(AuthService.class);
122
         authService.login(map).compose(NetworkApi.applySchedulers(new BaseObserver<DataResponse<LoginModel>>() {
159
         authService.login(map).compose(NetworkApi.applySchedulers(new BaseObserver<DataResponse<LoginModel>>() {
123
             @Override
160
             @Override
124
             public void onSuccess(DataResponse<LoginModel> loginModelDataResponse) {
161
             public void onSuccess(DataResponse<LoginModel> loginModelDataResponse) {
125
-                if (loginModelDataResponse.responseCode==200){
162
+                if (loginModelDataResponse.responseCode == 200) {
126
                     loginModel.postValue(loginModelDataResponse);
163
                     loginModel.postValue(loginModelDataResponse);
127
-                }else {
164
+                } else {
128
                     ToastUtils.showLong(loginModelDataResponse.responseError);
165
                     ToastUtils.showLong(loginModelDataResponse.responseError);
129
                 }
166
                 }
130
             }
167
             }
@@ -135,25 +172,34 @@ public class LoginViewModel extends BaseViewModel {
135
             }
172
             }
136
         }));
173
         }));
137
     }
174
     }
175
+
138
     /**
176
     /**
139
      * 微信登录-绑定用户-手机号验证码
177
      * 微信登录-绑定用户-手机号验证码
178
+     *
140
      * @param context
179
      * @param context
141
      * @param sms_code 验证码
180
      * @param sms_code 验证码
142
      */
181
      */
182
+    public void getWxBinding(Context context, String sms_code, String openId) {
183
+        getWxBinding(context,sms_code,openId,null);
184
+    }
143
     @SuppressLint("CheckResult")
185
     @SuppressLint("CheckResult")
144
-    public void  getWxBinding(Context context,String sms_code,String openId){
186
+    public void getWxBinding(Context context, String sms_code, String openId,String uid) {
145
         Map<String, Object> map = new HashMap<>();
187
         Map<String, Object> map = new HashMap<>();
146
-        map.put("phone",mPhone.getValue());
147
-        map.put("sms_code",sms_code);
148
-        map.put("type","1");
149
-        map.put("third_user_id",openId);
188
+        map.put("phone", mPhone.getValue());
189
+        map.put("sms_code", sms_code);
190
+        map.put("type", "1");
191
+        map.put("third_user_id", openId);
192
+        if (EmptyCheckUtils.isNotEmpty(uid)){
193
+            map.put("spread", uid);
194
+        }
195
+
150
         AuthService authService = NetworkApi.createService(AuthService.class);
196
         AuthService authService = NetworkApi.createService(AuthService.class);
151
         authService.wxloginbinding(map).compose(NetworkApi.applySchedulers(new BaseObserver<DataResponse<LoginModel>>() {
197
         authService.wxloginbinding(map).compose(NetworkApi.applySchedulers(new BaseObserver<DataResponse<LoginModel>>() {
152
             @Override
198
             @Override
153
             public void onSuccess(DataResponse<LoginModel> loginModelDataResponse) {
199
             public void onSuccess(DataResponse<LoginModel> loginModelDataResponse) {
154
-                if (loginModelDataResponse.responseCode==200){
200
+                if (loginModelDataResponse.responseCode == 200) {
155
                     loginModel.postValue(loginModelDataResponse);
201
                     loginModel.postValue(loginModelDataResponse);
156
-                }else {
202
+                } else {
157
                     MyToast.makeText(context, loginModelDataResponse.responseError, Toast.LENGTH_LONG).show();
203
                     MyToast.makeText(context, loginModelDataResponse.responseError, Toast.LENGTH_LONG).show();
158
                 }
204
                 }
159
 
205
 
@@ -162,26 +208,27 @@ public class LoginViewModel extends BaseViewModel {
162
             @Override
208
             @Override
163
             public void onFailure(Throwable e) {
209
             public void onFailure(Throwable e) {
164
                 LogUtil.LogInfo("Throwable", e.getMessage());
210
                 LogUtil.LogInfo("Throwable", e.getMessage());
165
-               // MyToast.makeText(context, getString(R.string.failed_string), Toast.LENGTH_LONG).show();
211
+                // MyToast.makeText(context, getString(R.string.failed_string), Toast.LENGTH_LONG).show();
166
             }
212
             }
167
         }));
213
         }));
168
     }
214
     }
169
 
215
 
170
     /**
216
     /**
171
      * 一键登录
217
      * 一键登录
218
+     *
172
      * @param token
219
      * @param token
173
      */
220
      */
174
     @SuppressLint("CheckResult")
221
     @SuppressLint("CheckResult")
175
-    public void getAKeyToLogIn(String token){
222
+    public void getAKeyToLogIn(String token) {
176
         Map<String, Object> map = new HashMap<>();
223
         Map<String, Object> map = new HashMap<>();
177
-        map.put("token",token);
178
-        AuthService authService=NetworkApi.createService(AuthService.class);
224
+        map.put("token", token);
225
+        AuthService authService = NetworkApi.createService(AuthService.class);
179
         authService.getAKeyToLogIn(map).compose(NetworkApi.applySchedulers(new BaseObserver<DataResponse<LoginModel>>() {
226
         authService.getAKeyToLogIn(map).compose(NetworkApi.applySchedulers(new BaseObserver<DataResponse<LoginModel>>() {
180
             @Override
227
             @Override
181
             public void onSuccess(DataResponse<LoginModel> loginModelDataResponse) {
228
             public void onSuccess(DataResponse<LoginModel> loginModelDataResponse) {
182
-                if (loginModelDataResponse.responseCode==200){
229
+                if (loginModelDataResponse.responseCode == 200) {
183
                     loginModel.postValue(loginModelDataResponse);
230
                     loginModel.postValue(loginModelDataResponse);
184
-                }else {
231
+                } else {
185
                     ToastUtils.showLong(loginModelDataResponse.responseError);
232
                     ToastUtils.showLong(loginModelDataResponse.responseError);
186
                 }
233
                 }
187
 
234
 
@@ -189,36 +236,37 @@ public class LoginViewModel extends BaseViewModel {
189
 
236
 
190
             @Override
237
             @Override
191
             public void onFailure(Throwable e) {
238
             public void onFailure(Throwable e) {
192
-              //  failed.postValue(getString(R.string.failed_string));
239
+                //  failed.postValue(getString(R.string.failed_string));
193
             }
240
             }
194
         }));
241
         }));
195
     }
242
     }
196
 
243
 
197
     /**
244
     /**
198
      * 一键登录
245
      * 一键登录
246
+     *
199
      * @param openid 微信用户唯一标识
247
      * @param openid 微信用户唯一标识
200
      */
248
      */
201
     @SuppressLint("CheckResult")
249
     @SuppressLint("CheckResult")
202
-    public void getWechatLogIn(String openid){
250
+    public void getWechatLogIn(String openid) {
203
         Map<String, Object> map = new HashMap<>();
251
         Map<String, Object> map = new HashMap<>();
204
-        map.put("openid",openid);
205
-        AuthService authService=NetworkApi.createService(AuthService.class);
252
+        map.put("openid", openid);
253
+        AuthService authService = NetworkApi.createService(AuthService.class);
206
         authService.getWechatLogIn(map).compose(NetworkApi.applySchedulers(new BaseObserver<DataResponse<LoginModel>>() {
254
         authService.getWechatLogIn(map).compose(NetworkApi.applySchedulers(new BaseObserver<DataResponse<LoginModel>>() {
207
             @Override
255
             @Override
208
             public void onSuccess(DataResponse<LoginModel> loginModelDataResponse) {
256
             public void onSuccess(DataResponse<LoginModel> loginModelDataResponse) {
209
-                if (loginModelDataResponse.responseCode ==200){
257
+                if (loginModelDataResponse.responseCode == 200) {
210
                     loginModel.postValue(loginModelDataResponse);
258
                     loginModel.postValue(loginModelDataResponse);
211
-                }else {
259
+                } else {
212
                     ToastUtils.showLong(loginModelDataResponse.responseError);
260
                     ToastUtils.showLong(loginModelDataResponse.responseError);
213
                 }
261
                 }
214
 
262
 
215
-                LogUtil.LogInfo("Code++",JSON.toJSONString(loginModelDataResponse));
263
+                LogUtil.LogInfo("Code++", JSON.toJSONString(loginModelDataResponse));
216
             }
264
             }
217
 
265
 
218
             @Override
266
             @Override
219
             public void onFailure(Throwable e) {
267
             public void onFailure(Throwable e) {
220
-             //   failed.postValue(getString(R.string.failed_string));
221
-                LogUtil.LogInfo("Code++",e.getMessage());
268
+                //   failed.postValue(getString(R.string.failed_string));
269
+                LogUtil.LogInfo("Code++", e.getMessage());
222
             }
270
             }
223
         }));
271
         }));
224
     }
272
     }

+ 7 - 1
app/src/main/java/com/yihucha/hbyhc/view/CustomDialog.java

@@ -490,7 +490,13 @@ public class CustomDialog {
490
             lDialog.setText(R.id.tv_title, title);
490
             lDialog.setText(R.id.tv_title, title);
491
         }
491
         }
492
         EditText etInvitationCode = lDialog.getView(R.id.et_invitationcode);
492
         EditText etInvitationCode = lDialog.getView(R.id.et_invitationcode);
493
-        lDialog.setMaskValue(0.5f).setGravity(Gravity.CENTER).setCancelBtn(R.id.confirm_negative).setOnClickListener((v, lDialog1) -> oneInputButtonsListener.clickButton(etInvitationCode.getText().toString()), R.id.confirm_positive).show();
493
+        lDialog.setMaskValue(0.5f)
494
+                .setGravity(Gravity.CENTER)
495
+                .setCancelBtn(R.id.confirm_negative)
496
+                .setOnClickListener((v, lDialog1) -> {
497
+                    oneInputButtonsListener.clickButton(etInvitationCode.getText().toString());
498
+                    lDialog.dismiss();
499
+                }, R.id.confirm_positive).show();
494
     }
500
     }
495
 
501
 
496
     /**
502
     /**