Commit eba5811b authored by maxiaoliang's avatar maxiaoliang

提交

parent cd95bbcc
......@@ -21,7 +21,7 @@ public class NetConfig {
}
// 根据调试选项更新环境
public static Environment sEnvironment = DEV;// 当前环境
public static Environment sEnvironment = PRODUCT;// 当前环境
public static String BASE_WEB_URL = "";
public static String BASE_URL = "";
public static String BASE_NEW_URL = "";
......
......@@ -1741,5 +1741,16 @@ public class SettingPreference {
editor.putInt("PAY_TIPS_DIALOG", num);
editor.commit();
}
public static String getShowUseDiscount() {
SharedPreferences settings = AppContext.get().getSharedPreferences(USER_SETTING, 0);
return settings.getString("SHOW_USE_DISCOUNT_DIALOG", "0");
}
public static void setShowUseDiscount(String isshow) {
SharedPreferences settings = AppContext.get().getSharedPreferences(USER_SETTING, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString("SHOW_USE_DISCOUNT_DIALOG", isshow);
editor.commit();
}
}
......@@ -398,5 +398,5 @@ interface IHomeApi {
//获取用户话费券列表
@GET(NetConfig.QY.XX_GOODS_FETCHALL_CARD)
fun getFetchallCard( @Query("phone") phone: String?): Observable<Response<List<CouponsEntity>>>
fun getFetchallCard(): Observable<Response<List<CouponsEntity>>>
}
\ No newline at end of file
......@@ -37,5 +37,6 @@
<color name="color_b28a17">#B28A17</color>
<color name="color_ddcb97">#DDCB97</color>
<color name="color_ba7e36">#BA7E36</color>
<color name="color_f8e8cc">#F8E8CC</color>
</resources>
\ No newline at end of file
......@@ -3,10 +3,12 @@ package com.zxbw.modulemain.activity
import android.app.Dialog
import android.graphics.Paint
import android.os.Handler
import android.text.TextUtils
import android.util.Log
import android.view.View
import androidx.recyclerview.widget.GridLayoutManager
import com.zxbw.modulemain.R
import com.zxbw.modulemain.adapter.OperatorAdapter
import com.zxbw.modulemain.adapter.RechargeAdapter
import com.zxbw.modulemain.contract.RechargeContract
import com.zxbw.modulemain.presenter.RechargePresenter
......@@ -16,7 +18,10 @@ import com.zxhl.cms.common.Constant
import com.zxhl.cms.common.base.BaseActivity
import com.zxhl.cms.net.SettingPreference
import com.zxhl.cms.net.model.box.AppInEntity
import com.zxhl.cms.net.model.box.MobileOpEntity
import com.zxhl.cms.net.model.qy.CouponsEntity
import com.zxhl.cms.net.model.qy.RightsDetailEntity
import com.zxhl.cms.net.model.qy.SkillGoodsEntity
import com.zxhl.cms.net.model.uc.AliPayEntity
import com.zxhl.cms.net.model.uc.PayResultEntity
import com.zxhl.cms.net.model.video.MemberEntity
......@@ -36,20 +41,24 @@ import kotlinx.android.synthetic.main.activity_layout_recharge.id_rl_h5_pay_view
class RechargeActivity : BaseActivity(), OnRecycleItemClickListener<MemberEntity.ProductDetail>,
RechargeContract.View {
private var mAdapter: RechargeAdapter? = null
private var mOperatorAdapter:OperatorAdapter?=null
private var mPresenter: RechargePresenter? = null
private var couponsentity: CouponsEntity? = null
private var mLoading: LoadingDialog? = null
private var pay_type: Int? = RightsDetailActivity.H5_PAY
private var payResultObservable: Observable<PayResultEntity>? = null
private var mobileOp:String?=""
private var selectPrice:String?=""
var goodsID: String? = ""
var couponId: String? = ""
private var position:Int?=-1
override fun onClick(v: View?) {
when (v) {
id_tv_select_coupons -> {
//如果有默认选中,传入默认选中的优惠券
DialogUtils.showFetchAllCard(
this,
"100",
selectPrice.toString(),
null,
mCouponsResult,
object : DialogUtils.OnFetchCardListener {
......@@ -73,13 +82,30 @@ class RechargeActivity : BaseActivity(), OnRecycleItemClickListener<MemberEntity
}
override fun init() {
id_img_back?.setOnClickListener {
finish()
}
val user = SettingPreference.getUserInfoData()
initPay()
mOperatorAdapter= OperatorAdapter(this, OnRecycleItemClickListener<MobileOpEntity> { view, position, data ->
mobileOp=data.value
})
id_rl_yunyingshang?.layoutManager=GridLayoutManager(this,3)
id_rl_yunyingshang?.adapter=mOperatorAdapter
var result = SettingPreference.getConfig()
if(!result?.mobileOpList.isNullOrEmpty()){
mOperatorAdapter?.clear()
mOperatorAdapter?.appendToList(result?.mobileOpList)
mOperatorAdapter?.notifyDataSetChanged()
}
mPresenter = RechargePresenter(this)
mAdapter = RechargeAdapter(this, this)
id_rl_recharge?.layoutManager = GridLayoutManager(this, 3)
id_rl_recharge?.adapter = mAdapter
mPresenter?.getFetchCard(user.nickname)
mPresenter?.getFetchCard()
mPresenter?.getPayList("mobileFee")
id_edit_user_phone?.setText(user.nickname.toString())
id_tv_select_coupons?.setOnClickListener(this)
......@@ -169,6 +195,10 @@ class RechargeActivity : BaseActivity(), OnRecycleItemClickListener<MemberEntity
showToast("请检查要兑换的手机号")
return
}
if(TextUtils.isEmpty(mobileOp)){
showToast("请选择运营商")
return
}
isClickPayBtn = true
mLoading?.setLoading("请稍后...")
mLoading?.show()
......@@ -180,17 +210,17 @@ class RechargeActivity : BaseActivity(), OnRecycleItemClickListener<MemberEntity
false,
"",
couponsentity?.id,
"SHKC_CT"
mobileOp
)
}
private var mCouponsResult: List<CouponsEntity>? = null;
private var mCouponsResult: List<CouponsEntity>? = null
override fun setCouponsList(result: List<CouponsEntity>?) {
mCouponsResult = result
if (!result.isNullOrEmpty()) {
couponsentity = result.get(0)
setCouponInfo(couponsentity)
}
// if (!result.isNullOrEmpty()) {
// couponsentity = result.get(0)
// setCouponInfo(couponsentity)
// }
}
override fun requestOrderSuc(result: AliPayEntity) {
......@@ -265,20 +295,105 @@ class RechargeActivity : BaseActivity(), OnRecycleItemClickListener<MemberEntity
mAdapter?.notifyDataSetChanged()
if (!result.goodsList.isNullOrEmpty()) {
if (result.goodsList!!.size >= 3) {
useCoupn(0,0)
}
}
}
fun useCoupn(default: Int,price:Int){
if(!mCouponsResult.isNullOrEmpty()){
for(i in mCouponsResult!!){
if(price==200){
if(TextUtils.equals(i.amount,"10.0")){
//判断当有5元券时 帮他选择100元档位且使用当前5元的券
Log.e("MXL","优先使用10元优惠券")
couponsentity=i
setCouponInfo(couponsentity)
break
}
}else{
if(TextUtils.equals(i.amount,"5.0")){
//判断当有5元券时 帮他选择100元档位且使用当前5元的券
Log.e("MXL","使用5元优惠券")
if(default==0){
mAdapter?.setPosition(1)
selectPrice= mAdapter?.getItem(1)?.originalPrice
goodsID = mAdapter?.getItem(1)?.goodsId
memberentity=mAdapter?.getItem(1)
}
couponsentity=i
setCouponInfo(couponsentity)
break
}
}
}
Log.e("MXL","循环结束取到优惠券信息")
if(couponsentity==null){
Log.e("MXL","没有5元的 使用10元券")
if(default==0){
mAdapter?.setPosition(2)
goodsID = result.goodsList?.get(2)?.goodsId
selectPrice= mAdapter?.getItem(2)?.originalPrice
goodsID = mAdapter?.getItem(2)?.goodsId
memberentity=mAdapter?.getItem(2)
}
couponsentity=mCouponsResult!!.get(0)
setCouponInfo(couponsentity)
}
Log.e("MXL","price:"+price+"default:"+default)
// mAdapter?.updateData( couponsentity?.amount.toString())
if(SettingPreference.getShowUseDiscount().equals("0")){
DialogUtils.showHuafeiTips(this)
}
}else{
Log.e("MXL","当前无可用优惠券")
mAdapter?.updateData( "")
if(default==0){
memberentity=mAdapter?.getItem(1)
mAdapter?.setPosition(1)
selectPrice= mAdapter?.getItem(1)?.originalPrice
goodsID = mAdapter?.getItem(1)?.goodsId
}
couponsentity=null
setCouponInfo(couponsentity)
}
}
var memberentity: MemberEntity.ProductDetail? = null
override fun onItemClick(view: View?, position: Int, data: MemberEntity.ProductDetail?) {
memberentity = data
selectPrice=data?.originalPrice
goodsID = data?.goodsId
chosseData(position,data)
}
fun chosseData(position: Int,data: MemberEntity.ProductDetail?){
when (position) {
0->{
Log.e("MXL","选0")
couponsentity=null
setCouponInfo(couponsentity)
setBootomPrice(data)
return
}
1->{
Log.e("MXL","选1")
useCoupn(1,100)
setBootomPrice(data)
return
}
2->{
Log.e("MXL","选2")
useCoupn(1,200)
setBootomPrice(data)
return
}
}
}
fun setBootomPrice(data: MemberEntity.ProductDetail?) {
if (couponsentity == null) {
id_tv_cash?.text = "${data?.cash}"
......@@ -296,10 +411,12 @@ class RechargeActivity : BaseActivity(), OnRecycleItemClickListener<MemberEntity
setBootomPrice(memberentity)
if (entity != null) {
Log.e("MXL", "选择这个优惠券")
mAdapter?.updateData(entity?.amount.toString())
id_tv_select_coupons?.text = "您已选择${entity?.amount}元优惠券"
} else {
Log.e("MXL", "无优惠券可选")
id_tv_select_coupons?.text = "未选择优惠券"
mAdapter?.updateData("")
id_tv_select_coupons?.text = "无可用优惠券"
}
}
......
......@@ -3,6 +3,8 @@ package com.zxbw.modulemain.adapter
import android.app.Activity
import android.graphics.Color
import android.graphics.Paint
import android.text.TextUtils
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
......@@ -15,12 +17,14 @@ import com.zxhl.cms.common.base.BaseRecyclerAdapter
import com.zxhl.cms.net.model.video.MemberEntity
import com.zxhl.cms.utils.OnRecycleItemClickListener
class RechargeAdapter : BaseRecyclerAdapter<MemberEntity.ProductDetail, RechargeAdapter.ViewHolder> {
class RechargeAdapter :
BaseRecyclerAdapter<MemberEntity.ProductDetail, RechargeAdapter.ViewHolder> {
private var mContext: Activity? = null
private val listener: OnRecycleItemClickListener<MemberEntity.ProductDetail>
private val mSelectColor: Int
private val mUnSelectColor: Int
private var position = -1
private var price:String?=""
constructor(
content: Activity?,
listener: OnRecycleItemClickListener<MemberEntity.ProductDetail>
......@@ -30,22 +34,36 @@ class RechargeAdapter : BaseRecyclerAdapter<MemberEntity.ProductDetail, Recharge
mSelectColor = AppContext.get().resources.getColor(R.color.color_ba7e36)
mUnSelectColor = AppContext.get().resources.getColor(R.color.color_333333)
}
fun setPosition(pos: Int) {
position = pos
notifyDataSetChanged()
}
fun updateData( discountprice: String) {
price=discountprice
notifyDataSetChanged()
}
override fun onBindViewHolder(holder: ViewHolder, pos: Int) {
var bean = mList[pos]
if(pos==position){
holder.id_tv_activity_price_text?.text = "活动价"
holder.id_tv_price?.text = "${bean.cash}"
if (pos == position) {
if(!TextUtils.isEmpty(price)){
Log.e("MXL","更新ui")
holder.id_tv_activity_price_text?.text="已减${price}元"
holder.id_tv_price?.text = "${bean.cash?.toDoubleOrNull()?.minus(price?.toDoubleOrNull()!!)}"
}
holder.id_ll_item?.setBackgroundResource(R.drawable.shape_edd49d_r6)
holder.id_tv_activity_price_text?.setBackgroundResource(R.drawable.shape_edd49d_r11)
holder.id_tv_activity_price_text?.setTextColor(mSelectColor)
holder.id_tv_price?.setTextColor(mSelectColor)
holder.id_tv_orgin_price?.setTextColor(mSelectColor)
holder.id_tv_rmb?.setTextColor(mSelectColor)
listener.onItemClick(holder.itemView, pos, bean)
}else{
// listener.onItemClick(holder.itemView, pos, bean)
} else {
holder.id_ll_item?.setBackgroundResource(R.drawable.shape_cbcbcb_r6)
holder.id_tv_activity_price_text?.setBackgroundResource(R.drawable.shape_a3a4a6_r10)
holder.id_tv_activity_price_text?.setTextColor(Color.parseColor("#ffffff"))
......@@ -53,14 +71,11 @@ class RechargeAdapter : BaseRecyclerAdapter<MemberEntity.ProductDetail, Recharge
holder.id_tv_orgin_price?.setTextColor(Color.parseColor("#999999"))
holder.id_tv_rmb?.setTextColor(mUnSelectColor)
}
holder.id_tv_activity_price_text?.text = "活动价"
holder.id_tv_price?.text="${bean.cash}"
holder.id_tv_orgin_price?.text="原价 ¥${bean.originalPrice}"
holder.id_tv_orgin_price?.text = "原价 ¥${bean.originalPrice}"
holder.id_tv_orgin_price?.getPaint()?.setFlags(Paint.STRIKE_THRU_TEXT_FLAG)
// holder.id_ll_item?.setOnClickListener {
// listener.onItemClick(it, position, bean)
// }
}
// override fun getItemCount(): Int {
......@@ -84,22 +99,23 @@ class RechargeAdapter : BaseRecyclerAdapter<MemberEntity.ProductDetail, Recharge
var id_tv_orgin_price: TextView?
constructor(
itemView: View
) : super(itemView) {
id_ll_item =
itemView.findViewById<LinearLayout>(R.id.id_ll_item)
id_tv_activity_price_text = itemView.findViewById<TextView>(R.id.id_tv_activity_price_text)
id_tv_activity_price_text =
itemView.findViewById<TextView>(R.id.id_tv_activity_price_text)
id_tv_rmb = itemView.findViewById<TextView>(R.id.id_tv_rmb)
id_tv_price = itemView.findViewById<TextView>(R.id.id_tv_price)
id_tv_orgin_price = itemView.findViewById<TextView>(R.id.id_tv_orgin_price)
id_ll_item?.setOnClickListener {
val pos = adapterPosition
Log.e("MXL", "pos:" + pos)
if (pos >= 0 && pos < mList.size) {
setPosition(pos)
notifyDataSetChanged()
listener.onItemClick(it, pos, mList[pos])
}
}
}
......
......@@ -21,7 +21,7 @@ class RechargeContract {
}
interface Presenter {
fun getFetchCard(phone: String)
fun getFetchCard()
fun getPayList(payModel: String)
fun requestRightsAliPay(
goodsId: String,
......
......@@ -26,7 +26,8 @@ class UserCenterFragment : BaseFragment(), AdCallback<String> {
override fun init(view: View?) {
id_ll_member?.setOnClickListener {
JumpUtils.RechargeJump()
// JumpUtils.RechargeJump()
}
id_img_kefu?.setOnClickListener {
JumpUtils.webJump("客服", NetConfig.H5.WEB_URL_CUSTOMER_SERVICE)
......
......@@ -21,8 +21,8 @@ class RechargePresenter : RechargeContract.Presenter {
this.mView = mView
}
override fun getFetchCard(phone: String) {
ApiClient.homeApi.getFetchallCard(phone).compose(RxSchedulers.observableIO2Main())
override fun getFetchCard() {
ApiClient.homeApi.getFetchallCard().compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<List<CouponsEntity>>() {
override fun onSuccess(result: List<CouponsEntity>?) {
mView.setCouponsList(result)
......
......@@ -460,7 +460,7 @@ object DialogUtils {
Gravity.CENTER
)
SettingPreference.setShowUseDiscount("1")
mDialog.setCanceledOnTouchOutside(true)
mDialog.setCancelable(true)
mDialog.show()
......
......@@ -75,7 +75,10 @@
android:inputType="phone"
android:textCursorDrawable="@drawable/cursor_color"
android:textSize="16sp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/id_rl_yunyingshang"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
......@@ -125,6 +128,7 @@
android:layout_height="wrap_content"
android:layout_below="@+id/id_img_huafei_bg"
android:layout_marginTop="-10dp"
android:paddingBottom="16dp"
android:background="@drawable/shape_ffffff_r6"
android:orientation="vertical">
......@@ -166,7 +170,8 @@
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
android:gravity="center"
android:orientation="horizontal">
android:orientation="horizontal"
android:visibility="gone">
<TextView
android:layout_width="wrap_content"
......@@ -178,7 +183,7 @@
android:textSize="10sp" />
<TextView
android:layout_width="wrap_content"
android:layout_width="1dp"
android:layout_height="15dp"
android:layout_marginLeft="32dp"
android:layout_marginRight="32dp"
......@@ -314,7 +319,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:text="94.8"
android:text=""
android:textColor="#BA7E36"
android:textSize="28sp"
android:textStyle="bold" />
......
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