@Override
        public void handleMessage(Message msg) {
          switch (msg.what) {
            case VALIDCODE_MSG_CODE:
              djsx_tv.setVisibility(View.VISIBLE);
              yanzhengma_iv.setImageBitmap(validCodeBitmap);
              break;
            case COMMIT_ORDER_MSG_CODE:
              if (commitReturnJson.length() == 0) {
                getValidCodePic(); // 提交失败后需刷新验证码
                yanzhengma_input_et.setText("");
                progressdialog.dismiss();
                // new AlertDialog.Builder(context).setTitle("发生异常,订单提交失败!")
                // .setPositiveButton("确认", null).show();
                final CustomerAlertDialog cad = new CustomerAlertDialog(context, true);
                cad.setTitle("发生异常,订单提交失败");
                cad.setPositiveButton(
                    "知道了",
                    new OnClickListener() {
                      @Override
                      public void onClick(View arg0) {
                        cad.dismiss();
                      }
                    });
                break;
              }
              JSONTokener jsonParser;
              jsonParser = new JSONTokener(commitReturnJson);
              try {
                JSONObject jsonObject = (JSONObject) jsonParser.nextValue();
                String state = jsonObject.getString("c");

                if (state.equals("0000")) {
                  String orderID = jsonObject.getJSONObject("d").getString("msg");
                  Intent intent = new Intent(context, ActivityTrainOrderDetail.class);
                  intent.putExtra(ActivityTrainOrderDetail.ORDERRECEIPT, orderID);
                  startActivityForResult(intent, NEW_ORDER_DETAIL_CODE);

                } else {
                  // new AlertDialog.Builder(context)
                  // .setTitle(
                  // jsonObject.getJSONObject("d")
                  // .getString("msg"))
                  // .setPositiveButton("确定", null).show();
                  final CustomerAlertDialog cad = new CustomerAlertDialog(context, true);
                  cad.setTitle(jsonObject.getJSONObject("d").getString("msg"));
                  cad.setPositiveButton(
                      "知道了",
                      new OnClickListener() {
                        @Override
                        public void onClick(View arg0) {
                          cad.dismiss();
                        }
                      });
                  getValidCodePic(); // 提交失败后需刷新验证码
                  yanzhengma_input_et.setText("");
                }
                // else {
                // Toast.makeText(context, "发生异常,提交订单失败!", 0).show();
                // getValidCodePic();//提交失败后需刷新验证码
                // yanzhengma_input_et.setText("");
                // }
                progressdialog.dismiss();
              } catch (Exception e) {
                e.printStackTrace();
                getValidCodePic(); // 提交失败后需刷新验证码
                yanzhengma_input_et.setText("");
                progressdialog.dismiss();
              }
              break;
          }
        }
 private void commitOrder() {
   new Thread(
           new Runnable() {
             @Override
             public void run() {
               try {
                 MyApp ma = new MyApp(context);
                 String siteid = sp.getString(SPkeys.siteid.getString(), "65");
                 String str =
                     "{\"uid\":\""
                         + sp.getString(SPkeys.userid.getString(), "")
                         + "\",\"Amount\": \""
                         + totalPrice
                         + "\",\"sid\":\""
                         + siteid
                         + "\",\"vcode\":\""
                         + yanzhengma_input_et.getText().toString().trim()
                         + "\",\"TrainNo\":\""
                         + ti.getTrainID()
                         + "\",\"SCity\":\""
                         + ti.getStationS()
                         + "\",\"ECity\":\""
                         + ti.getStationE()
                         + "\",\"ETime\":\""
                         + ti.getETime()
                         + "\",\"STime\":\""
                         + ti.getGoTime()
                         + "\",\"SDate\":\""
                         + startdate
                         + "\",\"Mobile\":\""
                         + contact_person_phone_et.getText().toString().trim()
                         + "\",\"Email\":\"[email protected]\",\"Name\":\""
                         + sp.getString(SPkeys.username.getString(), "")
                         + "\",\"TicketCount\":\""
                         + passengerList.size()
                         + "\",\"PsgInfo\":"
                         + getPassengers()
                         + "}";
                 str = str.replace("null", "");
                 String orgin = ma.getHm().get(PackageKeys.ORGIN.getString()).toString();
                 String param =
                     "?action=trainorderv2&userkey="
                         + ma.getHm().get(PackageKeys.USERKEY.getString()).toString()
                         + "&sitekey="
                         + MyApp.sitekey
                         + "&sign="
                         + CommonFunc.MD5(
                             ma.getHm().get(PackageKeys.USERKEY.getString()).toString()
                                 + "trainorderv2"
                                 + str)
                         + "&orgin="
                         + orgin;
                 // try {
                 // str = URLEncoder.encode(str, "utf-8");
                 // } catch (UnsupportedEncodingException e) {
                 // // TODO Auto-generated catch block
                 // e.printStackTrace();
                 // }
                 commitReturnJson = HttpUtils.myPost(ma.getServeUrl() + param, "&str=" + str);
                 Message msg = new Message();
                 msg.what = COMMIT_ORDER_MSG_CODE;
                 handler.sendMessage(msg);
               } catch (Exception e) {
                 e.printStackTrace();
               }
             }
           })
       .start();
   progressdialog = CustomProgressDialog.createDialog(context);
   progressdialog.setMessage("正在提交订单,请稍候...");
   progressdialog.setCancelable(true);
   progressdialog.setOnCancelListener(
       new OnCancelListener() {
         @Override
         public void onCancel(DialogInterface dialog) {}
       });
   progressdialog.show();
 }