|
@@ -346,7 +346,131 @@ public class SendKeyBoardFragment extends Fragment {
|
|
ToastUtils.make(getContext(), "密码格式错误!请输入8-16位的数字!");
|
|
ToastUtils.make(getContext(), "密码格式错误!请输入8-16位的数字!");
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+ binding.buttonConfirm.setOnClickListener(view1 -> {
|
|
|
|
+ if (ButtonUtils.isFastClick()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // 登录逻辑 editTextTextPersonName4 手机 editTextTextPersonName5 密码
|
|
|
|
+ String sendPhone = "";
|
|
|
|
+ if ("courier".equals(finalLoginType) || "collect".equals(finalLoginType)){
|
|
|
|
+ sendPhone = binding.editTextTextPersonName4.getText().toString();
|
|
|
|
+ }else {
|
|
|
|
+ sendPhone = !StringUtils.isNullOrEmpty(finalLoginPhone) ? finalLoginPhone : binding.editTextTextPersonName4.getText().toString();
|
|
|
|
+ }
|
|
|
|
+ String password = binding.editTextTextPersonName5.getText().toString();
|
|
|
|
+
|
|
|
|
+ Pattern phonePattern = Pattern.compile("^((13[0-9])|(14[0,1,4-9])|(15[0-3,5-9])|(16[2,5,6,7])|(17[0-8])|(18[0-9])|(19[0-3,5-9]))\\d{8}$");
|
|
|
|
+ Pattern pwdPattern = Pattern.compile("^[0-9]{8,16}$");
|
|
|
|
+
|
|
|
|
+ if (phonePattern.matcher(sendPhone).matches() && pwdPattern.matcher(password).matches()) {
|
|
|
|
+ String finalSendPhone = sendPhone;
|
|
|
|
+ ICSPClient.login(sendPhone, password, new Callback() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onFailure(@NotNull Call call, @NotNull IOException e) {
|
|
|
|
+ // TODO 登录失败处理
|
|
|
|
+ ToastUtils.make(getContext(), "登录失败!网络异常!");
|
|
|
|
+ Log.e(TAG, "onFailure: 登录失败! call: " + call.timeout().toString(), e);
|
|
|
|
+ LoggingUtils.sendErrorLog("业务异常: 登录失败!网络异常! ", e);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
|
|
|
|
+ ((MainActivity) getActivity()).runOnUiThread(() -> {
|
|
|
|
+ String responseStr = ICSPClient.isSuccessfulAndParseResponse(response);
|
|
|
|
+ if (!StringUtils.isNullOrEmpty(responseStr)) {
|
|
|
|
+ try {
|
|
|
|
+ ResponseData<ResponseTokenVo> responseData = JacksonUtils.objectmapper.readValue(responseStr, new TypeReference<ResponseData<ResponseTokenVo>>() {
|
|
|
|
+ });
|
|
|
|
+ ResponseTokenVo data = responseData.getData();
|
|
|
|
+
|
|
|
|
+ if (responseData.getCode().equals(ICSPConstant.OK)) {
|
|
|
|
+ LocalStorage.Session session = new LocalStorage.Session();
|
|
|
|
+ session.setPhone(finalSendPhone);
|
|
|
|
+ session.setTime(System.currentTimeMillis());
|
|
|
|
+ session.setToken(data.getToken());
|
|
|
|
+ MainActivity activity = (MainActivity) getActivity();
|
|
|
|
+ String pageType = activity.getBundleMap().get(MainFragment.class.getName()).getString("pageType");
|
|
|
|
+ String loginType = activity.getBundleMap().get(CourierFragment.class.getName()).getString("loginType");
|
|
|
|
+ LocalStorage.getInstance().cleanSession(activity,false);
|
|
|
|
+ LocalStorage.getInstance().setSession(session);
|
|
|
|
+
|
|
|
|
+ Bundle pageTypeBundle = new Bundle();
|
|
|
|
+ pageTypeBundle.putString("pageType",pageType);
|
|
|
|
+ activity.getBundleMap().put(MainFragment.class.getName(), pageTypeBundle);
|
|
|
|
+ Bundle loginTypeBundle = new Bundle();
|
|
|
|
+ loginTypeBundle.putString("loginType",loginType);
|
|
|
|
+ activity.getBundleMap().put(CourierFragment.class.getName(), loginTypeBundle);
|
|
|
|
+
|
|
|
|
+ // 登录成功
|
|
|
|
+ ToastUtils.make(getContext(), "登录成功!");
|
|
|
|
+ if (null != timer) {
|
|
|
|
+ timer.cancel();
|
|
|
|
+ }
|
|
|
|
+ if ("store".equals(finalLoginType) || "courier".equals(finalLoginType)){
|
|
|
|
+ Bundle isPayBundle = new Bundle();
|
|
|
|
+ isPayBundle.putString("isPay",data.getIsPay());
|
|
|
|
+ activity.getBundleMap().put(SendKeyBoardFragment.class.getName(), isPayBundle);
|
|
|
|
+ // "30"为供应链账号,定为管理员账号
|
|
|
|
+ if("store".equals(finalLoginType) ){
|
|
|
|
+ if("10".equals(data.getDelType()) || "30".equals(data.getDelType())){
|
|
|
|
+ NavUtils.navigate(SendKeyBoardFragment.this, R.id.action_sendFragment_to_sendMainFragment);
|
|
|
|
+ } else {
|
|
|
|
+ ToastUtils.make(getContext(), "请用门店账号登录!");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ if("20".equals(data.getDelType()) || "30".equals(data.getDelType())){
|
|
|
|
+ NavUtils.navigate(SendKeyBoardFragment.this, R.id.action_sendFragment_to_sendMainFragment);
|
|
|
|
+ } else {
|
|
|
|
+ ToastUtils.make(getContext(), "请用快递员账号登录!");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+// if ("0".equals(data.getIsPay())){
|
|
|
|
+// NavUtils.navigate(SendKeyBoardFragment.this, R.id.action_sendFragment_to_paymentFragment);
|
|
|
|
+// }else {
|
|
|
|
+// NavUtils.navigate(SendKeyBoardFragment.this, R.id.action_sendFragment_to_sendMainFragment);
|
|
|
|
+// }
|
|
|
|
+ }else{
|
|
|
|
+ if(!"20".equals(data.getDelType())){
|
|
|
|
+ ToastUtils.make(getContext(), "请用快递员账号登录!");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ NavUtils.navigate(SendKeyBoardFragment.this, R.id.action_sendFragment_to_collectMaterialsFragment);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ ToastUtils.make(getContext(), responseData.getMsg());
|
|
|
|
+ Log.w(TAG, "onResponse: " + responseData.getMsg());
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
|
+ Log.e(TAG, "onViewCreated: 解析登录响应信息错误! response body: " + responseStr, e);
|
|
|
|
+ ToastUtils.make(getContext(), "登录失败!");
|
|
|
|
+ LoggingUtils.sendErrorLog("业务异常: 登录失败!", e);
|
|
|
|
+ } catch (ClassCastException e) {
|
|
|
|
+ Log.e(TAG, "onResponse: 解析登录响应信息类型转换错误! response body: " + responseStr, e);
|
|
|
|
+ ToastUtils.make(getContext(), "登录失败!");
|
|
|
|
+ LoggingUtils.sendErrorLog("业务异常: 登录失败!", e);
|
|
|
|
+ } catch (RuntimeException e) {
|
|
|
|
+ Log.e(TAG, "onResponse: 登录失败! ", e);
|
|
|
|
+ ToastUtils.make(getContext(), "登录失败!");
|
|
|
|
+ LoggingUtils.sendErrorLog("业务异常: 登录失败!未知错误! ", e);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ // 登录失败
|
|
|
|
+ ToastUtils.make(getContext(), "服务异常!请稍后重试!");
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ } else if (!phonePattern.matcher(sendPhone).matches()) {
|
|
|
|
+ ToastUtils.make(getContext(), "输入正确的手机号!");
|
|
|
|
+ } else if (!pwdPattern.matcher(password).matches()) {
|
|
|
|
+ ToastUtils.make(getContext(), "密码格式错误!请输入8-16位的数字!");
|
|
|
|
+ }
|
|
|
|
+ });
|
|
// 密码
|
|
// 密码
|
|
binding.editTextTextPersonName5.setOnFocusChangeListener((view1, hasFocus) -> {
|
|
binding.editTextTextPersonName5.setOnFocusChangeListener((view1, hasFocus) -> {
|
|
AtomicBoolean caseSmallFlag = new AtomicBoolean(true);
|
|
AtomicBoolean caseSmallFlag = new AtomicBoolean(true);
|
|
@@ -975,6 +1099,7 @@ public class SendKeyBoardFragment extends Fragment {
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
// 默认选中密码输入
|
|
// 默认选中密码输入
|
|
if (!StringUtils.isNullOrEmpty(binding.editTextTextPersonName4.getText().toString())) {
|
|
if (!StringUtils.isNullOrEmpty(binding.editTextTextPersonName4.getText().toString())) {
|
|
binding.editTextTextPersonName5.requestFocus();
|
|
binding.editTextTextPersonName5.requestFocus();
|