|
|
@@ -1,13 +1,35 @@
|
|
|
package com.xzjmyk.pm.activity.ui.erp.activity.message;
|
|
|
|
|
|
+import android.app.AlertDialog;
|
|
|
+import android.content.DialogInterface;
|
|
|
import android.os.Bundle;
|
|
|
+import android.os.Handler;
|
|
|
+import android.os.Message;
|
|
|
+import android.util.Log;
|
|
|
import android.view.View;
|
|
|
+import android.widget.Button;
|
|
|
import android.widget.EditText;
|
|
|
+import android.widget.TextView;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.lidroid.xutils.ViewUtils;
|
|
|
import com.lidroid.xutils.view.annotation.ViewInject;
|
|
|
import com.xzjmyk.pm.activity.R;
|
|
|
import com.xzjmyk.pm.activity.ui.base.BaseActivity;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.net.ViewUtil;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.util.CommonUtil;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.util.Constants;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.util.JsonValidator;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.util.LogUtil;
|
|
|
+import com.xzjmyk.pm.activity.util.CalendarUtils;
|
|
|
+import com.xzjmyk.pm.activity.util.StringUtils;
|
|
|
+import com.xzjmyk.pm.activity.util.ToastUtil;
|
|
|
+import com.xzjmyk.pm.activity.view.wheel.DateTimePicker;
|
|
|
+
|
|
|
+import java.util.GregorianCalendar;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* Created by FANGlh on 2017/7/21.
|
|
|
@@ -28,23 +50,157 @@ public class PersonalRegActivity extends BaseActivity implements View.OnClickLis
|
|
|
@ViewInject(R.id.person_sign_et)
|
|
|
private EditText person_sign_et;
|
|
|
@ViewInject(R.id.register_btn)
|
|
|
- private EditText register_btn;
|
|
|
+ private Button register_btn;
|
|
|
@ViewInject(R.id.to_login_tv)
|
|
|
- private EditText to_login_tv;
|
|
|
+ private TextView to_login_tv;
|
|
|
+ private int male_log = 1;
|
|
|
+ private long bir_Timestamp = 1489141231;
|
|
|
+ private Handler rHandler = new Handler(){
|
|
|
+ @Override
|
|
|
+ public void handleMessage(Message msg) {
|
|
|
+ super.handleMessage(msg);
|
|
|
+ String result = msg.getData().getString("result");
|
|
|
+ switch (msg.what){
|
|
|
+ case 0x01:
|
|
|
+ if (!StringUtils.isEmpty(result)){
|
|
|
+ Log.i("0x01result", result);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case Constants.APP_SOCKETIMEOUTEXCEPTION:
|
|
|
+ if (new JsonValidator().validate(result)) {
|
|
|
+ ToastMessage(JSON.parseObject(result).getString("exceptionInfo"));
|
|
|
+ } else {
|
|
|
+ ToastMessage(result);
|
|
|
+ }
|
|
|
+ progressDialog.dismiss();
|
|
|
+ register_btn.setEnabled(true);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
setContentView(R.layout.personal_reg_activity);
|
|
|
+ getSupportActionBar().hide();
|
|
|
ViewUtils.inject(this);
|
|
|
initView();
|
|
|
}
|
|
|
|
|
|
private void initView() {
|
|
|
+ male_et.setKeyListener(null);
|
|
|
+ male_et.setFocusable(false);
|
|
|
+ male_et.setOnClickListener(this);
|
|
|
+
|
|
|
+ birthday_et.setKeyListener(null);
|
|
|
+ birthday_et.setFocusable(false);
|
|
|
+ birthday_et.setOnClickListener(this);
|
|
|
|
|
|
+ register_btn.setOnClickListener(this);
|
|
|
+ to_login_tv.setOnClickListener(this);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
+ switch(v.getId()){
|
|
|
+ case R.id.male_et:
|
|
|
+ showSelectSexDialog();
|
|
|
+ break;
|
|
|
+ case R.id.birthday_et:
|
|
|
+ showSelectBirthdayDialog();
|
|
|
+ break;
|
|
|
+ case R.id.register_btn:
|
|
|
+ registerJudge();
|
|
|
+ break;
|
|
|
+ case R.id.to_login_tv:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void registerJudge() {
|
|
|
+ if (StringUtils.isEmpty(phone_et.getText().toString())){
|
|
|
+ ToastMessage("请输入手机号");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(password_et.getText().toString())){
|
|
|
+ ToastMessage("请输入密码");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(name_et.getText().toString())){
|
|
|
+ ToastMessage("请输入姓名");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isEmpty(person_sign_et.getText().toString())){
|
|
|
+ ToastMessage("请输入个性签名");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ doRegiter();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void doRegiter() {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ register_btn.setEnabled(false);
|
|
|
+ String url = Constants.getAppBaseUrl(getApplicationContext()) + "user/appRegister";
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("telephone",phone_et.getText().toString());
|
|
|
+ params.put("password",password_et.getText().toString());
|
|
|
+ params.put("userType",0);
|
|
|
+ params.put("companyId",0);
|
|
|
+ params.put("nickname",name_et.getText().toString());
|
|
|
+ params.put("description",person_sign_et.getText().toString());
|
|
|
+ params.put("sex",male_log);
|
|
|
+ params.put("birthday",bir_Timestamp);
|
|
|
+ LogUtil.prinlnLongMsg("0x01params","url="+url+JSON.toJSONString(params));
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
+ headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ ViewUtil.httpSendRequest(ct, url, params, rHandler, headers, 0x01, null, null, "post");
|
|
|
+ }
|
|
|
+
|
|
|
+ private void showSelectBirthdayDialog() {
|
|
|
+ DateTimePicker picker = new DateTimePicker(this, DateTimePicker.YEAR_MONTH_DAY);
|
|
|
+ picker.setRange(1900, CalendarUtils.getCurrentYear());
|
|
|
+ picker.setOnDateTimePickListener(new DateTimePicker.OnYearMonthDayTimePickListener() {
|
|
|
+ @Override
|
|
|
+ public void onDateTimePicked(String year, String month, String day, String hour, String minute) {
|
|
|
+ Log.i(TAG, "onDateTimePicked:" + year + "-" + month + "-" + day + " " + hour + ":" + minute + ":00");
|
|
|
+ GregorianCalendar calendar = new GregorianCalendar(Integer.parseInt(year), Integer.parseInt(month) - 1, Integer.parseInt(day));
|
|
|
+
|
|
|
+ long currentTime = System.currentTimeMillis() / 1000;
|
|
|
+ long birthdayTime = calendar.getTime().getTime() / 1000;
|
|
|
+ if (birthdayTime > currentTime) {
|
|
|
+ ToastUtil.showToast(mContext, "亲!您的出生日期已经超过现在了哦!");
|
|
|
+ } else {
|
|
|
+ birthday_et.setText(year + "-" + month + "-" + day);
|
|
|
+ bir_Timestamp = birthdayTime;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ picker.show();
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
+ private void showSelectSexDialog() {
|
|
|
+ // 1是男,0是女,2是全部
|
|
|
+ String[] sexs = new String[]{ getString(R.string.user_body), getString(R.string.user_girl)};
|
|
|
+ int checkItem = 0;
|
|
|
+ new AlertDialog.Builder(this).setTitle(getString(R.string.select_sex_title))
|
|
|
+ .setSingleChoiceItems(sexs, checkItem, new DialogInterface.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(DialogInterface dialog, int which) {
|
|
|
+ if (which == 0) {
|
|
|
+ male_et.setText(R.string.user_body);
|
|
|
+ male_log = 1;
|
|
|
+ } else {
|
|
|
+ male_et.setText(R.string.user_girl);
|
|
|
+ male_log = 0;
|
|
|
+ }
|
|
|
+ dialog.dismiss();
|
|
|
+ }
|
|
|
+ }).setCancelable(true).create().show();
|
|
|
}
|
|
|
}
|