hanjing пре 6 година
родитељ
комит
f631a0efe5

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

@@ -1938,6 +1938,9 @@ public interface ApiService {
     @POST("app/user/set_pay_pwd")
     @POST("app/user/set_pay_pwd")
     Observable<BaseMessage> setPayPwd(@Body JSONObject jsonObject);
     Observable<BaseMessage> setPayPwd(@Body JSONObject jsonObject);
 
 
+    @POST("app/user/clear_pay_pwd")
+    Observable<BaseMessage> clearPayPwd();
+
     @POST("app/user/send_sms_captcha")
     @POST("app/user/send_sms_captcha")
     Observable<BaseMessage> sendSmsCaptcha();
     Observable<BaseMessage> sendSmsCaptcha();
 
 

+ 23 - 4
app/src/main/java/com/sheep/gamegroup/module/pay/activity/ActPayPassword.java

@@ -42,6 +42,7 @@ public class ActPayPassword extends BaseContainerActivity {
     public final static int ACTION_SEND_CAPTCHA = 3;
     public final static int ACTION_SEND_CAPTCHA = 3;
     public final static int ACTION_CONFIRM_UPDATE = 4;
     public final static int ACTION_CONFIRM_UPDATE = 4;
     public final static int ACTION_VERIFY_PAY_PWD = 5;
     public final static int ACTION_VERIFY_PAY_PWD = 5;
+    public final static int ACTION_CANCEL_PWD = 6;
 
 
     @BindView(R.id.frame_container)
     @BindView(R.id.frame_container)
     View container;
     View container;
@@ -60,20 +61,22 @@ public class ActPayPassword extends BaseContainerActivity {
     @Override
     @Override
     protected Fragment initFragment() {
     protected Fragment initFragment() {
         int action = getIntent().getIntExtra("action", -1);
         int action = getIntent().getIntExtra("action", -1);
-        return getFragment(action);
+        return getFragment(action, "");
     }
     }
 
 
-    private Fragment getFragment(int action) {
+    private Fragment getFragment(int action, String extra) {
         if (action == ACTION_COMPLETION) {
         if (action == ACTION_COMPLETION) {
             return new CompletionInfoFragment();
             return new CompletionInfoFragment();
         } else if (action == ACTION_SEND_CAPTCHA) {
         } else if (action == ACTION_SEND_CAPTCHA) {
-            return CheckCaptchaFragment.newInstance(getIntent().getStringExtra("mobile"));
+            return CheckCaptchaFragment.newInstance(getIntent().getStringExtra("mobile"), CheckCaptchaFragment.FOR_SET, "");
         } else if (action == ACTION_CONFIRM_UPDATE) {
         } else if (action == ACTION_CONFIRM_UPDATE) {
             return new ConfirmUpdateFragment();
             return new ConfirmUpdateFragment();
         } else if (action == ACTION_SET_PWD) {
         } else if (action == ACTION_SET_PWD) {
             return new SetPasswordFragment();
             return new SetPasswordFragment();
         } else if (action == ACTION_VERIFY_PAY_PWD) {
         } else if (action == ACTION_VERIFY_PAY_PWD) {
             return VerifyPayPwdFragment.newInstance(getIntent().getStringExtra("token"), getIntent().getStringExtra("ext"));
             return VerifyPayPwdFragment.newInstance(getIntent().getStringExtra("token"), getIntent().getStringExtra("ext"));
+        } else if (action == ACTION_CANCEL_PWD) {
+            return CheckCaptchaFragment.newInstance(getIntent().getStringExtra("mobile"), CheckCaptchaFragment.FOR_CLEAR, extra);
         } else {
         } else {
             return null;
             return null;
         }
         }
@@ -81,7 +84,7 @@ public class ActPayPassword extends BaseContainerActivity {
 
 
     @Subscribe
     @Subscribe
     public void whenActionComming(PayPasswordEvent ev) {
     public void whenActionComming(PayPasswordEvent ev) {
-        replaceFragment(getFragment(ev.action));
+        replaceFragment(getFragment(ev.action, ev.extra));
     }
     }
 
 
     public static void setPwd(Context context) {
     public static void setPwd(Context context) {
@@ -101,6 +104,16 @@ public class ActPayPassword extends BaseContainerActivity {
         });
         });
     }
     }
 
 
+    public static void clearPwd(Context context) {
+        CommonUtil.getInstance().getUserInfo(SpUtils.getToken(context), (user) -> {
+            if (user == null) return;
+            Intent in = new Intent(context, ActPayPassword.class);
+            in.putExtra("action", ACTION_CANCEL_PWD);
+            in.putExtra("mobile", user.getMobile());
+            context.startActivity(in);
+        });
+    }
+
     public static void verifyPwd(Activity activity, String token, String ext, PayPasswordCallback callback) {
     public static void verifyPwd(Activity activity, String token, String ext, PayPasswordCallback callback) {
         CommonUtil.getInstance().getUserInfo(token, (user) -> {
         CommonUtil.getInstance().getUserInfo(token, (user) -> {
             if (user != null && user.hasPayPwd()) {
             if (user != null && user.hasPayPwd()) {
@@ -122,10 +135,16 @@ public class ActPayPassword extends BaseContainerActivity {
 
 
     public static class PayPasswordEvent {
     public static class PayPasswordEvent {
         public int action;
         public int action;
+        public String extra;
 
 
         public PayPasswordEvent(int action) {
         public PayPasswordEvent(int action) {
             this.action = action;
             this.action = action;
         }
         }
+
+        public PayPasswordEvent(int action, String extra) {
+            this.action = action;
+            this.extra = extra;
+        }
     }
     }
 
 
 }
 }

+ 39 - 2
app/src/main/java/com/sheep/gamegroup/module/pay/fragment/CheckCaptchaFragment.java

@@ -1,8 +1,11 @@
 package com.sheep.gamegroup.module.pay.fragment;
 package com.sheep.gamegroup.module.pay.fragment;
 
 
+import android.app.Activity;
+import android.content.Intent;
 import android.support.design.widget.Snackbar;
 import android.support.design.widget.Snackbar;
 import android.text.TextUtils;
 import android.text.TextUtils;
 import android.util.Log;
 import android.util.Log;
+import android.view.View;
 import android.widget.EditText;
 import android.widget.EditText;
 import android.widget.TextView;
 import android.widget.TextView;
 
 
@@ -27,6 +30,9 @@ import io.reactivex.schedulers.Schedulers;
 
 
 public class CheckCaptchaFragment extends AbsConfirmFragment {
 public class CheckCaptchaFragment extends AbsConfirmFragment {
 
 
+    public final static int FOR_SET = 0;
+    public final static int FOR_CLEAR = 1;
+
     @BindView(R.id.send_captcha_btn)
     @BindView(R.id.send_captcha_btn)
     CountDownButton countDownButton;
     CountDownButton countDownButton;
     @BindView(R.id.mobile_view)
     @BindView(R.id.mobile_view)
@@ -35,10 +41,14 @@ public class CheckCaptchaFragment extends AbsConfirmFragment {
     EditText captchaBox;
     EditText captchaBox;
 
 
     private String mobile;
     private String mobile;
+    private int forWhat = FOR_SET;
+    private String ext;
 
 
-    public static CheckCaptchaFragment newInstance(String mobile){
+    public static CheckCaptchaFragment newInstance(String mobile, int fw, String ext) {
         CheckCaptchaFragment fragment = new CheckCaptchaFragment();
         CheckCaptchaFragment fragment = new CheckCaptchaFragment();
         fragment.mobile = mobile;
         fragment.mobile = mobile;
+        fragment.forWhat = fw;
+        fragment.ext = ext;
         return fragment;
         return fragment;
     }
     }
 
 
@@ -99,7 +109,34 @@ public class CheckCaptchaFragment extends AbsConfirmFragment {
 
 
                     @Override
                     @Override
                     public void onNext(BaseMessage baseMessage) {
                     public void onNext(BaseMessage baseMessage) {
-                        EventBus.getDefault().post(new ActPayPassword.PayPasswordEvent(ActPayPassword.ACTION_SET_PWD));
+                        if (forWhat == FOR_SET) {
+                            EventBus.getDefault().post(new ActPayPassword.PayPasswordEvent(ActPayPassword.ACTION_SET_PWD));
+                        } else if (forWhat == FOR_CLEAR) {
+                            clearPwd();
+                        }
+                    }
+
+                    @Override
+                    public void onError(BaseMessage baseMessage) {
+                        G.showToast(baseMessage);
+                    }
+                });
+    }
+
+    private void clearPwd(){
+        SheepApp.getInstance().getNetComponent().getApiService().clearPayPwd()
+                .subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
+
+                    @Override
+                    public void onNext(BaseMessage baseMessage) {
+                        DataUtil.getInstance().getUserEntity().setHas_pay_pwd(0);
+                        G.showToast("已关闭支付密码");
+                        Intent out = new Intent();
+                        out.putExtra("ext", ext);
+                        getActivity().setResult(Activity.RESULT_OK, out);
+                        getActivity().finish();
                     }
                     }
 
 
                     @Override
                     @Override

+ 14 - 0
app/src/main/java/com/sheep/gamegroup/module/pay/fragment/VerifyPayPwdFragment.java

@@ -8,12 +8,18 @@ import android.widget.TextView;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.util.SheepSubscriber;
 import com.sheep.gamegroup.model.util.SheepSubscriber;
+import com.sheep.gamegroup.module.pay.activity.ActPayPassword;
+import com.sheep.gamegroup.util.CommonUtil;
 import com.sheep.gamegroup.view.customview.VerificationCodeEditText;
 import com.sheep.gamegroup.view.customview.VerificationCodeEditText;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.utils.G;
 import com.sheep.jiuyan.samllsheep.utils.G;
+import com.sheep.jiuyan.samllsheep.utils.SpUtils;
+
+import org.greenrobot.eventbus.EventBus;
 
 
 import butterknife.BindView;
 import butterknife.BindView;
+import butterknife.OnClick;
 import butterknife.OnEditorAction;
 import butterknife.OnEditorAction;
 import butterknife.OnTextChanged;
 import butterknife.OnTextChanged;
 import io.reactivex.android.schedulers.AndroidSchedulers;
 import io.reactivex.android.schedulers.AndroidSchedulers;
@@ -49,6 +55,14 @@ public class VerifyPayPwdFragment extends AbsConfirmFragment {
         }
         }
     }
     }
 
 
+    @OnClick(R.id.cancel_pay_pwd_btn)
+    public void onClosePayPassword(View view) {
+        CommonUtil.getInstance().getUserInfo(SpUtils.getToken(getContext()), (user) -> {
+            if (user == null) return;
+            getActivity().getIntent().putExtra("mobile", user.getMobile());
+            EventBus.getDefault().post(new ActPayPassword.PayPasswordEvent(ActPayPassword.ACTION_CANCEL_PWD, ext));
+        });
+    }
 
 
     @Override
     @Override
     public int getInnerLayoutId() {
     public int getInnerLayoutId() {

+ 11 - 1
app/src/main/java/com/sheep/gamegroup/view/activity/ActSetting.java

@@ -69,7 +69,17 @@ public class ActSetting extends BaseActivity {
 
 
     public void onResume() {
     public void onResume() {
         super.onResume();
         super.onResume();
-        CommonUtil.getInstance().getUserInfo(false, (user) -> payPwdFlag.setText(user.hasPayPwd() ? "已设置" : "未设置"));
+        CommonUtil.getInstance().getUserInfo(false, (user) -> {
+            if(user.hasPayPwd()){
+                ViewUtil.setText(payPwdFlag, "去关闭");
+                ViewUtil.setOnClickListener(payPwdFlag, v->{
+                    ActPayPassword.clearPwd(activity);
+                });
+            } else {
+                ViewUtil.setText(payPwdFlag, "未设置");
+                ViewUtil.setOnClickListener(payPwdFlag, null);
+            }
+        });
     }
     }
 
 
     @Override
     @Override

+ 16 - 0
app/src/main/res/layout/pay_pwd_verify_pwd_fgt.xml

@@ -31,4 +31,20 @@
         android:visibility="invisible"
         android:visibility="invisible"
         android:textSize="13sp" />
         android:textSize="13sp" />
 
 
+    <TextView android:id="@+id/cancel_pay_pwd_btn"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="30dp"
+        android:text="@string/close_pay_password"
+        android:textSize="13sp"
+        android:textColor="#333333" />
+
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="12dp"
+        android:text="注意: 一旦关闭支付时不需要输入密码"
+        android:textSize="12sp"
+        android:textColor="#999999" />
+
 </LinearLayout>
 </LinearLayout>

+ 1 - 0
app/src/main/res/values/strings.xml

@@ -1,4 +1,5 @@
 <resources>
 <resources>
+    <string name="close_pay_password"><u>关闭支付密码</u></string>
     <string name="get_captcha">获取验证码</string>
     <string name="get_captcha">获取验证码</string>
     <string name="input_your_phone">请输入你的手机号</string>
     <string name="input_your_phone">请输入你的手机号</string>
     <string name="input_your_captcha">请输验证码</string>
     <string name="input_your_captcha">请输验证码</string>