1
This commit is contained in:
@@ -17,6 +17,7 @@ import com.cutil.StringUtils;
|
||||
import com.sl.house_property.cart.AddressListActivity;
|
||||
import com.sl.house_property.databinding.FragmentMain4Binding;
|
||||
import com.sl.house_property.f1.UserdlistActivity;
|
||||
import com.sl.house_property.order.OrderActivity;
|
||||
import com.sl.house_property.user.MyAuthorizedFamilyHistory;
|
||||
import com.sl.house_property.user.MyBillHistory;
|
||||
import com.sl.house_property.user.MyGuaranteeHistory;
|
||||
@@ -190,6 +191,60 @@ public class Main4Fragment extends BaseFragment<FragmentMain4Binding> {
|
||||
startActivityForResult(intent, 0);
|
||||
}
|
||||
});
|
||||
mDataBinding.tvOrder1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getActivity(), OrderActivity.class);
|
||||
intent.putExtra("type", 1);
|
||||
intent.putExtra("orderType", 1);
|
||||
startActivityForResult(intent, 0);
|
||||
}
|
||||
});
|
||||
mDataBinding.tvOrder2.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getActivity(), OrderActivity.class);
|
||||
intent.putExtra("type", 1);
|
||||
intent.putExtra("orderType", 2);
|
||||
startActivityForResult(intent, 0);
|
||||
}
|
||||
});
|
||||
mDataBinding.tvOrder3.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getActivity(), OrderActivity.class);
|
||||
intent.putExtra("type", 1);
|
||||
intent.putExtra("orderType", 3);
|
||||
startActivityForResult(intent, 0);
|
||||
}
|
||||
});
|
||||
mDataBinding.tvOrder4.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getActivity(), OrderActivity.class);
|
||||
intent.putExtra("type", 2);
|
||||
intent.putExtra("orderType", 1);
|
||||
startActivityForResult(intent, 0);
|
||||
}
|
||||
});
|
||||
mDataBinding.tvOrder5.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getActivity(), OrderActivity.class);
|
||||
intent.putExtra("type", 2);
|
||||
intent.putExtra("orderType", 2);
|
||||
startActivityForResult(intent, 0);
|
||||
}
|
||||
});
|
||||
mDataBinding.tvOrder6.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getActivity(), OrderActivity.class);
|
||||
intent.putExtra("type", 2);
|
||||
intent.putExtra("orderType", 3);
|
||||
startActivityForResult(intent, 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// private void initMyReycyView() {
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
package com.sl.house_property.cart;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.gyf.immersionbar.ImmersionBar;
|
||||
import com.lljjcoder.Interface.OnCityItemClickListener;
|
||||
import com.lljjcoder.bean.CityBean;
|
||||
import com.lljjcoder.bean.DistrictBean;
|
||||
import com.lljjcoder.bean.ProvinceBean;
|
||||
import com.lljjcoder.style.cityjd.JDCityConfig;
|
||||
import com.lljjcoder.style.cityjd.JDCityPicker;
|
||||
import com.sl.house_property.BaseActivity;
|
||||
import com.sl.house_property.R;
|
||||
import com.sl.house_property.databinding.ActivityAddAddressBinding;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import entity.RegisterUser;
|
||||
import http.ApiConfig;
|
||||
import my_loader.Loader;
|
||||
import my_loader.Resultcode;
|
||||
import rx.functions.Action1;
|
||||
import tools.Config;
|
||||
import utils.Md5;
|
||||
|
||||
public class AddAddressActivity extends BaseActivity<ActivityAddAddressBinding> {
|
||||
private ProgressDialog progressDialog;
|
||||
private Context context;
|
||||
private String area = "";
|
||||
|
||||
@Override
|
||||
protected int getLayoutResId() {
|
||||
return R.layout.activity_add_address;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ImmersionBar.with(this)
|
||||
.keyboardEnable(true) //解决软键盘与底部输入框冲突问题
|
||||
// .keyboardEnable(true, WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE
|
||||
// | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) //软键盘自动弹出
|
||||
//.barColor(R.color.colorPrimary)
|
||||
.init();
|
||||
context = this;
|
||||
mDataBinding.left.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
progressDialog = new ProgressDialog(this);
|
||||
mDataBinding.tvArea.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
select();
|
||||
}
|
||||
});
|
||||
mDataBinding.btnSubmit.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
submit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Loader loader = new Loader();
|
||||
|
||||
private void submit() {
|
||||
String name = mDataBinding.etName.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(name)) {
|
||||
setToast(1, "请输入收货人姓名");
|
||||
return;
|
||||
}
|
||||
String phone = mDataBinding.etPhone.getText().toString().trim();
|
||||
|
||||
if (TextUtils.isEmpty(phone)) {
|
||||
setToast(1, "请输入手机号码");
|
||||
return;
|
||||
}
|
||||
if (TextUtils.isEmpty(area)) {
|
||||
setToast(1, "请选择地区");
|
||||
return;
|
||||
}
|
||||
String detail = mDataBinding.etDetail.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(detail)) {
|
||||
setToast(1, "请输入详细地址");
|
||||
return;
|
||||
}
|
||||
progressDialog.setMessage("提交中");
|
||||
progressDialog.show();
|
||||
RegisterUser user =
|
||||
Config.getInstance(context).getUser();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
if (user != null) {
|
||||
map.put("userid", user.getUserid());
|
||||
} else {
|
||||
map.put("userid", 0 + "");
|
||||
}
|
||||
map.put("app", "Order");
|
||||
map.put("class", "UserAddressAdd");
|
||||
map.put("name", name);
|
||||
map.put("mobile", phone);
|
||||
map.put("address", area + detail);
|
||||
map.put("sign", Md5.md5("Order" + "UserAddressAdd" + Md5.secret));
|
||||
|
||||
loader.getMovie(ApiConfig.BASE_URL, map)
|
||||
.subscribe(new Action1<Resultcode>() {
|
||||
@Override
|
||||
public void call(Resultcode resultcode) {
|
||||
progressDialog.dismiss();
|
||||
if (resultcode.status == 0) {
|
||||
Toast.makeText(context, "提交成功", Toast.LENGTH_SHORT).show();
|
||||
setResult(200);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}, new Action1<Throwable>() {
|
||||
@Override
|
||||
public void call(Throwable throwable) {
|
||||
progressDialog.dismiss();
|
||||
throwable.fillInStackTrace();
|
||||
Toast.makeText(context, "提交失败", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void select() {
|
||||
JDCityPicker cityPicker = new JDCityPicker();
|
||||
JDCityConfig jdCityConfig = new JDCityConfig.Builder().build();
|
||||
|
||||
jdCityConfig.setShowType(JDCityConfig.ShowType.PRO_CITY_DIS);
|
||||
cityPicker.init(this);
|
||||
cityPicker.setConfig(jdCityConfig);
|
||||
cityPicker.setOnCityItemClickListener(new OnCityItemClickListener() {
|
||||
@Override
|
||||
public void onSelected(ProvinceBean province, CityBean city, DistrictBean district) {
|
||||
area = province.getName() + city.getName() + district.getName();
|
||||
mDataBinding.tvArea.setText(area);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
}
|
||||
});
|
||||
cityPicker.showCityPicker();
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.sl.house_property.cart;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
@@ -60,6 +61,12 @@ public class AddressListActivity extends BaseActivity<ActivityAddressListBinding
|
||||
// .keyboardEnable(true, WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE
|
||||
// | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) //软键盘自动弹出
|
||||
.init();
|
||||
mDataBinding.left.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
progressDialog = new ProgressDialog(this);
|
||||
initRec();
|
||||
mDataBinding.dw.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
|
||||
@@ -75,7 +82,12 @@ public class AddressListActivity extends BaseActivity<ActivityAddressListBinding
|
||||
}
|
||||
});
|
||||
mDataBinding.dw.autoRefresh();
|
||||
|
||||
mDataBinding.tvManager.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivityForResult(new Intent(context, AddAddressActivity.class), 13);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initRec() {
|
||||
@@ -102,7 +114,7 @@ public class AddressListActivity extends BaseActivity<ActivityAddressListBinding
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
|
||||
opera(addressEntity.getConsignee_id(), "1");
|
||||
opera(addressEntity.getConsignee_id(), "1");
|
||||
|
||||
}
|
||||
}).show();
|
||||
@@ -239,4 +251,13 @@ public class AddressListActivity extends BaseActivity<ActivityAddressListBinding
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == 13 && resultCode == 200) {
|
||||
page = 1;
|
||||
getList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
383
app/src/main/java/com/sl/house_property/order/OrderActivity.java
Normal file
383
app/src/main/java/com/sl/house_property/order/OrderActivity.java
Normal file
@@ -0,0 +1,383 @@
|
||||
package com.sl.house_property.order;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.view.View;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.internal.LinkedTreeMap;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.gyf.immersionbar.ImmersionBar;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.lxj.xpopup.interfaces.OnConfirmListener;
|
||||
import com.lxj.xpopup.interfaces.OnInputConfirmListener;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
|
||||
import com.sl.house_property.BaseActivity;
|
||||
import com.sl.house_property.R;
|
||||
import com.sl.house_property.databinding.ActivityOrderBinding;
|
||||
import com.sl.house_property.databinding.ItemOrderBinding;
|
||||
import com.sl.house_property.databinding.ItemOrderItemBinding;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import adapter.BaseRecycleViewAdapter;
|
||||
import entity.OrderListBean;
|
||||
import entity.RegisterUser;
|
||||
import http.ApiConfig;
|
||||
import my_loader.Loader;
|
||||
import my_loader.Resultcode;
|
||||
import rx.functions.Action1;
|
||||
import tools.Config;
|
||||
import utils.Md5;
|
||||
|
||||
public class OrderActivity extends BaseActivity<ActivityOrderBinding> {
|
||||
@Override
|
||||
protected int getLayoutResId() {
|
||||
return R.layout.activity_order;
|
||||
}
|
||||
|
||||
private int type = -1;
|
||||
private int page = 1;
|
||||
private int orderType = -1;
|
||||
private Context context;
|
||||
private ProgressDialog progressDialog;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
ImmersionBar.with(this)
|
||||
.keyboardEnable(true) //解决软键盘与底部输入框冲突问题
|
||||
// .keyboardEnable(true, WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE
|
||||
// | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) //软键盘自动弹出
|
||||
.init();
|
||||
context = this;
|
||||
progressDialog = new ProgressDialog(this);
|
||||
mDataBinding.left.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
type = getIntent().getIntExtra("type", -1);
|
||||
orderType = getIntent().getIntExtra("orderType", -1);
|
||||
initRec();
|
||||
|
||||
|
||||
mDataBinding.dw.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
|
||||
getList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
page = 1;
|
||||
getList();
|
||||
}
|
||||
});
|
||||
mDataBinding.dw.autoRefresh();
|
||||
if (orderType == 1) {
|
||||
mDataBinding.tvTitle.setText("待付款");
|
||||
} else if (orderType == 2) {
|
||||
mDataBinding.tvTitle.setText("待发货");
|
||||
} else if (orderType == 3) {
|
||||
mDataBinding.tvTitle.setText("待收货");
|
||||
} else if (orderType == 4) {
|
||||
mDataBinding.tvTitle.setText("待评价");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void initRec() {
|
||||
BaseRecycleViewAdapter<OrderListBean, ItemOrderBinding> adapter = new BaseRecycleViewAdapter<>(context, R.layout.item_order);
|
||||
adapter.setOnBindViewHolder(new BaseRecycleViewAdapter.BindView<ItemOrderBinding>() {
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(final ItemOrderBinding b, int position) {
|
||||
final OrderListBean orderListBean = list.get(position);
|
||||
if (type == 1) {
|
||||
if (orderType == 1) {
|
||||
//待付款
|
||||
b.btnFk.setVisibility(View.VISIBLE);
|
||||
b.btnFk.setText("付款");
|
||||
b.btnCancel.setVisibility(View.VISIBLE);
|
||||
b.btnCancel.setText("取消订单");
|
||||
b.tvInfo.setVisibility(View.VISIBLE);
|
||||
} else if (orderType == 2) {
|
||||
//待发货
|
||||
b.btnFk.setVisibility(View.VISIBLE);
|
||||
b.btnFk.setText("取消订单");
|
||||
b.btnCancel.setVisibility(View.GONE);
|
||||
b.tvInfo.setVisibility(View.GONE);
|
||||
} else if (orderType == 3) {
|
||||
//待收货
|
||||
b.btnFk.setVisibility(View.VISIBLE);
|
||||
b.btnFk.setText("确认收货");
|
||||
b.btnCancel.setVisibility(View.GONE);
|
||||
b.tvInfo.setVisibility(View.GONE);
|
||||
} else if (orderType == 4) {
|
||||
//待评价
|
||||
b.btnFk.setVisibility(View.VISIBLE);
|
||||
b.btnFk.setText("删除订单");
|
||||
b.btnCancel.setVisibility(View.GONE);
|
||||
b.tvInfo.setVisibility(View.GONE);
|
||||
}
|
||||
} else if (type == 2) {
|
||||
b.tvInfo.setVisibility(View.GONE);
|
||||
if (orderType == 2) {
|
||||
b.btnFk.setVisibility(View.VISIBLE);
|
||||
b.btnFk.setText("确认发货");
|
||||
} else {
|
||||
b.btnFk.setVisibility(View.GONE);
|
||||
}
|
||||
b.btnCancel.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
b.tvAmount.setText("¥" + orderListBean.getOrder_money());
|
||||
RequestOptions requestOptions = new RequestOptions();
|
||||
requestOptions.placeholder(R.mipmap.head);
|
||||
requestOptions.error(R.mipmap.head);
|
||||
|
||||
Glide.with(context).load(orderListBean.getAvatar())
|
||||
.apply(requestOptions)
|
||||
.into(b.ivHead);
|
||||
b.tvUsername.setText(orderListBean.getNickname());
|
||||
b.rv.setLayoutManager(new LinearLayoutManager(context));
|
||||
BaseRecycleViewAdapter<OrderListBean.Content_info, ItemOrderItemBinding> itemAdapter = new BaseRecycleViewAdapter<>(context, R.layout.item_order_item);
|
||||
itemAdapter.setOnBindViewHolder(new BaseRecycleViewAdapter.BindView<ItemOrderItemBinding>() {
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ItemOrderItemBinding b, int position) {
|
||||
if (!(position >= orderListBean.getContent_info().size())) {
|
||||
OrderListBean.Content_info content_info = orderListBean.getContent_info().get(position);
|
||||
b.tvGoodsName.setText(content_info.getName());
|
||||
b.tvInfo2.setText(content_info.getProperty());
|
||||
b.tvPrice.setText("¥" + content_info.getSale_price());
|
||||
b.tvNum.setText("x" + content_info.getGoods_num());
|
||||
RequestOptions requestOptions = new RequestOptions();
|
||||
requestOptions.placeholder(R.mipmap.icon_default_rectangle);
|
||||
requestOptions.error(R.mipmap.icon_default_rectangle);
|
||||
|
||||
Glide.with(context).load(content_info.getImg())
|
||||
.apply(requestOptions)
|
||||
.into(b.ivGoods);
|
||||
}
|
||||
}
|
||||
});
|
||||
itemAdapter.setData(orderListBean.getContent_info());
|
||||
b.rv.setAdapter(itemAdapter);
|
||||
b.rv.setLayoutManager(new LinearLayoutManager(context));
|
||||
b.btnCancel.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//取消订单
|
||||
new XPopup.Builder(context).asConfirm("", "确定要取消订单吗?", new OnConfirmListener() {
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
orderAction(1, orderListBean.getOrder_id(), "");
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
});
|
||||
b.btnFk.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (b.btnFk.getText().equals("付款")) {
|
||||
//付款
|
||||
|
||||
} else if (b.btnFk.getText().equals("取消订单")) {
|
||||
new XPopup.Builder(context).asConfirm("", "确定要取消订单吗?", new OnConfirmListener() {
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
orderAction(1, orderListBean.getOrder_id(), "");
|
||||
}
|
||||
}).show();
|
||||
} else if (b.btnFk.getText().equals("确认收货")) {
|
||||
new XPopup.Builder(context).asConfirm("", "真的要确认收货吗?", new OnConfirmListener() {
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
orderAction(2, orderListBean.getOrder_id(), "");
|
||||
}
|
||||
}).show();
|
||||
} else if (b.btnFk.getText().equals("删除订单")) {
|
||||
new XPopup.Builder(context).asConfirm("", "确定要删除订单吗?", new OnConfirmListener() {
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
orderAction(3, orderListBean.getOrder_id(), "");
|
||||
}
|
||||
}).show();
|
||||
} else if (b.btnFk.getText().equals("确认发货")) {
|
||||
new XPopup.Builder(context).asInputConfirm("确认发货", "", "", "请输入物流编号", new OnInputConfirmListener() {
|
||||
@Override
|
||||
public void onConfirm(String text) {
|
||||
orderAction(4, orderListBean.getOrder_id(), text);
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
mDataBinding.rec.setLayoutManager(new LinearLayoutManager(context));
|
||||
mDataBinding.rec.setAdapter(adapter);
|
||||
adapter.setOnItemClickListener(new BaseRecycleViewAdapter.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(View itemView, int position) {
|
||||
Intent intent = new Intent(context, OrderDetailActivity.class);
|
||||
intent.putExtra("type", type);
|
||||
intent.putExtra("orderType", orderType);
|
||||
intent.putExtra("orderId", list.get(position).getOrder_id());
|
||||
startActivityForResult(intent, 15);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Loader loader = new Loader();
|
||||
private ArrayList<OrderListBean> list = new ArrayList<>();
|
||||
|
||||
private void orderAction(int action, String order_id, String info) {
|
||||
progressDialog.setMessage("提交中");
|
||||
progressDialog.show();
|
||||
RegisterUser user =
|
||||
Config.getInstance(context).getUser();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
if (user != null) {
|
||||
map.put("userid", user.getUserid());
|
||||
} else {
|
||||
map.put("userid", 0 + "");
|
||||
}
|
||||
map.put("app", "Order");
|
||||
if (action == 4) {
|
||||
map.put("class", "StoreOrderAction");
|
||||
map.put("logistics_no", info);
|
||||
} else {
|
||||
map.put("class", "OrderAction");
|
||||
|
||||
}
|
||||
map.put("action", action + "");
|
||||
map.put("order_id", order_id);
|
||||
if (action == 4) {
|
||||
map.put("sign", Md5.md5("Order" + "StoreOrderAction" + Md5.secret));
|
||||
} else {
|
||||
map.put("sign", Md5.md5("Order" + "OrderAction" + Md5.secret));
|
||||
|
||||
}
|
||||
loader.getMovie(ApiConfig.BASE_URL, map).subscribe(new Action1<Resultcode>() {
|
||||
@Override
|
||||
public void call(Resultcode resultcode) {
|
||||
progressDialog.dismiss();
|
||||
if (resultcode.status == 0) {
|
||||
setToast(resultcode.msg);
|
||||
page = 1;
|
||||
getList();
|
||||
} else {
|
||||
setToast(resultcode.msg);
|
||||
}
|
||||
}
|
||||
}, new Action1<Throwable>() {
|
||||
@Override
|
||||
public void call(Throwable throwable) {
|
||||
progressDialog.dismiss();
|
||||
setToast("操作失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getList() {
|
||||
|
||||
RegisterUser user =
|
||||
Config.getInstance(context).getUser();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
if (user != null) {
|
||||
map.put("userid", user.getUserid());
|
||||
map.put("goods_user_id", user.getUserid());
|
||||
} else {
|
||||
map.put("userid", 0 + "");
|
||||
map.put("goods_user_id", 0 + "");
|
||||
}
|
||||
map.put("app", "Order");
|
||||
if (type == 1) {
|
||||
map.put("class", "OrderLists");
|
||||
map.put("sign", Md5.md5("Order" + "OrderLists" + Md5.secret));
|
||||
} else if (type == 2) {
|
||||
map.put("class", "StoreOrderLists");
|
||||
map.put("sign", Md5.md5("Order" + "StoreOrderLists" + Md5.secret));
|
||||
}
|
||||
map.put("type", orderType + "");
|
||||
map.put("page", page + "");
|
||||
loader.getMovie(ApiConfig.BASE_URL, map)
|
||||
.subscribe(new Action1<Resultcode>() {
|
||||
@Override
|
||||
public void call(Resultcode resultcode) {
|
||||
mDataBinding.dw.finishLoadMore();
|
||||
mDataBinding.dw.finishRefresh();
|
||||
progressDialog.dismiss();
|
||||
if (resultcode.status != 0) {
|
||||
setToast(resultcode.msg);
|
||||
return;
|
||||
}
|
||||
Gson gs = new Gson();
|
||||
LinkedTreeMap adta = (LinkedTreeMap) resultcode.data;
|
||||
String s = gs.toJson(adta);
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(s);
|
||||
org.json.JSONArray array = jsonObject.getJSONArray("info");
|
||||
|
||||
//买家订单
|
||||
Type type = new TypeToken<ArrayList<OrderListBean>>() {
|
||||
}.getType();
|
||||
ArrayList<OrderListBean> newList = gs.fromJson(array.toString(), type);
|
||||
int count = jsonObject.getInt("count");
|
||||
|
||||
if (page == 1) {
|
||||
list.clear();
|
||||
}
|
||||
list.addAll(newList);
|
||||
if (list.size() == count || newList.isEmpty()) {
|
||||
mDataBinding.dw.finishLoadMoreWithNoMoreData();
|
||||
} else {
|
||||
page++;
|
||||
}
|
||||
BaseRecycleViewAdapter baseRecycleViewAdapter = (BaseRecycleViewAdapter) mDataBinding.rec.getAdapter();
|
||||
baseRecycleViewAdapter.setData(list);
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
}
|
||||
}
|
||||
}, new Action1<Throwable>() {
|
||||
@Override
|
||||
public void call(Throwable throwable) {
|
||||
mDataBinding.dw.finishLoadMore();
|
||||
mDataBinding.dw.finishRefresh();
|
||||
progressDialog.dismiss();
|
||||
throwable.fillInStackTrace();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == 15 && resultCode == 200) {
|
||||
page = 1;
|
||||
getList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,280 @@
|
||||
package com.sl.house_property.order;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.view.View;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.internal.LinkedTreeMap;
|
||||
import com.gyf.immersionbar.ImmersionBar;
|
||||
import com.lxj.xpopup.XPopup;
|
||||
import com.lxj.xpopup.interfaces.OnConfirmListener;
|
||||
import com.lxj.xpopup.interfaces.OnInputConfirmListener;
|
||||
import com.sl.house_property.BaseActivity;
|
||||
import com.sl.house_property.R;
|
||||
import com.sl.house_property.databinding.ActivityOrderDetailBinding;
|
||||
import com.sl.house_property.databinding.ItemOrderItemBinding;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import adapter.BaseRecycleViewAdapter;
|
||||
import entity.OrderListBean;
|
||||
import entity.RegisterUser;
|
||||
import http.ApiConfig;
|
||||
import my_loader.Loader;
|
||||
import my_loader.Resultcode;
|
||||
import rx.functions.Action1;
|
||||
import tools.Config;
|
||||
import utils.Md5;
|
||||
|
||||
public class OrderDetailActivity extends BaseActivity<ActivityOrderDetailBinding> {
|
||||
private Context context;
|
||||
private ProgressDialog progressDialog;
|
||||
private int orderType = -1;
|
||||
private int type = -1;
|
||||
private String orderId;
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutResId() {
|
||||
return R.layout.activity_order_detail;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
context = this;
|
||||
progressDialog = new ProgressDialog(this);
|
||||
ImmersionBar.with(this)
|
||||
.keyboardEnable(true) //解决软键盘与底部输入框冲突问题
|
||||
// .keyboardEnable(true, WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE
|
||||
// | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) //软键盘自动弹出
|
||||
.init();
|
||||
context = this;
|
||||
progressDialog = new ProgressDialog(this);
|
||||
type = getIntent().getIntExtra("type", -1);
|
||||
orderType = getIntent().getIntExtra("orderType", -1);
|
||||
orderId = getIntent().getStringExtra("orderId");
|
||||
mDataBinding.left.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
mDataBinding.tvTitle.setText("订单详情");
|
||||
getData();
|
||||
}
|
||||
|
||||
Loader loader = new Loader();
|
||||
|
||||
private void getData() {
|
||||
RegisterUser user =
|
||||
Config.getInstance(context).getUser();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
if (user != null) {
|
||||
map.put("userid", user.getUserid());
|
||||
} else {
|
||||
map.put("userid", 0 + "");
|
||||
}
|
||||
map.put("app", "Order");
|
||||
map.put("class", "OrderInfo");
|
||||
map.put("order_id", orderId);
|
||||
map.put("sign", Md5.md5("Order" + "OrderInfo" + Md5.secret));
|
||||
loader.getMovie(ApiConfig.BASE_URL, map).subscribe(new Action1<Resultcode>() {
|
||||
@Override
|
||||
public void call(Resultcode resultcode) {
|
||||
if (resultcode.status == 0) {
|
||||
LinkedTreeMap adta = (LinkedTreeMap) resultcode.data;
|
||||
String s = new Gson().toJson(adta);
|
||||
OrderListBean orderListBean = new Gson().fromJson(s, OrderListBean.class);
|
||||
setViewData(orderListBean);
|
||||
}
|
||||
}
|
||||
}, new Action1<Throwable>() {
|
||||
@Override
|
||||
public void call(Throwable throwable) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setViewData(final OrderListBean orderListBean) {
|
||||
BaseRecycleViewAdapter<OrderListBean.Content_info, ItemOrderItemBinding> itemAdapter = new BaseRecycleViewAdapter<>(context, R.layout.item_order_item);
|
||||
itemAdapter.setOnBindViewHolder(new BaseRecycleViewAdapter.BindView<ItemOrderItemBinding>() {
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ItemOrderItemBinding b, int position) {
|
||||
if (!(position >= orderListBean.getContent_info().size())) {
|
||||
OrderListBean.Content_info content_info = orderListBean.getContent_info().get(position);
|
||||
b.tvGoodsName.setText(content_info.getName());
|
||||
b.tvInfo2.setText(content_info.getProperty());
|
||||
b.tvPrice.setText("¥" + content_info.getSale_price());
|
||||
b.tvNum.setText("x" + content_info.getGoods_num());
|
||||
RequestOptions requestOptions = new RequestOptions();
|
||||
requestOptions.placeholder(R.mipmap.icon_default_rectangle);
|
||||
requestOptions.error(R.mipmap.icon_default_rectangle);
|
||||
|
||||
Glide.with(context).load(content_info.getImg())
|
||||
.apply(requestOptions)
|
||||
.into(b.ivGoods);
|
||||
}
|
||||
}
|
||||
});
|
||||
itemAdapter.setData(orderListBean.getContent_info());
|
||||
mDataBinding.rv.setLayoutManager(new LinearLayoutManager(context));
|
||||
mDataBinding.rv.setAdapter(itemAdapter);
|
||||
mDataBinding.tvAmount.setText("¥" + orderListBean.getOrder_money());
|
||||
mDataBinding.tv2.setText("¥" + orderListBean.getOrder_money());
|
||||
mDataBinding.tvOrderId.setText(orderListBean.getOrder_number());
|
||||
mDataBinding.tvOrderTime.setText(orderListBean.getCtime());
|
||||
if (orderListBean.getOrder_status().equals("0")) {
|
||||
mDataBinding.tvState.setText("等待买家付款");
|
||||
} else if (orderListBean.getOrder_status().equals("1")) {
|
||||
mDataBinding.tvState.setText("等待卖家发货");
|
||||
} else if (orderListBean.getOrder_status().equals("2")) {
|
||||
mDataBinding.tvState.setText("等待买家收货");
|
||||
} else if (orderListBean.getOrder_status().equals("3")) {
|
||||
mDataBinding.tvState.setText("订单已完成");
|
||||
}
|
||||
if (type == 1) {
|
||||
if (orderType == 1) {
|
||||
//待付款
|
||||
mDataBinding.btnFk.setVisibility(View.VISIBLE);
|
||||
mDataBinding.btnFk.setText("付款");
|
||||
mDataBinding.btnCancel.setVisibility(View.VISIBLE);
|
||||
mDataBinding.btnCancel.setText("取消订单");
|
||||
|
||||
} else if (orderType == 2) {
|
||||
//待发货
|
||||
mDataBinding.btnFk.setVisibility(View.VISIBLE);
|
||||
mDataBinding.btnFk.setText("取消订单");
|
||||
mDataBinding.btnCancel.setVisibility(View.GONE);
|
||||
|
||||
} else if (orderType == 3) {
|
||||
//待收货
|
||||
mDataBinding.btnFk.setVisibility(View.VISIBLE);
|
||||
mDataBinding.btnFk.setText("确认收货");
|
||||
mDataBinding.btnCancel.setVisibility(View.GONE);
|
||||
} else if (orderType == 4) {
|
||||
//待评价
|
||||
mDataBinding.btnFk.setVisibility(View.VISIBLE);
|
||||
mDataBinding.btnFk.setText("删除订单");
|
||||
mDataBinding.btnCancel.setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
} else if (type == 2) {
|
||||
|
||||
if (orderType == 2) {
|
||||
mDataBinding.btnFk.setVisibility(View.VISIBLE);
|
||||
mDataBinding.btnFk.setText("确认发货");
|
||||
} else {
|
||||
mDataBinding.btnFk.setVisibility(View.GONE);
|
||||
}
|
||||
mDataBinding.btnCancel.setVisibility(View.GONE);
|
||||
}
|
||||
mDataBinding.btnCancel.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//取消订单
|
||||
new XPopup.Builder(context).asConfirm("", "确定要取消订单吗?", new OnConfirmListener() {
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
orderAction(1, orderListBean.getOrder_id(), "");
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
});
|
||||
mDataBinding.btnFk.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mDataBinding.btnFk.getText().equals("付款")) {
|
||||
//付款
|
||||
|
||||
} else if (mDataBinding.btnFk.getText().equals("取消订单")) {
|
||||
new XPopup.Builder(context).asConfirm("", "确定要取消订单吗?", new OnConfirmListener() {
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
orderAction(1, orderListBean.getOrder_id(), "");
|
||||
}
|
||||
}).show();
|
||||
} else if (mDataBinding.btnFk.getText().equals("确认收货")) {
|
||||
new XPopup.Builder(context).asConfirm("", "真的要确认收货吗?", new OnConfirmListener() {
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
orderAction(2, orderListBean.getOrder_id(), "");
|
||||
}
|
||||
}).show();
|
||||
} else if (mDataBinding.btnFk.getText().equals("删除订单")) {
|
||||
new XPopup.Builder(context).asConfirm("", "确定要删除订单吗?", new OnConfirmListener() {
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
orderAction(3, orderListBean.getOrder_id(), "");
|
||||
}
|
||||
}).show();
|
||||
} else if (mDataBinding.btnFk.getText().equals("确认发货")) {
|
||||
new XPopup.Builder(context).asInputConfirm("确认发货", "", "", "请输入物流编号", new OnInputConfirmListener() {
|
||||
@Override
|
||||
public void onConfirm(String text) {
|
||||
orderAction(4, orderListBean.getOrder_id(), text);
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void orderAction(int action, String order_id, String info) {
|
||||
progressDialog.setMessage("提交中");
|
||||
progressDialog.show();
|
||||
RegisterUser user =
|
||||
Config.getInstance(context).getUser();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
if (user != null) {
|
||||
map.put("userid", user.getUserid());
|
||||
} else {
|
||||
map.put("userid", 0 + "");
|
||||
}
|
||||
map.put("app", "Order");
|
||||
if (action == 4) {
|
||||
map.put("class", "StoreOrderAction");
|
||||
map.put("logistics_no", info);
|
||||
} else {
|
||||
map.put("class", "OrderAction");
|
||||
|
||||
}
|
||||
map.put("action", action + "");
|
||||
map.put("order_id", order_id);
|
||||
if (action == 4) {
|
||||
map.put("sign", Md5.md5("Order" + "StoreOrderAction" + Md5.secret));
|
||||
} else {
|
||||
map.put("sign", Md5.md5("Order" + "OrderAction" + Md5.secret));
|
||||
|
||||
}
|
||||
loader.getMovie(ApiConfig.BASE_URL, map).subscribe(new Action1<Resultcode>() {
|
||||
@Override
|
||||
public void call(Resultcode resultcode) {
|
||||
progressDialog.dismiss();
|
||||
if (resultcode.status == 0) {
|
||||
setToast(resultcode.msg);
|
||||
page = 1;
|
||||
setResult(200);
|
||||
finish();
|
||||
} else {
|
||||
setToast(resultcode.msg);
|
||||
}
|
||||
}
|
||||
}, new Action1<Throwable>() {
|
||||
@Override
|
||||
public void call(Throwable throwable) {
|
||||
progressDialog.dismiss();
|
||||
setToast("操作失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.sl.house_property.order;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.sl.house_property.BaseActivity;
|
||||
import com.sl.house_property.R;
|
||||
import com.sl.house_property.databinding.ActivitySettleBinding;
|
||||
|
||||
public class SettleActivity extends BaseActivity<ActivitySettleBinding> {
|
||||
@Override
|
||||
protected int getLayoutResId() {
|
||||
return R.layout.activity_settle;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user