浏览代码

bug fixed

hanjing 7 年之前
父节点
当前提交
cc0e9f2ec7

+ 3 - 3
app/src/main/java/com/sheep/gamegroup/model/api/ApiService.java

@@ -176,19 +176,19 @@ public interface ApiService {
     /**
      * 手机号召回密码:1.获取验证码
      */
-    @POST("app/user/bind_resetpass1/")
+    @POST("app/user/resetpass1/")
     Observable<BaseMessage> resetPass4Captcha(@Body JSONObject jsonObject);
 
     /**
      * 手机号召回密码:2.验证验证码
      */
-    @POST("app/user/bind_resetpass2/")
+    @POST("app/user/resetpass2/")
     Observable<BaseMessage> resetPass4Valid(@Body JSONObject jsonObject);
 
     /**
      * 手机号召回密码:3.设置新密码
      */
-    @POST("app/user/bind_resetpass3/")
+    @POST("app/user/resetpass3/")
     Observable<BaseMessage> resetPass4New(@Body JSONObject jsonObject);
 
     /**

+ 103 - 31
app/src/main/java/com/sheep/gamegroup/module/login/ChangePasswordAct.java

@@ -1,9 +1,12 @@
 package com.sheep.gamegroup.module.login;
 
 import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
 import android.os.Bundle;
 import android.support.v4.app.Fragment;
 import android.support.v4.app.FragmentTransaction;
+import android.text.TextUtils;
 
 import com.alibaba.fastjson.JSONObject;
 import com.sheep.gamegroup.absBase.BaseActivity;
@@ -12,7 +15,9 @@ import com.sheep.gamegroup.model.entity.UserEntity;
 import com.sheep.gamegroup.model.util.SheepSubscriber;
 import com.sheep.gamegroup.module.login.controller.ChangePasswordController;
 import com.sheep.gamegroup.module.login.fragments.BindAccountFgt;
+import com.sheep.gamegroup.module.login.fragments.Captcha4ForgetFgt;
 import com.sheep.gamegroup.module.login.fragments.NewPasswordFgt;
+import com.sheep.gamegroup.module.login.fragments.NoPhoneTipFgt;
 import com.sheep.gamegroup.module.login.fragments.OldPasswordFgt;
 import com.sheep.gamegroup.module.login.fragments.SignInFgt;
 import com.sheep.gamegroup.util.DataUtil;
@@ -26,8 +31,14 @@ import io.reactivex.schedulers.Schedulers;
 
 public class ChangePasswordAct extends BaseActivity implements ChangePasswordController {
 
+    public final static int MODE_CHANGE = 0;
+    public final static int MODE_FORGET = 1;
+
     private String newPwd, oldPwd;
 
+    private int mode;
+    private UserEntity user;
+
     @Override
     protected int getLayoutId() {
         return R.layout.activity_login;
@@ -37,13 +48,24 @@ public class ChangePasswordAct extends BaseActivity implements ChangePasswordCon
     public void initView() {
         TitleBarUtils.getInstance().setShowOrHide(this, true);
         TitleBarUtils.getInstance().setTitleBack(this).setTitle(this, "设置密码");
-        UserEntity user = DataUtil.getInstance().getUserEntity();
-        if(user.getSet_password()==0){
-            BindAccountFgt fgt = BindAccountFgt.newInstance(this);
-            showFragment("绑定登录名密码", fgt);
-        } else {
-            OldPasswordFgt fgt = OldPasswordFgt.newInstance(this);
-            showFragment("设置密码", fgt);
+        user = DataUtil.getInstance().getUserEntity();
+        mode = getIntent().getIntExtra("mode", -1);
+        if (mode == MODE_CHANGE) {
+            if (user.getSet_password() == 0) {
+                BindAccountFgt fgt = BindAccountFgt.newInstance(this);
+                showFragment("绑定登录名密码", fgt);
+            } else {
+                OldPasswordFgt fgt = OldPasswordFgt.newInstance(this);
+                showFragment("设置密码", fgt);
+            }
+        } else if (mode == MODE_FORGET) {
+            if (TextUtils.isEmpty(user.getMobile())) {
+                NoPhoneTipFgt fgt = NoPhoneTipFgt.newInstance(this);
+                showFragment("忘记密码", fgt);
+            } else {
+                Captcha4ForgetFgt fgt = Captcha4ForgetFgt.newInstance(this);
+                showFragment("输入验证码", fgt);
+            }
         }
     }
 
@@ -66,33 +88,58 @@ public class ChangePasswordAct extends BaseActivity implements ChangePasswordCon
     @Override
     public void whenComplete(String newPwd) {
         this.newPwd = newPwd;
-
         showProgress();
         JSONObject json = new JSONObject();
-        json.put("old_password", oldPwd);
-        json.put("new_password", newPwd);
-        SheepApp.getInstance().getNetComponent().getApiService().changePassword(json)
-                .subscribeOn(Schedulers.io())
-                .observeOn(AndroidSchedulers.mainThread())
-                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
-
-                    @Override
-                    public void onNext(BaseMessage baseMessage) {
-                        hideProgress();
-                        G.shortToast("密码修改成功");
-                        finish();
-                    }
-
-                    @Override
-                    public void onError(BaseMessage baseMessage) {
-                        hideProgress();
-                        if (baseMessage != null) {
-                            G.shortToast(baseMessage);
-                        } else {
-                            G.shortToast("修改密码出错");
+        if (mode == 0) {
+            json.put("old_password", oldPwd);
+            json.put("new_password", newPwd);
+            SheepApp.getInstance().getNetComponent().getApiService().changePassword(json)
+                    .subscribeOn(Schedulers.io())
+                    .observeOn(AndroidSchedulers.mainThread())
+                    .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+
+                        @Override
+                        public void onNext(BaseMessage baseMessage) {
+                            hideProgress();
+                            G.shortToast("密码修改成功");
+                            finish();
+                        }
+
+                        @Override
+                        public void onError(BaseMessage baseMessage) {
+                            hideProgress();
+                            if (baseMessage != null) {
+                                G.shortToast(baseMessage);
+                            } else {
+                                G.shortToast("修改密码出错");
+                            }
                         }
-                    }
-                });
+                    });
+        } else {
+            json.put("password", newPwd);
+            SheepApp.getInstance().getNetComponent().getApiService().resetPass4New(json)
+                    .subscribeOn(Schedulers.io())
+                    .observeOn(AndroidSchedulers.mainThread())
+                    .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()){
+
+                        @Override
+                        public void onNext(BaseMessage baseMessage) {
+                            hideProgress();
+                            G.shortToast("密码重置成功");
+                            finish();
+                        }
+
+                        @Override
+                        public void onError(BaseMessage baseMessage) {
+                            hideProgress();
+                            if (baseMessage != null) {
+                                G.shortToast(baseMessage);
+                            } else {
+                                G.shortToast("修改密码出错");
+                            }
+                        }
+                    });
+        }
     }
 
     @Override
@@ -101,6 +148,24 @@ public class ChangePasswordAct extends BaseActivity implements ChangePasswordCon
         finish();
     }
 
+    @Override
+    public void whenCaptcha(String code) {
+        NewPasswordFgt fgt = NewPasswordFgt.newInstance(this);
+        showFragment("重置密码", fgt);
+    }
+
+    @Override
+    public void whenForget() {
+        mode = MODE_FORGET;
+        if (TextUtils.isEmpty(user.getMobile())) {
+            NoPhoneTipFgt fgt = NoPhoneTipFgt.newInstance(this);
+            showFragment("忘记密码", fgt);
+        } else {
+            Captcha4ForgetFgt fgt = Captcha4ForgetFgt.newInstance(this);
+            showFragment("输入验证码", fgt);
+        }
+    }
+
     private void showFragment(String tag, Fragment fragment) {
         FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
         transaction.replace(R.id.fragment_container, fragment, tag);
@@ -108,4 +173,11 @@ public class ChangePasswordAct extends BaseActivity implements ChangePasswordCon
         transaction.addToBackStack(null);
         transaction.commitAllowingStateLoss();
     }
+
+    public static void changePassword(Context context) {
+        Intent intent = new Intent(context, ChangePasswordAct.class);
+        intent.putExtra("mode", MODE_CHANGE);
+        context.startActivity(intent);
+    }
+
 }

+ 4 - 0
app/src/main/java/com/sheep/gamegroup/module/login/controller/ChangePasswordController.java

@@ -8,4 +8,8 @@ public interface ChangePasswordController {
 
     void whenBindAccount();
 
+    void whenCaptcha(String code);
+
+    void whenForget();
+
 }

+ 145 - 0
app/src/main/java/com/sheep/gamegroup/module/login/fragments/Captcha4ForgetFgt.java

@@ -0,0 +1,145 @@
+package com.sheep.gamegroup.module.login.fragments;
+
+
+import android.content.Context;
+import android.support.design.widget.Snackbar;
+import android.support.v4.app.Fragment;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.view.View;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.EditText;
+import android.widget.TextView;
+
+import com.alibaba.fastjson.JSONObject;
+import com.sheep.gamegroup.model.entity.BaseMessage;
+import com.sheep.gamegroup.model.entity.LoginEntity;
+import com.sheep.gamegroup.model.util.SheepSubscriber;
+import com.sheep.gamegroup.module.login.controller.ChangePasswordController;
+import com.sheep.gamegroup.module.login.controller.LoginController;
+import com.sheep.gamegroup.util.DataUtil;
+import com.sheep.gamegroup.util.PreferenceUtils;
+import com.sheep.gamegroup.util.UMConfigUtils;
+import com.sheep.gamegroup.view.customview.CountDownButton;
+import com.sheep.jiuyan.samllsheep.R;
+import com.sheep.jiuyan.samllsheep.SheepApp;
+import com.sheep.jiuyan.samllsheep.base.BaseFragment;
+import com.sheep.jiuyan.samllsheep.utils.G;
+import com.sheep.jiuyan.samllsheep.utils.SpUtils;
+
+import butterknife.BindView;
+import butterknife.OnClick;
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.schedulers.Schedulers;
+
+/**
+ * A simple {@link Fragment} subclass.
+ */
+public class Captcha4ForgetFgt extends BaseFragment {
+
+    private ChangePasswordController mController;
+
+    @BindView(R.id.tip_view)
+    TextView tipView;
+    @BindView(R.id.title_view)
+    TextView titleView;
+    @BindView(R.id.captcha_box)
+    EditText captchaBox;
+    @BindView(R.id.resend_captcha_btn)
+    CountDownButton countDownButton;
+
+    private String phoneNum;
+
+    public Captcha4ForgetFgt() {
+        // Required empty public constructor
+    }
+
+    public static Captcha4ForgetFgt newInstance(ChangePasswordController controller) {
+        Captcha4ForgetFgt fragment = new Captcha4ForgetFgt();
+        fragment.mController = controller;
+        return fragment;
+    }
+
+    @Override
+    public int getLayoutId() {
+        return R.layout.fragment_valid_captcha;
+    }
+
+    @Override
+    public void onViewCreated() {
+//        titleView.setVisibility(View.INVISIBLE);
+        phoneNum = DataUtil.getInstance().getUserEntity().getMobile();
+        tipView.setText("我们已向 " + phoneNum + " 发送验证码短信请查看短信并输入验证码");
+        captchaBox.addTextChangedListener(new TextWatcher() {
+
+            @Override
+            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+
+            }
+
+            @Override
+            public void onTextChanged(CharSequence s, int start, int before, int count) {
+                if (s != null && s.length() == 6) {
+                    submitCaptcha();
+                }
+            }
+
+            @Override
+            public void afterTextChanged(Editable s) {
+
+            }
+        });
+        countDownButton.click();
+        InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
+        imm.showSoftInput(captchaBox, InputMethodManager.SHOW_FORCED);
+    }
+
+    private void submitCaptcha() {
+        JSONObject jsonObject = new JSONObject();
+        jsonObject.put("code", captchaBox.getText().toString());
+        SheepApp.getInstance().getNetComponent().getApiService().resetPass4Valid(jsonObject)
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+                    @Override
+                    public void onError(BaseMessage baseMessage) {
+                        hideProgress();
+                        G.shortToast(baseMessage);
+                    }
+
+                    @Override
+                    public void onNext(BaseMessage baseMessage) {
+                        hideProgress();
+                        mController.whenCaptcha(captchaBox.getText().toString());
+                    }
+                });
+    }
+
+    @OnClick(R.id.resend_captcha_btn)
+    public void sendCaptcha(View v) {
+        SheepApp.getInstance().getNetComponent().getApiService().resetPass4Captcha(new JSONObject())
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+
+                    @Override
+                    public void onNext(BaseMessage baseMessage) {
+                        Snackbar.make(v, "验证码已发送", Snackbar.LENGTH_SHORT).show();
+                    }
+
+                    @Override
+                    public void onError(BaseMessage baseMessage) {
+                        Snackbar.make(v, "发生错误", Snackbar.LENGTH_SHORT).show();
+                    }
+                });
+    }
+
+    @Override
+    public void onDestroy() {
+        if (countDownButton != null) {
+            countDownButton.onDestroy();
+        }
+        super.onDestroy();
+    }
+
+}

