Przeglądaj źródła

增加第一步UI逻辑及网络接口

zhanghai 8 lat temu
rodzic
commit
329ab8a7cd

+ 129 - 6
app/src/main/java/com/sheep/groups/creditcard/CITICBankOtherInfoFragment1.java

@@ -1,20 +1,58 @@
 package com.sheep.groups.creditcard;
 
-import android.graphics.Color;
-import android.text.Html;
+import android.os.Bundle;
 import android.text.Spannable;
 import android.text.SpannableStringBuilder;
+import android.text.TextUtils;
 import android.text.style.ForegroundColorSpan;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.EditText;
 import android.widget.TextView;
+import android.widget.Toast;
 
+import com.kfzs.libs.di.http.HttpService;
+import com.kfzs.libs.widget.alpha.AlphaButton;
 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.SpUtils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+import butterknife.OnClick;
+import butterknife.Unbinder;
+import rx.Observer;
+import rx.android.schedulers.AndroidSchedulers;
+import rx.schedulers.Schedulers;
 
 /**
  * Created by realicing on 2018/4/4.
  * realicing@sina.com
  */
 public class CITICBankOtherInfoFragment1 extends BaseFragment {
+    @BindView(R.id.citic_province)
+    EditText citicProvince;
+    @BindView(R.id.citic_city)
+    EditText citicCity;
+    @BindView(R.id.citic_area)
+    EditText citicArea;
+    @BindView(R.id.citic_addr_et)
+    EditText citicAddrEt;
+    @BindView(R.id.citic_area_code)
+    EditText citicAreaCode;
+    @BindView(R.id.citic_phone_et)
+    EditText citicPhoneEt;
+    @BindView(R.id.citic_email_et)
+    EditText citicEmailEt;
+    @BindView(R.id.btn_citic_next_step)
+    AlphaButton btnCiticNextStep;
+    Unbinder unbinder;
+
     @Override
     public int getLayoutId() {
         return R.layout.fragment_citic_bank_other_info1;
@@ -29,20 +67,105 @@ public class CITICBankOtherInfoFragment1 extends BaseFragment {
 
     /**
      * 设置第一个字符颜色为红色
+     *
      * @param textView
      */
-    public static void setFirstRed(TextView textView){
+    public static void setFirstRed(TextView textView) {
         setFirstRed(textView, textView.getText().toString());
     }
 
     /**
      * 设置第一个字符颜色为红色
+     *
      * @param textView
      * @param text
      */
-    public static void setFirstRed(TextView textView, String text){
-        SpannableStringBuilder style=new SpannableStringBuilder(text);
-        style.setSpan(new ForegroundColorSpan(0xffD1021E),0,1,Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
+    public static void setFirstRed(TextView textView, String text) {
+        SpannableStringBuilder style = new SpannableStringBuilder(text);
+        style.setSpan(new ForegroundColorSpan(0xffD1021E), 0, 1, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
         textView.setText(style);
     }
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+        View rootView = super.onCreateView(inflater, container, savedInstanceState);
+        unbinder = ButterKnife.bind(this, rootView);
+        return rootView;
+    }
+
+    @Override
+    public void onDestroyView() {
+        super.onDestroyView();
+        unbinder.unbind();
+    }
+
+    @OnClick(R.id.btn_citic_next_step)
+    public void onViewClicked() {
+        String strProvince = citicProvince.getText().toString();
+        if(TextUtils.isEmpty(strProvince)){
+            showToast("请输入省份");
+            return;
+        }
+        String strCity = citicCity.getText().toString();
+        if(TextUtils.isEmpty(strCity)){
+            showToast("请输入城市");
+            return;
+        }
+        String strArea = citicArea.getText().toString();
+        if(TextUtils.isEmpty(strArea)){
+            showToast("请输入区");
+            return;
+        }
+        String strAddr = citicAddrEt.getText().toString();
+        if(TextUtils.isEmpty(strAddr)){
+            showToast("请输入详细地址");
+            return;
+        }
+        String strAreaCode = citicAreaCode.getText().toString();
+        String strPhone = citicPhoneEt.getText().toString();
+        String strEmail = citicEmailEt.getText().toString();
+        if(TextUtils.isEmpty(strEmail)){
+            showToast("请输入电子邮件");
+            return;
+        }
+
+        //亲属
+        Map<String,String> map = new HashMap<>();
+        map.put("token", SpUtils.getOpenId(SheepApp.mContext));
+        map.put("province",strProvince);
+        map.put("city",strCity);
+        map.put("district",strArea);
+        map.put("address",strAddr);
+        map.put("tel_1",strAreaCode);
+
+        //紧急联系人
+        map.put("tel_2",strPhone);
+        map.put("email",strEmail);
+
+        HttpService httpService = SheepApp.getInstance().getHttpComponent().getHttpService();
+        httpService.zxContact(map).subscribeOn(Schedulers.io())
+                .observeOn(AndroidSchedulers.mainThread())
+                .subscribe(new Observer<String>() {
+                    @Override
+                    public void onCompleted() {
+                    }
+
+                    @Override
+                    public void onError(Throwable throwable) {
+
+                    }
+
+                    @Override
+                    public void onNext(String s) {
+                        /// ??? 提交完成后,去哪儿????
+
+                        showToast("数据发送成功");
+                    }
+                });
+
+    }
+
+    private void showToast(String text){
+        Toast.makeText(SheepApp.mContext,text,Toast.LENGTH_SHORT).show();
+    }
 }

+ 1 - 1
app/src/main/res/layout/fragment_citic_bank_other_info1.xml

@@ -209,7 +209,7 @@
     </android.support.constraint.ConstraintLayout>
 
     <com.kfzs.libs.widget.alpha.AlphaButton
-        android:id="@+id/btn_citic_commit"
+        android:id="@+id/btn_citic_next_step"
         style="@style/citic_creditCardBtnGradientStyle"
         android:text="下一步 >"/>