Commit fc52a1b8 by mReturn

客户验收二维码

parent 1d9acec7
......@@ -24,6 +24,8 @@ import java.util.List;
import io.reactivex.Observable;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.Call;
/**
* Created by luofan
......@@ -155,6 +157,9 @@ public class OrderApiFactory {
public static Observable<String> createUrl(int orderId) {
return Api.getService(OrderService.class).createUrl(orderId).compose(Api.applySchedulers());
}
public static Call<ResponseBody> createWxUrl(int orderId, int width) {
return Api.getService(OrderService.class).createWxUrl(orderId,width);
}
public static Observable<Boolean> queryPayStatus(int siteId) {
return Api.getService(OrderService.class).queryPayStatus(siteId).compose(Api.applySchedulers());
......
......@@ -23,6 +23,8 @@ import java.util.List;
import io.reactivex.Observable;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.POST;
......@@ -340,6 +342,9 @@ interface OrderService {
@GET(OrderConstant.CREATE_URL)
Observable<BaseResponse<String>> createUrl(@Path("orderId") int orderId);
@GET(OrderConstant.CREATE_WX_URL)
Call<ResponseBody> createWxUrl(@Query("id") int workId, @Query("width") int width);
/**
* 查询是否开通移动支付.
*
......
......@@ -170,6 +170,9 @@ public class OrderConstant {
*/
public final static String CREATE_URL = "/api-user" + "/account/createUrlByOrderId/{orderId}";
public final static String CREATE_WX_URL = "/api-third/WXUser/getWxQrCode?path=pages/orderServerDetail/main";
/**
* 修改自建单.
*/
......
package com.dayu.order.presenter.qrcode;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import com.dayu.common.Constants;
import com.dayu.order.R;
import com.dayu.order.api.OrderApiFactory;
import com.dayu.utils.QRCodeUtils;
import com.dayu.utils.ToastUtils;
import java.io.IOException;
import java.io.InputStream;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
/**
* Created by luofan
......@@ -23,9 +34,34 @@ public class QRCodePresenter extends QRCodeContract.Presenter {
@Override
public void getUrl() {
mView.showDialog();
OrderApiFactory.createUrl(mId).subscribe(baseObserver(s -> {
Bitmap bitmap = QRCodeUtils.createBitmap(s);
mView.setBitmap(bitmap);
}));
// OrderApiFactory.createUrl(mId).subscribe(baseObserver(s -> {
// Bitmap bitmap = QRCodeUtils.createBitmap(s);
// mView.setBitmap(bitmap);
// }));
Call<ResponseBody> call = OrderApiFactory.createWxUrl(mId, 470);
call.enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
mView.hideDialog();
try {
InputStream is = response.body().byteStream();
Bitmap bitmap = BitmapFactory.decodeStream(is);
is.close();
mView.setBitmap(bitmap);
} catch (IOException e) {
e.printStackTrace();
ToastUtils.showShortToast(R.string.error_unknow);
}
}
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
mView.hideDialog();
ToastUtils.showShortToast(R.string.error_unknow);
}
});
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment