package com.appc.myapplication.Moudleshop;
import com.appc.myapplication.Moudledl.bean.dlbean;
import com.appc.myapplication.Moudleshop.bean2.shopbean;
import com.appc.myapplication.Presentershop.Ipshop;
import com.appc.myapplication.Presentershop.Presentershop;
import com.google.gson.Gson;
import java.io.IOException;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
/**
* Created by Administrator on 2018/1/6.
*/
public class Moudleshop {
private Ipshop ipshop;
public Moudleshop(Ipshop ipshop) {
this.ipshop=ipshop;
}
public void getmudleshuosj(String shoppingurl, String tiaojian, int page) {
OkHttpClient httpClient = new OkHttpClient();
FormBody body = new FormBody.Builder()
.add("keywords",tiaojian)
.add("page", String.valueOf(page))
.build();
Request request = new Request.Builder()
.url(shoppingurl)
.post(body)
.build();
Call call = httpClient.newCall(request);
call.enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
if (response.isSuccessful()){
String json = response.body().string();
Gson gson = new Gson();
shopbean shopbean = gson.fromJson(json, shopbean.class);
ipshop.Ipshousj(shopbean);
}
}
});
}
}