예제 #1
0
  /**
   * @Title: submitOrder @Description: TODO(提交课程 订单)
   *
   * @param 设定文件
   * @return void 返回类型
   * @throws
   */
  private void submitOrder() {
    RequestParams params = new RequestParams(); //
    params.put("user_id", YoutiApplication.getInstance().myPreference.getUserId());
    params.put("course_id", id);
    HttpUtils.post(
        Constants.ORDER_COURSE,
        params,
        new JsonHttpResponseHandler() {
          public void onStart() {
            super.onStart();
            dialog.show();
          }

          public void onFailure(
              int statusCode,
              org.apache.http.Header[] headers,
              java.lang.Throwable throwable,
              org.json.JSONObject errorResponse) {
            dialog.dismiss();
          };

          @Override
          public void onFinish() {
            // TODO Auto-generated method stub
            super.onFinish();
            dialog.dismiss();
          }

          public void onSuccess(
              int statusCode, org.apache.http.Header[] headers, org.json.JSONObject response) {
            try {

              /*code:400教练id为空
              code:401用户id为空
              code:402单价为空
              code:403时长为空
              code:404上课方式为空
              code:0下单失败
              code:1下单成功
              */
              String state = response.getString("code");
              if (state.equals("1")) {
                com.alibaba.fastjson.JSONObject object = JSON.parseObject(response.toString());
                JSONObject jsonObject = object.getJSONObject("list");
                orderCourse = JSON.parseObject(jsonObject.toString(), OrderCourse.class);
                Bundle b = new Bundle();
                b.putInt("orderType", Constants.REQUEST_CODE_PAY_COURSE);
                b.putSerializable(Constants.KEY_ORDER_COURSE, orderCourse);
                IntentJumpUtils.nextActivity(
                    OrderCoachActivity.class, CourseDetailActivity.this, b);
              }
            } catch (Exception e) {
            }
          };
        });
  }
예제 #2
0
  @Override
  public void onClick(View v) {

    switch (v.getId()) {
      case R.id.bt_book:
        if (!YoutiApplication.getInstance().myPreference.getHasLogin()) {
          IntentJumpUtils.nextActivity(
              LoginActivity.class, this, null, Constants.REQUEST_CODE_DETAIL_COURSE);
          return;
        }
        bookFlag();
        break;

      case R.id.bt_buy:
        if (!YoutiApplication.getInstance().myPreference.getHasLogin()) {
          IntentJumpUtils.nextActivity(
              LoginActivity.class, this, null, Constants.REQUEST_CODE_DETAIL_COURSE);
          return;
        }
        submitOrder();
        break;
      case R.id.title_share:
        // Utils.showToast(CourseDetailActivity.this, "分享该页面");
        if (!YoutiApplication.getInstance().myPreference.getHasLogin()) {
          IntentJumpUtils.nextActivity(
              LoginActivity.class, this, null, Constants.REQUEST_CODE_DETAIL_COURSE);
          return;
        }
        mController
            .getConfig()
            .setPlatforms(
                SHARE_MEDIA.WEIXIN,
                SHARE_MEDIA.WEIXIN_CIRCLE,
                SHARE_MEDIA.QQ,
                SHARE_MEDIA.QZONE,
                SHARE_MEDIA.SINA);
        mController.openShare(CourseDetailActivity.this, false);
        break;
      default:
        break;
    }
  }
예제 #3
0
  private void bookFlag() {

    RequestParams params = new RequestParams(); //
    params.put("user_id", YoutiApplication.getInstance().myPreference.getUserId());
    params.put("course_id", id);
    HttpUtils.post(
        Constants.BOOK_COURSE_FLAG,
        params,
        new JsonHttpResponseHandler() {
          public void onStart() {
            super.onStart();
          }

          public void onFailure(
              int statusCode,
              org.apache.http.Header[] headers,
              java.lang.Throwable throwable,
              org.json.JSONObject errorResponse) {};

          @Override
          public void onFinish() {
            // TODO Auto-generated method stub
            super.onFinish();
          }

          public void onSuccess(
              int statusCode, org.apache.http.Header[] headers, org.json.JSONObject response) {
            try {

              /* code:402该用户没有购买该俱乐部的通卡
              				code:403约课次数已用完
              				code:0约课失败
              				code:1约课成功
              */
              String state = response.getString("code");
              if (state.equals("1")) {
                IntentJumpUtils.nextActivity(
                    MyCourseActivity.class, CourseDetailActivity.this, null);
              } else if (state.equals("402")) {
                Utils.showToast(mContext, "您没有购买该俱乐部的通卡");
              } else if (state.equals("403")) {
                Utils.showToast(mContext, "您的约课次数已用完");
              } else if (state.equals("0")) {
                Utils.showToast(mContext, "约课失败请稍后重试");
              }

            } catch (Exception e) {
            }
          };
        });
  }