Commit 805bac58 authored by mengcuiguang's avatar mengcuiguang

代码优化

parent 4ae4c218
package com.duben.shortplay.mvp.model;
import java.io.Serializable;
public class FirstCancel implements Serializable {
private boolean weixin;
private boolean alipay;
private boolean showCycTips;// 判断是否提示
private double firstPayPrice;
private double oldPrice;
private int days;
private int trial;//是否签约 0-没签约 1-签约
private int trialFirstDay;
private int activityType;//0-不显示 1-显示
private String remarks;//底部描述
private String pid;
private String title;
private String topTitle;
private String buttonText;
public String getButtonText() {
return buttonText;
}
public boolean isWeixin() {
return weixin;
}
public boolean isAlipay() {
return alipay;
}
public double getPrice() {
return firstPayPrice;
}
public double getOldPrice() {
return oldPrice;
}
public void setOldPrice(double oldPrice) {
this.oldPrice = oldPrice;
}
public int getDays() {
return days;
}
public void setDays(int days) {
this.days = days;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public int getActivityType() {
return activityType;
}
public void setActivityType(int activityType) {
this.activityType = activityType;
}
public String getTitle() {
return title;
}
public String getTopTitle() {
return topTitle;
}
public void setTitle(String title) {
this.title = title;
}
public boolean isShowCycTips() {
return showCycTips;
}
public int getTrialFirstDay() {
return trialFirstDay;
}
public int getTrial() {
return trial;
}
}
package com.duben.shortplay.mvp.model;
import java.io.Serializable;
public class SecondCancel implements Serializable {
private boolean weixin;
private boolean alipay;
private boolean showCycTips;// 判断是否提示
private double firstPayPrice;
private double oldPrice;
private int days;
private int trial;//是否签约 0-没签约 1-签约
private int trialFirstDay;
private int activityType;//0-不显示 1-显示
private String remarks;//底部描述
private String pid;
private String title;
private String topTitle;
private String buttonText;
public String getButtonText() {
return buttonText;
}
public boolean isWeixin() {
return weixin;
}
public boolean isAlipay() {
return alipay;
}
public double getPrice() {
return firstPayPrice;
}
public double getOldPrice() {
return oldPrice;
}
public void setOldPrice(double oldPrice) {
this.oldPrice = oldPrice;
}
public int getDays() {
return days;
}
public void setDays(int days) {
this.days = days;
}
public String getRemarks() {
return remarks;
}
public void setRemarks(String remarks) {
this.remarks = remarks;
}
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public int getActivityType() {
return activityType;
}
public void setActivityType(int activityType) {
this.activityType = activityType;
}
public String getTitle() {
return title;
}
public String getTopTitle() {
return topTitle;
}
public void setTitle(String title) {
this.title = title;
}
public boolean isShowCycTips() {
return showCycTips;
}
public int getTrialFirstDay() {
return trialFirstDay;
}
public int getTrial() {
return trial;
}
}
...@@ -6,6 +6,9 @@ import java.util.List; ...@@ -6,6 +6,9 @@ import java.util.List;
public class VipBean implements Serializable { public class VipBean implements Serializable {
private List<ListBean> list; private List<ListBean> list;
private FirstCancel firstCancel;
private SecondCancel secondCancel;
private boolean needClick;// 是否勾选协议 true-勾选 private boolean needClick;// 是否勾选协议 true-勾选
...@@ -17,6 +20,22 @@ public class VipBean implements Serializable { ...@@ -17,6 +20,22 @@ public class VipBean implements Serializable {
return list; return list;
} }
public FirstCancel getFirstCancel() {
return firstCancel;
}
public void setFirstCancel(FirstCancel firstCancel) {
this.firstCancel = firstCancel;
}
public SecondCancel getSecondCancel() {
return secondCancel;
}
public void setSecondCancel(SecondCancel secondCancel) {
this.secondCancel = secondCancel;
}
public class ListBean implements Serializable{ public class ListBean implements Serializable{
private boolean weixin; private boolean weixin;
......
...@@ -79,6 +79,7 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener, ...@@ -79,6 +79,7 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
private val vipPresenter by lazy { VipPresenter() } private val vipPresenter by lazy { VipPresenter() }
private lateinit var vipAdapter: VipAdapter private lateinit var vipAdapter: VipAdapter
private var vipList: MutableList<VipBean.ListBean>? = null private var vipList: MutableList<VipBean.ListBean>? = null
private var vipData: VipBean = null
private var isCheckAgreeFlag: Boolean = true private var isCheckAgreeFlag: Boolean = true
private var isGuide: Boolean = false// 从启动页进入vip界面,返回时要回到首页 private var isGuide: Boolean = false// 从启动页进入vip界面,返回时要回到首页
private var isMain: Boolean = false private var isMain: Boolean = false
...@@ -154,6 +155,7 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener, ...@@ -154,6 +155,7 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
} }
override fun getVipProductSuc(data: VipBean) { override fun getVipProductSuc(data: VipBean) {
this.vipData = data
if (!isFinishing) { if (!isFinishing) {
if (data.list != null && data.list.size > 0) { if (data.list != null && data.list.size > 0) {
vipList = data.list vipList = data.list
...@@ -491,15 +493,14 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener, ...@@ -491,15 +493,14 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
val alipayCount = val alipayCount =
AppPreferencesManager.get().getInt(Constant.ALIPAY_COUNT, 0) AppPreferencesManager.get().getInt(Constant.ALIPAY_COUNT, 0)
AppPreferencesManager.get().put(Constant.ALIPAY_COUNT, alipayCount + 1) AppPreferencesManager.get().put(Constant.ALIPAY_COUNT, alipayCount + 1)
showPayCancelDialog()
// if (vipList != null && vipList!!.size > 0) {
// val vipBean = vipList!![vipAdapter.getPosition()]
// // 0.01
// if (vipBean.trial != 0) {
// showPayCancelDialog() // showPayCancelDialog()
// } if (vipList != null && vipList!!.size > 0) {
// } val vipBean = vipList!![vipAdapter.getPosition()]
// 0.01
if (vipBean.trial != 0) {
showPayCancelDialog()
}
}
}, },
2000 2000
...@@ -741,20 +742,32 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener, ...@@ -741,20 +742,32 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener,
// 金额 // 金额
val alipayCount = val alipayCount =
AppPreferencesManager.get().getInt(Constant.ALIPAY_COUNT, 0) AppPreferencesManager.get().getInt(Constant.ALIPAY_COUNT, 0)
var vipBean = vipList!![0]
var price = vipBean.price
var pid = vipBean.pid
var oldPrice = vipBean.oldPrice
if (alipayCount == 1) { if (alipayCount == 1) {
if (vipData != null && vipData.firstCancel != null) {
} else if (alipayCount == 2) { price = vipData.firstCancel.price
pid = vipData.firstCancel.pid
oldPrice = vipData.firstCancel.oldPrice
} }
val vipBean = vipList!![0] } else if (alipayCount >= 2) {
VipPayCancelDialog(this, vipBean.price, object : DialogListener() { if (vipData != null && vipData.secondCancel != null) {
price = vipData.secondCancel.price
pid = vipData.secondCancel.pid
oldPrice = vipData.secondCancel.oldPrice
}
}
VipPayCancelDialog(this, price, oldPrice, object : DialogListener() {
override fun onClick(dialog: Dialog?, v: View?) { override fun onClick(dialog: Dialog?, v: View?) {
super.onClick(dialog, v) super.onClick(dialog, v)
dialog?.dismiss() dialog?.dismiss()
vipPresenter.getVipPayParams( vipPresenter.getVipPayParams(
"ALIPAY", "ALIPAY",
vipBean.pid, isAliPayInstalled() pid, isAliPayInstalled()
) )
} }
}) })
......
...@@ -14,6 +14,7 @@ import kotlinx.android.synthetic.main.dialog_vip_pay_cancel.* ...@@ -14,6 +14,7 @@ import kotlinx.android.synthetic.main.dialog_vip_pay_cancel.*
class VipPayCancelDialog( class VipPayCancelDialog(
val activity: Activity, val activity: Activity,
val cash: Double, val cash: Double,
val coupon: Double,
private val listener: DialogListener private val listener: DialogListener
) : ) :
Dialog(activity, R.style.dialog) { Dialog(activity, R.style.dialog) {
...@@ -42,7 +43,7 @@ class VipPayCancelDialog( ...@@ -42,7 +43,7 @@ class VipPayCancelDialog(
dismiss() dismiss()
} }
tv_cancel_cash.text="${cash}元" tv_cancel_cash.text="${cash}元"
tv_cancel_coupon.text="赠送${cash}元体验券" tv_cancel_coupon.text="赠送${coupon-cash}元体验券"
listener.setDialog(this) listener.setDialog(this)
findViewById<View>(R.id.btn).setOnClickListener(listener) findViewById<View>(R.id.btn).setOnClickListener(listener)
......
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 to comment