+ 48 - 0
app/src/main/java/com/sheep/gamegroup/module/login/fragments/NoPhoneTipFgt.java

@@ -0,0 +1,48 @@
+package com.sheep.gamegroup.module.login.fragments;
+
+
+import android.support.v4.app.Fragment;
+import android.text.Editable;
+import android.text.TextUtils;
+import android.text.TextWatcher;
+import android.view.View;
+import android.widget.EditText;
+import android.widget.ImageView;
+
+import com.sheep.gamegroup.module.login.controller.ChangePasswordController;
+import com.sheep.gamegroup.module.login.controller.LoginController;
+import com.sheep.gamegroup.util.StringUtils;
+import com.sheep.jiuyan.samllsheep.R;
+import com.sheep.jiuyan.samllsheep.base.BaseFragment;
+import com.sheep.jiuyan.samllsheep.utils.G;
+
+import butterknife.BindView;
+import butterknife.OnClick;
+
+/**
+ * A simple {@link Fragment} subclass.
+ */
+public class NoPhoneTipFgt extends BaseFragment {
+
+    private ChangePasswordController mController;
+
+    public NoPhoneTipFgt() {
+        // Required empty public constructor
+    }
+
+    public static NoPhoneTipFgt newInstance(ChangePasswordController controller) {
+        NoPhoneTipFgt fragment = new NoPhoneTipFgt();
+        fragment.mController = controller;
+        return fragment;
+    }
+
+    @Override
+    public int getLayoutId() {
+        return R.layout.fragment_no_phone_tip;
+    }
+
+    @Override
+    public void onViewCreated() {
+    }
+
+}

