private void authLogin(String openId, String accessToken, final int type) { loadingDialog.show(); APIControl.getInstance() .authLogin( WXEntryActivity.this, openId, accessToken, type + "", new DataResponseListener<UserData>() { @Override public void onResponse(UserData user) { loadingDialog.dismiss(); if (user.getStatus() == 200) { SharedPreUtil.getInstance().putUser(user.getData().getUserInfo()); GeekApplication.setUser(user.getData().getUserInfo()); // Intent intent = new Intent(WXEntryActivity.this, // MainActivity.class); sendBroadcast(new Intent("com.geek.geekmall.action.user_login")); finish(); } else if (user.getStatus() == 118) { Intent intent = new Intent(WXEntryActivity.this, BindAccountActivity.class); intent.putExtra("user", WXEntryActivity.this.user); intent.putExtra("type", type); startActivity(intent); finish(); } } }, errorListener("")); }
private void authRegister() { if (mPhoneET.getText().toString().length() == 0) { new ToastView(this, "请输入手机号").show(); return; } if (mCodeET.getText().toString().length() == 0) { new ToastView(this, "请输入验证码").show(); return; } if (user != null) { APIControl.getInstance() .authRegister( this, user.getOpenId(), mPhoneET.getText().toString(), mCodeET.getText().toString(), user.getAccessToken(), type, user.getImgUrl(), user.getNickname(), user.getSex(), new DataResponseListener<UserData>() { @Override public void onResponse(UserData user) { // sendBroadcast(new Intent("com.geek.geekmall.action.auth")); if (user.getStatus() != 200) { new ToastView(BindAccountActivity.this, user.getErrorMsg()).show(); } else { GeekApplication.setUser(user.getData().getUserInfo()); SharedPreUtil.getInstance().putUser(user.getData().getUserInfo()); GeekApplication.setAgentInfo(user.getData().getAgentInfo()); GeekApplication.setOrderInfo(user.getData().getOrderInfo()); GeekApplication.setUserMoney(user.getData().getUserMoney()); // sendBroadcast(new // Intent("com.geek.geekmall.action.auth.sina")); // Intent intent = new // Intent(BindAccountActivity.this, MainActivity.class); // intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // startActivity(intent); sendBroadcast(new Intent("com.geek.geekmall.action.user_login")); finish(); } } }, errorListener("")); } }
private void getGuessLike() { loadingDialog.show(); APIControl.getInstance() .guessLike( this, userId, 10 + "", new DataResponseListener<ProductPageData>() { @Override public void onResponse(ProductPageData productPageData) { loadingDialog.dismiss(); if (productPageData.getStatus() == 200) { mLikeAdapter.setmProducts(productPageData.getData().getDataList()); mLikeAdapter.notifyDataSetChanged(); } } }, errorListener()); }
public void modifyCarts(String cardId, String number) { loadingDialog.show(); APIControl.getInstance() .modifyCart( this, userId, token, number, cardId, new DataResponseListener<CommonData>() { @Override public void onResponse(CommonData cartData) { loadingDialog.dismiss(); if (cartData.getStatus() == 200) { // getCarts(); } } }, errorListener()); }
private void settlement() { loadingDialog.show(); APIControl.getInstance() .settlementCart( this, userId, token, mAdapter.getChecked(), new DataResponseListener<BuyData>() { @Override public void onResponse(BuyData buyData) { loadingDialog.dismiss(); Intent intent = new Intent(); intent.putExtra("list", buyData.getData()); intent.setClass(ShoppingCartActivity.this, SettlementActivity.class); startActivity(intent); } }, errorListener()); }
private void deleteAddress(final Address address) { loadingDialog.show(); APIControl.getInstance() .deleteAddress( this, address.getId(), user.getId(), user.getToken(), new DataResponseListener<CommonData>() { @Override public void onResponse(CommonData o) { loadingDialog.dismiss(); if (o.getStatus() == 200) { getAddressList(); } else { } } }, errorListener("")); }
private void getCarts() { loadingDialog.show(); APIControl.getInstance() .getCartList( this, userId, token, new DataResponseListener<CartData>() { @Override public void onResponse(CartData cartData) { loadingDialog.dismiss(); mScrollView.onRefreshComplete(); // TODO 是否分页 if (cartData.getStatus() == 200) { if (cartData.getData().getValidInfoList() != null) { mStores = cartData.getData().getValidInfoList(); mAdapter.setmStores(mStores); mAdapter.notifyDataSetChanged(); for (int i = 0; i < cartData.getData().getValidInfoList().size(); i++) { mListView.expandGroup(i); } } } else { new ToastView(ShoppingCartActivity.this, cartData.getErrorMsg()).show(); } if (mStores == null || mStores.isEmpty()) { mListView.setVisibility(View.GONE); mBottomLayout.setVisibility(View.GONE); mEmptyLayout.setVisibility(View.VISIBLE); } else { mEmptyLayout.setVisibility(View.GONE); mListView.setVisibility(View.VISIBLE); mBottomLayout.setVisibility(View.VISIBLE); } } }, errorListener()); }
@Override public void onResp(BaseResp baseResp) { MyLog.debug(WXEntryActivity.class, baseResp.errCode + "---" + baseResp.openId + "==="); switch (baseResp.errCode) { case BaseResp.ErrCode.ERR_OK: if (baseResp instanceof SendAuth.Resp) { String code = ((SendAuth.Resp) baseResp).code; loadingDialog.show(); APIControl.getInstance() .weixinLogin( this, code, new DataResponseListener<WeXinResponse>() { @Override public void onResponse(WeXinResponse weXinResponse) { user.setAccessToken(weXinResponse.getAccess_token()); getWexinUserInfo(weXinResponse.getAccess_token(), weXinResponse.getOpenid()); // new // ToastView(WXEntryActivity.this,"333333333").show(); } }, errorListener("")); } else { new ToastView(this, "分享成功").show(); finish(); } // finish(); break; case BaseResp.ErrCode.ERR_USER_CANCEL: new ToastView(this, "取消分享").show(); finish(); break; default: break; } // finish(); }
private void getAddressList() { loadingDialog.show(); APIControl.getInstance() .getAddressList( this, userId, token, new DataResponseListener<AddressListData>() { @Override public void onResponse(AddressListData o) { loadingDialog.dismiss(); if (o.getStatus() == 200 && o.getData() != null && !o.getData().getDataList().isEmpty()) { mEmptyView.setVisibility(View.GONE); mAdapter.setmAddresses(o.getData().getDataList()); mAdapter.notifyDataSetChanged(); } else { mEmptyView.setVisibility(View.VISIBLE); } } }, errorListener(URLs.GET_ADDRESSLIST_URL)); }