|
|
@@ -0,0 +1,180 @@
|
|
|
+package com.modular.login;
|
|
|
+
|
|
|
+import android.os.Bundle;
|
|
|
+import android.os.Handler;
|
|
|
+import android.os.Message;
|
|
|
+import android.view.View;
|
|
|
+import android.widget.Button;
|
|
|
+import android.widget.TextView;
|
|
|
+import android.widget.Toast;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.andreabaccega.widget.FormEditText;
|
|
|
+import com.common.LogUtil;
|
|
|
+import com.common.data.JSONUtil;
|
|
|
+import com.common.data.StringUtil;
|
|
|
+import com.common.hmac.Md5Util;
|
|
|
+import com.core.app.Constants;
|
|
|
+import com.core.base.BaseActivity;
|
|
|
+import com.core.net.http.ViewUtil;
|
|
|
+import com.core.net.utils.NetUtils;
|
|
|
+import com.core.utils.CommonUtil;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 个人用户注册
|
|
|
+ */
|
|
|
+public class PersonalRegActivity extends BaseActivity implements View.OnClickListener {
|
|
|
+
|
|
|
+ private FormEditText phone_et;
|
|
|
+ private FormEditText password_et;
|
|
|
+ private FormEditText name_et;
|
|
|
+ private Button register_btn;
|
|
|
+ private TextView to_login_tv;
|
|
|
+
|
|
|
+ private int male_log = 1;
|
|
|
+ private long bir_Timestamp = 1489141231;
|
|
|
+ private String md5_password;
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onCreate(Bundle savedInstanceState) {
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
+ setContentView(R.layout.personal_reg_activity);
|
|
|
+ getSupportActionBar().hide();
|
|
|
+ phone_et=(FormEditText) findViewById(R.id.phone_et);
|
|
|
+ password_et=(FormEditText) findViewById(R.id.password_et);
|
|
|
+ name_et=(FormEditText) findViewById(R.id.name_et);
|
|
|
+ register_btn= (Button) findViewById(R.id.register_btn);
|
|
|
+ to_login_tv= (TextView) findViewById(R.id.to_login_tv);
|
|
|
+ initView();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initView() {
|
|
|
+ register_btn.setOnClickListener(this);
|
|
|
+ to_login_tv.setOnClickListener(this);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ int i = v.getId();
|
|
|
+ if (i == R.id.male_et) {
|
|
|
+ //showSelectSexDialog();
|
|
|
+
|
|
|
+ } else if (i == R.id.birthday_et) {
|
|
|
+ // showSelectBirthdayDialog();
|
|
|
+
|
|
|
+ } else if (i == R.id.register_btn) {
|
|
|
+ registerJudge();
|
|
|
+
|
|
|
+ } else if (i == R.id.to_login_tv) {
|
|
|
+ finish();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void registerJudge() {
|
|
|
+ if (phone_et.testValidity() && password_et.testValidity() && name_et.testValidity()) {
|
|
|
+ if (!NetUtils.isNetWorkConnected(this)) {
|
|
|
+ ToastMessage(getString(R.string.common_notlinknet));
|
|
|
+ } else {
|
|
|
+ md5_password = Md5Util.toMD5(password_et.getText().toString());
|
|
|
+ doRegiter();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void doRegiter() {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ String url = "http://113.105.74.140:8092/" + "user/appRegister";
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("telephone", phone_et.getText().toString());
|
|
|
+ params.put("password", md5_password);
|
|
|
+ params.put("userType", 0);
|
|
|
+ params.put("companyId", 0);
|
|
|
+ params.put("nickname", name_et.getText().toString());
|
|
|
+ params.put("description", "");
|
|
|
+ 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(1960, CalendarUtil.getYear());
|
|
|
+// 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();
|
|
|
+//
|
|
|
+// }
|
|
|
+
|
|
|
+ // // 1是男,0是女,2是全部
|
|
|
+// private void showSelectSexDialog() {
|
|
|
+// 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();
|
|
|
+// }
|
|
|
+
|
|
|
+ private Handler rHandler = new Handler() {
|
|
|
+ @Override
|
|
|
+ public void handleMessage(Message msg) {
|
|
|
+ String result = msg.getData().getString("result");
|
|
|
+ switch (msg.what) {
|
|
|
+ case 0x01:
|
|
|
+ if (!StringUtil.isEmpty(result)) {
|
|
|
+ if (result.contains("resultCode") && JSON.parseObject(result).getInteger("resultCode") == 1) {
|
|
|
+ Toast.makeText(ct, "注册成功", Toast.LENGTH_LONG).show();
|
|
|
+ finish();
|
|
|
+ } else {
|
|
|
+ ToastMessage(JSON.parseObject(result).getString("resultMsg"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case Constants.APP_SOCKETIMEOUTEXCEPTION:
|
|
|
+ if (JSONUtil.validate(result)) {
|
|
|
+ ToastMessage(JSON.parseObject(result).getString("exceptionInfo"));
|
|
|
+ } else {
|
|
|
+ ToastMessage(result);
|
|
|
+ }
|
|
|
+ progressDialog.dismiss();
|
|
|
+ register_btn.setEnabled(true);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+}
|