* 开发环境 * */ //public static final String BASE_URL="http://172.17.8.100"; /*http://172.17.8.100/small/commodity/v1/commodityList * 测试环境 * */ public static final String BASE_URL="http://172.17.8.100"; //首页商品信息列表 public static String SHOPLIST=BASE_URL+"/small/commodity/v1/commodityList"; //登录接口 public static String LOGIN=BASE_URL+"/small/user/v1/login";
private static OkHttpClient okHttpClient; public static final String TAG="OkHttp3"; private static Request request; private static FormBody build; private static Request get; private static OkHttpClient okHttpClient1; //OkHttp public static void OkHttpGet(String url , Callback callback1){ okHttpClient = new OkHttpClient(); get=new Request.Builder().url(url).method("GET",null).build(); okHttpClient.newCall(get).enqueue(callback1); } public static void OkHttpPost(String url, String name, String pswd, Callback callback){ okHttpClient1 = new OkHttpClient(); // build = new FormBody.Builder() .add("phone", name) .add("pwd", pswd) .build(); Request request = new Request.Builder().url(url).post(build).build(); okHttpClient1.newCall(request).enqueue(callback); }