空格
This commit is contained in:
@@ -0,0 +1,200 @@
|
||||
package com.xscm.moduleutil.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.adapter.BalanceRechargeAdapter;
|
||||
import com.xscm.moduleutil.adapter.PayMethodAdapter;
|
||||
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.AppPay;
|
||||
import com.xscm.moduleutil.bean.BindType;
|
||||
import com.xscm.moduleutil.bean.RechargeBean;
|
||||
import com.xscm.moduleutil.databinding.FragmentRechargeDialogBinding;
|
||||
import com.xscm.moduleutil.presenter.RechargeDialogContacts;
|
||||
import com.xscm.moduleutil.presenter.RechargeDialogPresenter;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
import com.xscm.moduleutil.widget.PaymentUtil;
|
||||
import com.tencent.mm.opensdk.openapi.IWXAPI;
|
||||
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/6/12
|
||||
*@description: 充值弹框
|
||||
*/
|
||||
public class RechargeDialogFragment extends BaseMvpDialogFragment<RechargeDialogPresenter, FragmentRechargeDialogBinding> implements RechargeDialogContacts.View {
|
||||
private BalanceRechargeAdapter rechargeAdapter;
|
||||
private String money = "0";
|
||||
private String type ;
|
||||
private String coin;
|
||||
private BindType.AllData selectedItem;
|
||||
private PayMethodAdapter bindTypeAdapter;
|
||||
private String roomId;
|
||||
|
||||
public static void show(String id, String type,FragmentManager fragmentManager) {
|
||||
RechargeDialogFragment dialogFragment = new RechargeDialogFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString("roomId", id); //// 可选:传递参数
|
||||
args.putString("type", type);
|
||||
dialogFragment.setArguments(args);
|
||||
dialogFragment.show(fragmentManager, "RoomOnlineDialogFragment");
|
||||
}
|
||||
@Override
|
||||
protected void initDialogStyle(Window window) {
|
||||
super.initDialogStyle(window);
|
||||
window.setGravity(Gravity.BOTTOM);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
roomId = getArguments().getString("roomId");
|
||||
type = getArguments().getString("type");
|
||||
if(type!=null){
|
||||
money=type;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RechargeDialogPresenter bindPresenter() {
|
||||
return new RechargeDialogPresenter(this, getContext());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
if (roomId!=null) {
|
||||
MvpPre.recharge();
|
||||
}
|
||||
MvpPre.bindType(SpUtil.getUserId() + "");
|
||||
|
||||
}
|
||||
private void onClick(View view) {
|
||||
if (view.getId() == R.id.tv_payment) {
|
||||
if (money.equals("0")) {
|
||||
money=mBinding.etCustomAmount.getText().toString().trim();
|
||||
if (TextUtils.isEmpty(money)) {
|
||||
ToastUtils.showShort("请选择充值金额");
|
||||
return;
|
||||
}
|
||||
}
|
||||
// if (Double.valueOf(money) < 6) {
|
||||
// ToastUtils.showShort("最低充值6元以上");
|
||||
// return;
|
||||
// }
|
||||
|
||||
if (selectedItem == null) {
|
||||
ToastUtils.showShort("请选择支付方式");
|
||||
return;
|
||||
}
|
||||
MvpPre.appPay(SpUtil.getUserId() + "", money, coin, selectedItem.getType());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void initView() {
|
||||
mBinding.tvPayment.setOnClickListener(this::onClick);
|
||||
mBinding.recycleView1.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
|
||||
bindTypeAdapter = new PayMethodAdapter(R.layout.item_bind_type);
|
||||
mBinding.recycleView1.setAdapter(bindTypeAdapter);
|
||||
|
||||
bindTypeAdapter.setOnItemClickListener((adapter, view, position) -> {
|
||||
// 更新选中项
|
||||
bindTypeAdapter.setSelectedPosition(position);
|
||||
|
||||
// 获取当前选中的数据
|
||||
selectedItem = bindTypeAdapter.getItem(position);
|
||||
// 可以在这里处理选中逻辑,比如保存到变量或触发支付
|
||||
});
|
||||
|
||||
if (type!=null){
|
||||
mBinding.r4.setVisibility(View.GONE);
|
||||
}else{
|
||||
mBinding.r4.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_recharge_dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRechargeData(List<RechargeBean> rechargeData) {
|
||||
RechargeBean customItem = new RechargeBean();
|
||||
customItem.setCoins("自定义");
|
||||
customItem.setMoney("");
|
||||
customItem.setItemViewType(1);
|
||||
rechargeData.add(customItem);
|
||||
rechargeAdapter = new BalanceRechargeAdapter(rechargeData);
|
||||
rechargeAdapter.setNewData(rechargeData);
|
||||
rechargeAdapter.setListener(new BalanceRechargeAdapter.OnRechargeItemClickListener() {
|
||||
@Override
|
||||
public void onClick(RechargeBean rechargeBean) {
|
||||
money = rechargeBean.getMoney();
|
||||
// mBinding.tvPayment.setText(String.format("立即支付(%s元)", money));
|
||||
}
|
||||
});
|
||||
rechargeAdapter.setInputBoxVisibilityListener(new BalanceRechargeAdapter.InputBoxVisibilityListener() {
|
||||
@Override
|
||||
public void onInputBoxVisibilityChanged(boolean isVisible) {
|
||||
// 根据 isVisible 的值来显示或隐藏输入框
|
||||
mBinding.r4.setVisibility(isVisible ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
});
|
||||
mBinding.rvComment.setLayoutManager(new GridLayoutManager(getContext(), 3));
|
||||
mBinding.rvComment.setAdapter(rechargeAdapter);
|
||||
mBinding.tvPayment.setText("立即支付");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void bindType(BindType bindType) {
|
||||
List<BindType.AllData> allData = new ArrayList<>();
|
||||
if (bindType.getAli().getIs_pay_open().equals("1")) {
|
||||
allData.add(bindType.getAli());
|
||||
}
|
||||
if (bindType.getWx().getIs_pay_open().equals("1")) {
|
||||
allData.add(bindType.getWx());
|
||||
}
|
||||
if (bindType.getBank().getIs_pay_open().equals("1")) {
|
||||
allData.add(bindType.getBank());
|
||||
}
|
||||
if (bindType.getAli_tl().getIs_pay_open().equals("1")) {
|
||||
allData.add(bindType.getAli_tl());
|
||||
}
|
||||
if (bindType.getWx_tl().getIs_pay_open().equals("1")) {
|
||||
allData.add(bindType.getWx_tl());
|
||||
}
|
||||
|
||||
bindTypeAdapter.setNewData(allData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appPay(AppPay appPay) {
|
||||
if (appPay.getAli()!=null) {
|
||||
PaymentUtil.payAlipay(getContext(), appPay.getAli());
|
||||
}else if (appPay.getWx()!=null){
|
||||
|
||||
IWXAPI wxapi = WXAPIFactory.createWXAPI(getContext(), CommonAppContext.getInstance().getCurrentEnvironment().getWxAppId());
|
||||
PaymentUtil.payWxMiniProgram2(wxapi,appPay);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user