+ 7 - 0
app/src/main/java/com/sheep/gamegroup/module/login/fragments/OldPasswordFgt.java

@@ -13,9 +13,11 @@ import android.view.ViewGroup;
 import android.widget.EditText;
 import android.widget.ImageView;
 
+import com.sheep.gamegroup.module.login.ChangePasswordAct;
 import com.sheep.gamegroup.module.login.controller.ChangePasswordController;
 import com.sheep.gamegroup.util.StringUtils;
 import com.sheep.jiuyan.samllsheep.R;
+import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.base.BaseFragment;
 import com.sheep.jiuyan.samllsheep.utils.G;
 
@@ -54,6 +56,11 @@ public class OldPasswordFgt extends BaseFragment {
 
     }
 
+    @OnClick(R.id.forget_pwd_btn)
+    public void doForgetPwd(View v) {
+        mController.whenForget();
+    }
+
     @OnClick(R.id.show_hide_pwd_btn)
     public void doShowHidePwd(View v) {
         showHidePwdBtn.setSelected(!showHidePwdBtn.isSelected());

+ 5 - 1
app/src/main/java/com/sheep/gamegroup/module/login/fragments/WelcomeFgt.java

@@ -52,7 +52,11 @@ public class WelcomeFgt extends AbsLoginFgt {
 
     @OnClick({R.id.login_btn, R.id.login_type_toggle})
     public void doToLogin(View v) {
-        mController.whenToLogin(LoginController.PLATFORM_ACCOUNT);
+        if(v.getId()==R.id.login_btn) {
+            mController.whenToLogin(LoginController.PLATFORM_ACCOUNT);
+        } else {
+            mController.whenToLogin(LoginController.PLATFORM_PHONE);
+        }
     }
 
     @OnClick(R.id.register_btn)

+ 1 - 2
app/src/main/java/com/sheep/gamegroup/util/Jump2View.java

@@ -1559,8 +1559,7 @@ public class Jump2View {
     }
 
     public void goChangePassword(Activity activity) {
-        Intent intent = new Intent(activity, ChangePasswordAct.class);
-        activity.startActivity(intent);
+        ChangePasswordAct.changePassword(activity);
         USER_CHANGE_PASSWORD.onEvent();
     }
 

+ 49 - 0
app/src/main/res/layout/fragment_no_phone_tip.xml

@@ -0,0 +1,49 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical"
+    android:paddingBottom="@dimen/content_padding_24"
+    android:paddingLeft="@dimen/content_padding_13"
+    android:paddingRight="@dimen/content_padding_24"
+    android:paddingTop="@dimen/content_padding_24">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="50dp"
+        android:gravity="center_vertical">
+
+        <View
+            android:layout_width="4dp"
+            android:layout_height="14dp"
+            android:layout_marginRight="4dp"
+            android:background="@color/btn_color_main_stroke" />
+
+        <TextView
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:text="您未设置手机号"
+            android:textColor="@color/black_6_3"
+            android:textSize="14sp"
+            android:textStyle="bold" />
+    </LinearLayout>
+
+    <TextView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginLeft="8dp"
+        android:layout_marginTop="24dp"
+        android:text="通过联系客服申述,召回无绑定手机号的小绵羊账号及密码"
+        android:textSize="12sp" />
+
+    <TextView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginLeft="8dp"
+        android:layout_marginTop="24dp"
+        android:text="客服QQ: 2441310002"
+        android:textColor="@color/btn_color_main_stroke"
+        android:textSize="12sp" />
+
+</LinearLayout>