package com.haicaojie.android;
|
|
import android.content.Context;
|
import android.os.Handler;
|
import android.os.Looper;
|
import android.util.Log;
|
import android.widget.Toast;
|
|
import com.lcjian.library.DeviceUuidFactory;
|
import com.lcjian.library.util.GetManifestDataUtil;
|
import com.lcjian.library.util.MobileUtil;
|
import com.lcjian.library.util.NetUtils;
|
import com.lcjian.library.util.SingleToast;
|
import com.lcjian.library.util.common.PackageUtils2;
|
import com.lcjian.library.util.common.StringUtils;
|
import com.lcjian.library.util.security.MD5Utils;
|
import com.loopj.android.http.AsyncHttpClient;
|
import com.loopj.android.http.RequestParams;
|
import com.loopj.android.http.ResponseHandlerInterface;
|
import com.loopj.android.http.SyncHttpClient;
|
|
import org.apache.http.Header;
|
import org.apache.http.HttpResponse;
|
|
import java.io.File;
|
import java.io.FileNotFoundException;
|
import java.io.IOException;
|
import java.net.URI;
|
import java.util.ArrayList;
|
import java.util.Collections;
|
import java.util.HashMap;
|
import java.util.Iterator;
|
import java.util.LinkedHashMap;
|
import java.util.List;
|
import java.util.concurrent.TimeUnit;
|
|
import okhttp3.OkHttpClient;
|
|
/**
|
* Created by weikou2015 on 2017/2/20.
|
* 网络请求API
|
*/
|
|
public class ShoppingApi {
|
public static final boolean isDebug = false;
|
|
private static final String TAG = "ShoppingAPI";
|
|
public static String BASE_URL = BuXinConstant.HOST + "/hcj/api/v1/";
|
|
private static AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
|
|
private static SyncHttpClient syncHttpClient = new SyncHttpClient();
|
private static OkHttpClient mOkHttpClient = new OkHttpClient();//okHttpClient 实例
|
|
static {
|
|
mOkHttpClient = new OkHttpClient().newBuilder()
|
.connectTimeout(10 * 1000, TimeUnit.SECONDS)//设置超时时间
|
.readTimeout(10 * 1000, TimeUnit.SECONDS)//设置读取超时时间
|
.writeTimeout(10 * 1000, TimeUnit.SECONDS)//设置写入超时时间
|
.build();
|
asyncHttpClient.setTimeout(60 * 1000);
|
syncHttpClient.setTimeout(60 * 1000);
|
asyncHttpClient.setURLEncodingEnabled(false);
|
syncHttpClient.setURLEncodingEnabled(false);
|
}
|
|
/**
|
* 首页顶部Banner
|
*
|
* @param context
|
* @param handler
|
*/
|
public static void getBanner(Context context,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
commonPost(context, BASE_URL + "user/getrecommendbanner", params, handler);
|
}
|
|
/**
|
* 首页特卖
|
*
|
* @param context
|
* @param handler
|
*/
|
public static void getSpecialOffers(Context context,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
commonPost(context, BASE_URL + "user/getrecommendspecial", params, handler);
|
}
|
|
/**
|
* 首页特卖2
|
*
|
* @param context
|
* @param handler
|
*/
|
public static void getSpecialOffer2(Context context,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
commonPost(context, BASE_URL + "user/getHonestList", params, handler);
|
}
|
|
/**
|
* 首页猜你喜欢
|
*
|
* @param context
|
* @param handler
|
*/
|
public static void guessLike(Context context, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("uid", uid);
|
commonPost(context, BASE_URL + "user/guessLike", params, handler);
|
}
|
|
/**
|
* 首页分类数据
|
*
|
* @param context
|
* @param handler
|
*/
|
public static void getRecommendGoods(Context context, String index,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("index", index);
|
commonPost(context, BASE_URL + "user/getrecommendsection", params, handler);
|
}
|
|
/**
|
* 一级分类数据
|
*
|
* @param context
|
* @param handler
|
*/
|
public static void getFirstCategory(Context context,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
commonPost(context, BASE_URL + "class/getgoodsclass", params, handler);
|
}
|
|
/**
|
* 二级分类数据
|
*
|
* @param context
|
* @param handler
|
*/
|
public static void getSecondCategory(Context context, String gcid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("gcid", gcid);
|
commonPost(context, BASE_URL + "class/getgoodssecondclass", params, handler);
|
}
|
|
/**
|
* 三级分类数据
|
*
|
* @param context
|
* @param handler
|
*/
|
public static void getThirdCategory(Context context, String page, String key, String fillter, String fastFilter,
|
String order, String startprice, String endprice,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("scid", key);
|
params.put("page", page);
|
params.put("filter", fillter);
|
params.put("fastFilter", fastFilter);
|
params.put("order", order);
|
params.put("startprice", startprice);
|
params.put("endprice", endprice);
|
commonPost(context, BASE_URL + "class/getgoods", params, handler);
|
}
|
|
/**
|
* 首页优惠券
|
*
|
* @param context
|
* @param handler
|
*/
|
public static void getCouponRecommendGoods(Context context, String page,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("page", page);
|
commonPost(context, BASE_URL + "class/getCouponList", params, handler);
|
}
|
|
/**
|
* 首页二级分类列表
|
*
|
* @param context
|
* @param handler
|
*/
|
public static void getRecommendSecondGoods(Context context, String page, String key,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("gcid", key);
|
params.put("page", page);
|
commonPost(context, BASE_URL + "class/choiceGoods", params, handler);
|
}
|
|
|
/**
|
* 资金明细
|
*
|
* @param context
|
* @param handler
|
*/
|
public static void findAccountDetailsListV2(Context context, String uid, String page,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("uid", uid);
|
params.put("page", page);
|
commonPost(context, BASE_URL + "customer/findAccountDetailsListV2", params, handler);
|
}
|
|
/**
|
* 发表评论
|
*
|
* @param context
|
* @param uid
|
* @param handler
|
*/
|
public static void addComment(Context context, String uid, String drid, String content, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("drid", drid);
|
params.put("uid", uid);
|
params.put("content", content);
|
commonPost(context, BASE_URL + "dynamic/replys", params, handler);
|
}
|
|
|
/**
|
* 回复评论
|
*
|
* @param context
|
* @param handler
|
*/
|
public static void replayComment(Context context, String loginUid,
|
String commentReplyId, String commentId, String Content,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("Method", "replayComment");
|
params.put("Uid", loginUid);
|
params.put("CommentReplyId", commentReplyId);
|
params.put("CommentId", commentId);
|
params.put("Content", Content);
|
commonPost(context, BASE_URL + "comment", params, handler);
|
}
|
|
|
/**
|
* 订单申诉
|
*
|
* @param context
|
* @param handler
|
*/
|
public static void setOrderAppeal(Context context, String orderId, String uid, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("orderId", orderId);
|
params.put("userInfo.id", uid);
|
commonPostWithFailture(context, BASE_URL + "customer/findLostOrder", params, handler);
|
}
|
|
|
/**
|
* 获取准备复制的商品信息
|
*
|
* @param context
|
* @param handler
|
*/
|
public static void getNewGoodsInfo(Context context, String text, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("text", text);
|
commonPost(context, BASE_URL + "dynamic/getNewGoodsInfo", params, handler);
|
}
|
|
|
/**
|
* 热门搜索
|
*
|
* @param context
|
*/
|
public static void getHotSearch(Context context,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
commonPost(context, BASE_URL + "search/gethotsearch", params, handler);
|
}
|
|
/**
|
* 历史搜索
|
*
|
* @param context
|
*/
|
public static void getHistorySearch(Context context,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
commonPost(context, BASE_URL + "search/gethistorysearch", params, handler);
|
}
|
|
/**
|
* 建议搜索
|
*
|
* @param context
|
*/
|
public static void getSuggestSearch(Context context, String kw,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("kw", kw);
|
commonPost(context, BASE_URL + "search/suggestsearch", params, handler);
|
}
|
|
/**
|
* 清除历史搜索
|
*
|
* @param context
|
*/
|
public static void clearSearch(Context context,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
commonPost(context, BASE_URL + "search/clearhistorysearch", params, handler);
|
}
|
|
/**
|
* 搜索
|
*
|
* @param context
|
*/
|
public static void search(Context context, String kw, String page, String fillter, String fastFilter,
|
String order, String startprice, String endprice,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("kw", kw);
|
params.put("page", page);
|
params.put("filter", fillter);
|
params.put("fastFilter", fastFilter);
|
params.put("order", order);
|
params.put("startprice", startprice);
|
params.put("endprice", endprice);
|
commonPost(context, BASE_URL + "search/search", params, handler);
|
}
|
|
/**
|
* 获取PID信息
|
*
|
* @param context
|
*/
|
public static void getPidInfo(Context context, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("uid", uid);
|
commonPost(context, BASE_URL + "user/gettbpidinfo", params, handler);
|
}
|
|
/**
|
* 获取转链信息
|
*
|
* @param context
|
*/
|
public static void getTBLinkInfo(Context context, String uid, String goodsId,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("uid", uid);
|
params.put("id", goodsId);
|
commonPost(context, BASE_URL + "user/gettaobaolink", params, handler);
|
}
|
|
/**
|
* 获取站内信列表
|
*
|
* @param context
|
*/
|
public static void getMailList(Context context, String uid, String page,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("uid", uid);
|
params.put("page", page);
|
commonPost(context, BASE_URL + "customer/findAccountMessageList", params, handler);
|
}
|
|
/**
|
* 上传授权信息,成功后从服务器获取完整的用户信息
|
*
|
* @param context
|
*/
|
public static void getExtractProcess(Context context, String id, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("id", id);
|
params.put("uid", uid);
|
commonPost(context, BASE_URL + "customer/getextractprocess", params, handler);
|
}
|
|
/**
|
* 绑定华为推送
|
*
|
* @param context
|
*/
|
public static void bindHMPush(Context context, String token, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("token", token);
|
params.put("uid", uid);
|
commonPost(context, BASE_URL + "push/bindHWPush", params, handler);
|
}
|
|
/**
|
* 解绑华为推送
|
*
|
* @param context
|
*/
|
public static void unbindHMPush(Context context, String token, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("token", token);
|
params.put("uid", uid);
|
commonPost(context, BASE_URL + "push/unBindHWPush", params, handler);
|
}
|
|
/**
|
* 获取返利订单
|
*
|
* @param context
|
*/
|
public static void getRebateOrderList(Context context, String uid, String page,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("uid", uid);
|
params.put("page", page);
|
commonPost(context, BASE_URL + "customer/findOrderItemList", params, handler);
|
}
|
|
/**
|
* 获取返利订单
|
*
|
* @param context
|
*/
|
public static void getPercentageOrderList(Context context, String uid, String page,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("uid", uid);
|
params.put("page", page);
|
commonPost(context, BASE_URL + "customer/getTiChengOrderList", params, handler);
|
}
|
|
/**
|
* 上传授权信息,成功后从服务器获取完整的用户信息
|
*
|
* @param context
|
*/
|
public static void login(Context context, boolean first, String code, String tbOpenid, String tbNickName,
|
String portrait, String vcode, boolean wxinstall,
|
String phone, String loginType, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("first", first + "");
|
params.put("code", code);
|
params.put("tbOpenid", tbOpenid);
|
params.put("tbNickName", tbNickName);
|
params.put("portrait", portrait);
|
params.put("vcode", vcode);
|
params.put("wxinstall", wxinstall + "");
|
params.put("phone", phone);
|
params.put("loginType", loginType);
|
commonPostWithFailture(context, BASE_URL + "user/login", params, handler);
|
}
|
|
/**
|
* 获取短信验证码
|
*
|
* @param context
|
*/
|
public static void sendSms(Context context, String uid, String phone, String type, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("phone", phone);
|
params.put("uid", uid);
|
params.put("type", type);
|
// commonPost(context, BASE_URL + "sms/sendSMS", params, handler);
|
commonPostWithFailture(context, BASE_URL + "sms/sendSMS", params, handler);
|
}
|
|
/**
|
* 注册账户
|
*
|
* @param context
|
* @param tbOpenid
|
* @param tbNickName
|
* @param tbPortrait
|
* @param vcode
|
* @param phone
|
* @param handler
|
*/
|
public static void register(Context context, String tbOpenid, String tbNickName, String tbPortrait,
|
String vcode, String phone, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("tbOpenid", tbOpenid);
|
params.put("tbNickName", tbNickName);
|
params.put("tbPortrait", tbPortrait);
|
params.put("vcode", vcode);
|
params.put("phone", phone);
|
commonPostWithFailture(context, BASE_URL + "user/register", params, handler);
|
}
|
|
/**
|
* 合并账户
|
*
|
* @param context
|
* @param mainUid 主账号ID
|
* @param lessUid 次账户ID
|
* @param handler
|
*/
|
public static void mergeAccount(Context context, String mainUid, String lessUid, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("mainUid", mainUid);
|
params.put("lessUid", lessUid);
|
commonPostWithFailture(context, BASE_URL + "user/connect", params, handler);
|
}
|
|
/**
|
* 是否可提现
|
*
|
* @param context
|
*/
|
public static void canExtract(Context context, String uid, String money,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("uid", uid);
|
params.put("money", money);
|
commonPostWithFailture(context, BASE_URL + "customer/canextract", params, handler);
|
}
|
|
/**
|
* 绑定电话号码
|
*
|
* @param context
|
* @param handler
|
*/
|
public static void bindPhone(Context context, String uid, String vcode, String phone, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("uid", uid);
|
params.put("vcode", vcode);
|
params.put("phone", phone);
|
commonPostWithFailture(context, BASE_URL + "user/bindPhone", params, handler);
|
}
|
|
/**
|
* 添加支付宝账号
|
*
|
* @param context
|
* @param handler
|
*/
|
public static void addZhifubaoAccount(Context context, String uid, String name, String account, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("uid", uid);
|
params.put("name", name);
|
params.put("account", account);
|
commonPostWithFailture(context, BASE_URL + "user/bindalipaywithverify", params, handler);
|
}
|
|
|
/**
|
* 验证绑定支付宝验证码
|
*
|
* @param context
|
* @param handler
|
*/
|
public static void verifyvcodeforbind(Context context, String uid, String vcode, String phone, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("uid", uid);
|
params.put("vcode", vcode);
|
params.put("phone", phone);
|
commonPostWithFailture(context, BASE_URL + "user/verifyvcodeforbind", params, handler);
|
}
|
|
/**
|
* 解绑手机号
|
*
|
* @param context
|
* @param handler
|
*/
|
public static void unbindPhone(Context context, String uid, String phone, ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("uid", uid);
|
params.put("phone", phone);
|
commonPostWithFailture(context, BASE_URL + "user/unBindPhone", params, handler);
|
}
|
|
/**
|
* 绑定淘宝
|
*
|
* @param context
|
*/
|
public static void bindTaoBao(Context context, String uid, String openid, String nickName, String portrait,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("tbOpenid", openid);
|
params.put("tbNickName", nickName);
|
params.put("tbPortrait", portrait);
|
params.put("uid", uid);
|
commonPostWithFailture(context, BASE_URL + "user/bindTaoBao", params, handler);
|
}
|
|
/**
|
* 解绑淘宝
|
*
|
* @param context
|
*/
|
public static void unBindTaoBao(Context context, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("uid", uid);
|
commonPostWithFailture(context, BASE_URL + "user/unBindTaoBao", params, handler);
|
}
|
|
/**
|
* 更换微信
|
*
|
* @param context
|
*/
|
public static void changeWx(Context context, String uid, String code,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("uid", uid);
|
params.put("code", code);
|
commonPostWithFailture(context, BASE_URL + "user/changeWX", params, handler);
|
}
|
|
/**
|
* 获取用户金额
|
*
|
* @param context
|
*/
|
public static void getUserMoney(Context context, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("uid", uid);
|
commonPostWithFailture(context, BASE_URL + "user/getusermoney", params, handler);
|
}
|
|
/**
|
* 上传用户信息,成功后从服务器获取完整的用户信息
|
*
|
* @param context
|
*/
|
public static void getUserInfo2(Context context, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("id", uid);
|
commonPostWithFailture(context, BASE_URL + "customer/getuserinfo", params, handler);
|
}
|
|
/**
|
* 新版提现2018/06/05
|
*
|
* @param context
|
*/
|
public static void extractmoneynew(Context context, String money, String uid, String vcode, String type,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("money", money);
|
params.put("uid", uid);
|
params.put("vcode", vcode);
|
params.put("type", type);
|
commonPostWithFailture(context, BASE_URL + "customer/extractmoneynew", params, handler);
|
}
|
|
/**
|
* 动态列表2018/06/05
|
*
|
* @param context
|
*/
|
public static void getRecommendActivity(Context context, String page,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("page", page);
|
commonPost(context, BASE_URL + "activity/getRecommendActivity", params, handler);
|
}
|
|
/**
|
* 退出登录
|
*
|
* @param context
|
*/
|
public static void loginOut(Context context, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("uid", uid);
|
commonPost(context, BASE_URL + "user/logout", params, handler);
|
}
|
|
/**
|
* 分享商品2018/06/06
|
*
|
* @param context
|
*/
|
public static void shareGoods(Context context, String uid, String activityId,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("uid", uid);
|
params.put("activityId", activityId);
|
commonPost(context, BASE_URL + "activity/shareGoods", params, handler);
|
}
|
|
/**
|
* 分享商品2018/06/06
|
*
|
* @param context
|
*/
|
public static void getInviteImg(Context context, String uid, String activityId,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("uid", uid);
|
params.put("activityId", activityId);
|
commonPost(context, BASE_URL + "activity/inviteImg", params, handler);
|
}
|
|
|
/**
|
* 获取用户是否有新的站内信
|
*
|
* @param context
|
*/
|
public static void findCanOpenMessage(Context context, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("uid", uid);
|
commonPost(context, BASE_URL + "customer/findCanOpenMessage", params, handler);
|
}
|
|
/**
|
* 获取用户是否打开站内信
|
*
|
* @param context
|
*/
|
public static void openMessage(Context context, String uid, String id,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("uid", uid);
|
params.put("id", id);
|
commonPost(context, BASE_URL + "customer/openAccountMessage", params, handler);
|
}
|
|
/**
|
* 获取用户账户信息
|
*
|
* @param context
|
*/
|
public static void getUserAccount(Context context, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("uid", uid);
|
commonPostWithFailture(context, BASE_URL + "customer/getuseraccount", params, handler);
|
}
|
|
/**
|
* 获取真实支付宝信息
|
*
|
* @param context
|
*/
|
public static void getZFBInfo(Context context, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("uid", uid);
|
commonPostWithFailture(context, BASE_URL + "customer/getalipayaccount", params, handler);
|
}
|
|
/**
|
* 获取我的收藏
|
*
|
* @param context
|
*/
|
public static void getCollectioList(Context context, String page, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("page", page);
|
params.put("uid", uid);
|
commonPost(context, BASE_URL + "customer/collectionGoodsList", params, handler);
|
}
|
|
/**
|
* 删除我的收藏
|
*
|
* @param context
|
*/
|
public static void deleteCollect(Context context, String ids, String type, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("ids", ids);
|
params.put("uid", uid);
|
params.put("type", type);
|
commonPostWithFailture(context, BASE_URL + "customer/deleteCollectionGoods", params, handler);
|
}
|
|
/**
|
* 获取我的足迹
|
*
|
* @param context
|
*/
|
public static void getFootmark(Context context, String page, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("page", page);
|
params.put("uid", uid);
|
commonPost(context, BASE_URL + "user/getscanhistory", params, handler);
|
}
|
|
/**
|
* 删除我的足迹
|
*
|
* @param context
|
*/
|
public static void deleteFootmark(Context context, String ids, String type, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("ids", ids);
|
params.put("uid", uid);
|
params.put("type", type);
|
commonPostWithFailture(context, BASE_URL + "user/deletescanhistory", params, handler);
|
}
|
|
/**
|
* 获取商品信息
|
*
|
* @param context id 商品ID
|
*/
|
public static void getGoodsDetail(Context context, String id, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("id", id);
|
params.put("uid", uid);
|
commonPost(context, BASE_URL + "user/getgoodsdetail", params, handler);
|
}
|
|
/**
|
* 添加商品收藏信息
|
*
|
* @param context id 商品ID
|
*/
|
public static void collectionGoods(Context context, String id, String uid, String type,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("auctionId", id);
|
params.put("uid", uid);
|
params.put("type", type);
|
commonPost(context, BASE_URL + "customer/collectionGoods", params, handler);
|
}
|
|
/**
|
* 获取商品信息
|
*
|
* @param context id 商品ID
|
*/
|
public static void getGoodsDetailInfo(Context context, String id, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("id", id);
|
params.put("uid", uid);
|
commonPost(context, BASE_URL + "user/getnewgoodsdetail", params, handler);
|
}
|
|
/**
|
* 获取推荐商品
|
*
|
* @param context id 商品ID
|
*/
|
public static void getGoodsRecommend(Context context, String id,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("id", id);
|
commonPost(context, BASE_URL + "user/getgoodsrecommend", params, handler);
|
}
|
|
/**
|
* 上传订单号
|
*
|
* @param context id 商品ID
|
*/
|
public static void reportOrder(Context context, String order, String uid, String url, String money,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("order", order);
|
params.put("uid", uid);
|
params.put("money", money);
|
params.put("auctionUrl", url);
|
commonPost(context, BASE_URL + "user/reportorder", params, handler);
|
}
|
|
/**
|
* 添加账户
|
*
|
* @param context
|
*/
|
public static void addbindingaccount(Context context, String uid, String account, String name, String type,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("uid", uid);
|
params.put("account", account);
|
params.put("name", name);
|
params.put("type", type);
|
commonPostWithFailture(context, BASE_URL + "customer/addbindingaccount", params, handler);
|
}
|
|
/**
|
* 删除账户
|
*
|
* @param context
|
*/
|
public static void deletebindingaccount(Context context, String uid, String type,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("uid", uid);
|
params.put("type", type);
|
commonPostWithFailture(context, BASE_URL + "customer/deletebindingaccount", params, handler);
|
}
|
|
/**
|
* 获取主页邀请界面数据
|
*
|
* @param context
|
*/
|
public static void inviteFriend(Context context, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("uid", uid);
|
commonPost(context, BASE_URL + "invite/listInviteFriendImg", params, handler);
|
}
|
|
/**
|
* 获取主页邀请界面数据
|
*
|
* @param context
|
*/
|
public static void getGoodsShareUrl(Context context, String id,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("id", id);
|
commonPost(context, BASE_URL + "share/getGoodsShareUrl", params, handler);
|
}
|
|
/**
|
* 获取购物车商品淘宝联盟中的链接
|
*
|
* @param context
|
*/
|
public static void getTaoBaoLink(Context context, String url,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("url", url);
|
commonPost(context, BASE_URL + "user/getTaoBaoLink", params, handler);
|
}
|
|
/**
|
* 联系我们
|
*
|
* @param context
|
*/
|
public static void contactCustomerService(Context context,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
commonPostWithFailture(context, BASE_URL + "systemclient/contactCustomerService", params, handler);
|
}
|
|
/**
|
* 增加分享次数
|
*
|
* @param context uid动态ID
|
*/
|
public static void addShareCount(Context context, String uid,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
params.put("activityId", uid);
|
commonPostWithFailture(context, BASE_URL + "activity/addShareCount", params, handler);
|
}
|
|
/**
|
* 获取系统参数
|
*
|
* @param context
|
*/
|
public static void getSystemParams(Context context,
|
ResponseHandlerInterface handler) {
|
LinkedHashMap<String, String> params = new LinkedHashMap<String, String>();
|
commonPost(context, BASE_URL + "systemclient/getsystemclientparams", params, handler);
|
}
|
|
|
private static void commonPostWithFailture(final Context context, String url,
|
LinkedHashMap<String, String> params,
|
final ResponseHandlerInterface handler) {
|
commonPost(context, url,
|
params, new ResponseHandlerInterface() {
|
@Override
|
public void sendResponseMessage(HttpResponse httpResponse) throws IOException {
|
handler.sendResponseMessage(httpResponse);
|
}
|
|
@Override
|
public void sendStartMessage() {
|
handler.sendStartMessage();
|
}
|
|
@Override
|
public void sendFinishMessage() {
|
handler.sendFinishMessage();
|
}
|
|
@Override
|
public void sendProgressMessage(long l, long l1) {
|
handler.sendProgressMessage(l, l1);
|
}
|
|
@Override
|
public void sendCancelMessage() {
|
handler.sendCancelMessage();
|
}
|
|
@Override
|
public void sendSuccessMessage(int i, Header[] headers, byte[] bytes) {
|
handler.sendSuccessMessage(i, headers, bytes);
|
}
|
|
@Override
|
public void sendFailureMessage(int i, Header[] headers, byte[] bytes, Throwable throwable) {
|
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
@Override
|
public void run() {
|
if (NetUtils.getNetworkState(context).equalsIgnoreCase(NetUtils.NETWORK_NONE)) {
|
// Toast.makeText(context, "网络未连接,请检测网络设置。", Toast.LENGTH_SHORT).show();
|
SingleToast.showToast(context, "网络未连接,请检测网络设置");
|
} else {
|
// Toast.makeText(context, "网络连接异常,请检测网络设置。", Toast.LENGTH_SHORT).show();
|
SingleToast.showToast(context, "网络连接异常,请检测网络设置");
|
}
|
}
|
});
|
handler.sendFailureMessage(i, headers, bytes, throwable);
|
}
|
|
@Override
|
public void sendRetryMessage(int i) {
|
|
}
|
|
@Override
|
public URI getRequestURI() {
|
return null;
|
}
|
|
@Override
|
public Header[] getRequestHeaders() {
|
return new Header[0];
|
}
|
|
@Override
|
public void setRequestURI(URI uri) {
|
|
}
|
|
@Override
|
public void setRequestHeaders(Header[] headers) {
|
|
}
|
|
@Override
|
public void setUseSynchronousMode(boolean b) {
|
|
}
|
|
@Override
|
public boolean getUseSynchronousMode() {
|
return false;
|
}
|
|
@Override
|
public void setUsePoolThread(boolean b) {
|
|
}
|
|
@Override
|
public boolean getUsePoolThread() {
|
return false;
|
}
|
|
@Override
|
public void onPreProcessResponse(ResponseHandlerInterface responseHandlerInterface, HttpResponse httpResponse) {
|
|
}
|
|
@Override
|
public void onPostProcessResponse(ResponseHandlerInterface responseHandlerInterface, HttpResponse httpResponse) {
|
|
}
|
|
@Override
|
public void setTag(Object o) {
|
|
}
|
|
@Override
|
public Object getTag() {
|
return null;
|
}
|
});
|
|
}
|
|
private static void commonPost(Context context, String url,
|
LinkedHashMap<String, String> params,
|
ResponseHandlerInterface handler) {
|
if (BuXinConstant.isDisableProxy()) {
|
commonPost(context, url, params, null, handler);
|
} else {
|
Toast.makeText(context, "服务器拒绝访问,请查看是否禁用了代理服务器!",
|
Toast.LENGTH_SHORT).show();
|
return;
|
}
|
}
|
|
private static void commonPost1(Context context, String url,
|
LinkedHashMap<String, String> params, HashMap<String, File[]> files,
|
ResponseHandlerInterface handler) {
|
if (BuXinConstant.isDisableProxy()) {
|
commonPost(context, url, params, files, handler);
|
} else {
|
Toast.makeText(context, "服务器拒绝访问,请查看是否禁用了代理服务器!",
|
Toast.LENGTH_SHORT).show();
|
return;
|
}
|
}
|
|
private static void commonPost(Context context, String url,
|
LinkedHashMap<String, String> params, HashMap<String, File[]> files,
|
ResponseHandlerInterface handler) {
|
commonPost(context, url, params, files, handler, true);
|
}
|
|
private static void commonPost(Context context, String url,
|
LinkedHashMap<String, String> params, HashMap<String, File[]> files,
|
ResponseHandlerInterface handler, boolean asyn) {
|
LinkedHashMap<String, String> map = validateParams(params, context);
|
RequestParams requestParams = new RequestParams(map);
|
if (files != null && files.size() > 0) {
|
Iterator<String> it = files.keySet().iterator();
|
if (it.hasNext()) {
|
String entry = it.next();
|
try {
|
requestParams.put(entry, files.get(entry));
|
} catch (FileNotFoundException e) {
|
}
|
}
|
}
|
// requestParams.put("files", files);
|
if (BuildConfig.DEBUG) {
|
Log.i(TAG, "post url: " + url + "?" + requestParams.toString());
|
}
|
if (asyn) {
|
// asyncHttpClient.setProxy("192.168.1.122", 8888);
|
asyncHttpClient.post(context, url, requestParams, handler);
|
|
} else {
|
// syncHttpClient.post(context, url, requestParams, handler);
|
// asyncHttpClient.setProxy("192.168.1.122", 8888);
|
final Context context2 = context;
|
final String url2 = url;
|
final RequestParams requestParams2 = requestParams;
|
final ResponseHandlerInterface handler2 = handler;
|
syncHttpClient.post(context2, url2, requestParams2, handler2);
|
}
|
}
|
|
public static LinkedHashMap<String, String> validateParams(
|
LinkedHashMap<String, String> params, Context context) {
|
// for (Entry<String, String> entry : params.entrySet()) {
|
// sign.append(entry.getValue());
|
// }
|
|
int version = PackageUtils2.getVersionCode(context);
|
long time = System.currentTimeMillis();
|
String deviceType = MobileUtil.getSystemModel();
|
params.put("packages", context.getPackageName());
|
// params.put("packages", "com.yeshi.ec.rebate");
|
params.put("Version", version + "");
|
params.put("appkey", BuXinConstant.TAO_BAO_APP_KEY);
|
params.put("platform", "android");
|
params.put("channel", GetManifestDataUtil.getAppMetaData(context, "UMENG_CHANNEL"));
|
params.put("imei", MobileUtil.getIMEI(context));
|
params.put("osVersion", MobileUtil.getSystemVersion());
|
params.put("network", NetUtils.getNetworkState(context));
|
params.put("apiversion", "1");
|
params.put("deviceType", StringUtils.isEmpty(deviceType) ? "" : deviceType);
|
params.put("time", time + "");
|
params.put("Device", new DeviceUuidFactory(context).getDeviceUuid() + "");
|
Iterator<String> its = params.keySet().iterator();
|
List<String> list = new ArrayList<>();
|
while (its.hasNext()) {
|
String key = its.next();
|
Object value = params.get(key);
|
list.add(key + "=" + value);
|
}
|
Collections.sort(list);
|
String sign = "";
|
for (String str : list) {
|
sign += str + "&";
|
}
|
params.put("sign", MD5Utils.getMD532(sign + "Hai#CaO%jIe2018@"));
|
|
return params;
|
}
|
}
|