Commit 5b098e6f by yjiucheng

壳工程中支付功能下沉

parent 98db7101
ext {
kotlin_version = "1.3.21"
dev_mode = false
dev_mode = true
ydl_app = [
appName : "心理咨询壹点灵",
......
......@@ -50,7 +50,7 @@ import com.yidianling.course.bean.CourseMediaDetailBean
import com.yidianling.course.coursePlay.presenter.CoursePlayPresenter
import com.yidianling.course.router.CourseIn
import com.yidianling.course.widget.VideoFloatHelper
import com.yidianling.ydl_pay.CommonPayDialog
import com.yidianling.ydl_pay.common.CommonPayDialog
import kotlinx.android.synthetic.main.activity_course_play.*
import org.json.JSONException
import org.json.JSONObject
......
......@@ -22,7 +22,7 @@ import com.yidianling.dynamic.thank.ShowIntroduceDialogFragment
import com.yidianling.dynamic.thank.ThankActivity
import com.yidianling.dynamic.thank.WorryDetailAnswer
import com.yidianling.dynamic.thank.data.ThxData
import com.yidianling.ydl_pay.CommonPayDialog
import com.yidianling.ydl_pay.common.CommonPayDialog
import de.greenrobot.event.EventBus
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
......
......@@ -3,4 +3,10 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application>
<activity
android:name=".pay.PayActivity"
android:screenOrientation="portrait" />
</application>
</manifest>
package com.yidianling.ydl_pay.bean; import android.text.TextUtils; import java.util.Map; public class PayResult { private String resultStatus; private String result; private String memo; public PayResult(Map<String, String> rawResult) { if (rawResult == null) { return; } for (String key : rawResult.keySet()) { if (TextUtils.equals(key, "resultStatus")) { resultStatus = rawResult.get(key); } else if (TextUtils.equals(key, "result")) { result = rawResult.get(key); } else if (TextUtils.equals(key, "memo")) { memo = rawResult.get(key); } } } @Override public String toString() { return "resultStatus={" + resultStatus + "};memo={" + memo + "};result={" + result + "}"; } /** * @return the resultStatus */ public String getResultStatus() { return resultStatus; } /** * @return the memo */ public String getMemo() { return memo; } /** * @return the result */ public String getResult() { return result; }}
\ No newline at end of file
package com.yidianling.ydl_pay
package com.yidianling.ydl_pay.common
import android.annotation.SuppressLint
import android.app.Activity
......@@ -15,14 +15,15 @@ import com.alipay.sdk.app.PayTask
import com.tencent.mm.opensdk.modelpay.PayReq
import com.tencent.mm.opensdk.openapi.WXAPIFactory
import com.yidianling.common.tools.RxImageTool
import com.yidianling.ydl_pay.bean.*
import com.yidianling.ydl_pay.bean.params.*
import com.yidianling.ydl_pay.http.HttpUtils
import com.yidianling.ydl_pay.http.utils.NetUtils
import com.yidianling.ydl_pay.http.utils.RxDeviceTool
import com.yidianling.ydl_pay.toast.ToastHelper
import com.yidianling.ydl_pay.widget.PayCouponView
import com.yidianling.ydl_pay.widget.PayInfoDetailView
import com.yidianling.ydl_pay.R
import com.yidianling.ydl_pay.common.bean.*
import com.yidianling.ydl_pay.common.bean.params.*
import com.yidianling.ydl_pay.common.http.HttpUtils
import com.yidianling.ydl_pay.common.http.utils.NetUtils
import com.yidianling.ydl_pay.common.http.utils.RxDeviceTool
import com.yidianling.ydl_pay.common.toast.ToastHelper
import com.yidianling.ydl_pay.common.widget.PayCouponView
import com.yidianling.ydl_pay.common.widget.PayInfoDetailView
import de.greenrobot.event.EventBus
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
......@@ -135,7 +136,9 @@ class CommonPayDialog : Dialog {
private fun initThanksPayInfoDetailView(bean: OrderInfoBean) {
view_pager.setScanScroll(false)
detailView =
PayInfoDetailView(activity, object : PayInfoDetailView.OnCouponDetailClickListener {
PayInfoDetailView(
activity,
object : PayInfoDetailView.OnCouponDetailClickListener {
override fun selectCoupon(couponId: String) {
}
......@@ -262,7 +265,9 @@ class CommonPayDialog : Dialog {
private fun updateDataOnView(bean: OrderInfoBean) {
view_pager.setScanScroll(false)
detailView =
PayInfoDetailView(activity, object : PayInfoDetailView.OnCouponDetailClickListener {
PayInfoDetailView(
activity,
object : PayInfoDetailView.OnCouponDetailClickListener {
override fun selectCoupon(couponId: String) {
if (couponListBean != null) {
view_pager.currentItem = 1
......
package com.yidianling.ydl_pay.actionpoint
package com.yidianling.ydl_pay.common.actionpoint
import android.content.Context
import android.net.ConnectivityManager
import android.net.NetworkInfo
import com.yidianling.ydl_pay.http.HttpUtils
import com.yidianling.ydl_pay.http.utils.RxDeviceTool
import com.yidianling.ydl_pay.common.http.HttpUtils
import com.yidianling.ydl_pay.common.http.utils.RxDeviceTool
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
......
package com.yidianling.ydl_pay.actionpoint
package com.yidianling.ydl_pay.common.actionpoint
/**
* Created by xj on 2019/6/22.
......
package com.yidianling.ydl_pay.actionpoint
package com.yidianling.ydl_pay.common.actionpoint
/**
* Created by xj on 2019/7/1.
......
package com.yidianling.ydl_pay.adapter
package com.yidianling.ydl_pay.common.adapter
import android.annotation.SuppressLint
import android.content.Context
......@@ -7,13 +7,13 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.yidianling.ydl_pay.actionpoint.ActionCountUtils
import com.yidianling.ydl_pay.actionpoint.BIConstants
import com.yidianling.ydl_pay.http.HttpConfig
import com.yidianling.ydl_pay.widget.CouponInfoDetailView
import com.yidianling.ydl_pay.common.actionpoint.ActionCountUtils
import com.yidianling.ydl_pay.common.actionpoint.BIConstants
import com.yidianling.ydl_pay.common.http.HttpConfig
import com.yidianling.ydl_pay.common.widget.CouponInfoDetailView
import com.yidianling.ydl_pay.R
import com.yidianling.ydl_pay.bean.AllCouponListBean
import com.yidianling.ydl_pay.bean.CommonCouponBean
import com.yidianling.ydl_pay.common.bean.AllCouponListBean
import com.yidianling.ydl_pay.common.bean.CommonCouponBean
import kotlinx.android.synthetic.main.item_coupon_title.view.*
/**
......
package com.yidianling.ydl_pay.bean;
package com.yidianling.ydl_pay.common.bean;
import java.util.ArrayList;
import java.util.List;
......
package com.yidianling.ydl_pay.bean
package com.yidianling.ydl_pay.common.bean
/**
* @author jiucheng
......
package com.yidianling.ydl_pay.bean
package com.yidianling.ydl_pay.common.bean
/**
* author : Zhangwenchao
......
package com.yidianling.ydl_pay.common.bean; import android.text.TextUtils; import java.util.Map; public class PayResult { private String resultStatus; private String result; private String memo; public PayResult(Map<String, String> rawResult) { if (rawResult == null) { return; } for (String key : rawResult.keySet()) { if (TextUtils.equals(key, "resultStatus")) { resultStatus = rawResult.get(key); } else if (TextUtils.equals(key, "result")) { result = rawResult.get(key); } else if (TextUtils.equals(key, "memo")) { memo = rawResult.get(key); } } } @Override public String toString() { return "resultStatus={" + resultStatus + "};memo={" + memo + "};result={" + result + "}"; } /** * @return the resultStatus */ public String getResultStatus() { return resultStatus; } /** * @return the memo */ public String getMemo() { return memo; } /** * @return the result */ public String getResult() { return result; }}
\ No newline at end of file
package com.yidianling.ydl_pay.bean.params;
package com.yidianling.ydl_pay.common.bean.params;
/**
* @author jiucheng
......
package com.yidianling.ydl_pay.bean.params;
package com.yidianling.ydl_pay.common.bean.params;
import com.ydl.ydlcommon.data.http.BaseCommand;
......
package com.yidianling.ydl_pay.bean.params;
package com.yidianling.ydl_pay.common.bean.params;
import com.ydl.ydlcommon.data.http.BaseCommand;
......
package com.yidianling.ydl_pay.bean.params;
package com.yidianling.ydl_pay.common.bean.params;
import com.ydl.ydlcommon.data.http.BaseCommand;
......
package com.yidianling.ydl_pay.bean.params;
package com.yidianling.ydl_pay.common.bean.params;
import com.ydl.ydlcommon.data.http.BaseCommand;
......
package com.yidianling.ydl_pay.bean.params;
package com.yidianling.ydl_pay.common.bean.params;
import com.ydl.ydlcommon.base.BaseApp;
import com.ydl.ydlcommon.base.config.YDLConstants;
......
package com.yidianling.ydl_pay.http
package com.yidianling.ydl_pay.common.http
/**
* @author jiucheng
......
package com.yidianling.ydl_pay.http
package com.yidianling.ydl_pay.common.http
import com.google.gson.Gson
import com.ydl.ydlcommon.data.http.BaseCommand
import com.ydl.ydlcommon.data.http.BaseResponse
import com.ydl.ydlcommon.utils.NetworkParamsUtils
import com.ydl.ydlnet.YDLHttpUtils
import com.yidianling.ydl_pay.actionpoint.ActionDataBean
import com.yidianling.ydl_pay.bean.*
import com.yidianling.ydl_pay.bean.params.CheckRequestCouponBean
import com.yidianling.ydl_pay.bean.params.CreateOrderRequestBean
import com.yidianling.ydl_pay.bean.params.GetAllCouponRequestBean
import com.yidianling.ydl_pay.bean.params.OrderRequestBean
import com.yidianling.ydl_pay.common.actionpoint.ActionDataBean
import com.yidianling.ydl_pay.common.bean.*
import com.yidianling.ydl_pay.common.bean.params.CheckRequestCouponBean
import com.yidianling.ydl_pay.common.bean.params.CreateOrderRequestBean
import com.yidianling.ydl_pay.common.bean.params.GetAllCouponRequestBean
import com.yidianling.ydl_pay.common.bean.params.OrderRequestBean
import com.yidianling.ydl_pay.pay.bean.RechargeBean
import io.reactivex.Observable
import okhttp3.MediaType
import okhttp3.RequestBody
......@@ -112,6 +113,23 @@ class HttpUtils {
return YDLHttpUtils.obtainApi(PayServices::class.java).pay(map)
}
/**
* 获得充值单号
*/
fun recharge(bean: BaseCommand): Observable<BaseResponse<RechargeBean>> {
var params = NetworkParamsUtils.getPostList(bean)
var map = NetworkParamsUtils.getMaps(params)
return YDLHttpUtils.obtainApi(PayServices::class.java).recharge(map)
}
/**
* 微信充值
*/
fun wxRecharge(bean: BaseCommand): Observable<BaseResponse<CommonWXPayBean>> {
var params = NetworkParamsUtils.getPostList(bean)
var map = NetworkParamsUtils.getMaps(params)
return YDLHttpUtils.obtainApi(PayServices::class.java).wxRecharge(map)
}
/**
* 行为数据埋点统计接口
......
package com.yidianling.ydl_pay.http
package com.yidianling.ydl_pay.common.http
import com.ydl.ydlcommon.base.config.YDL_DOMAIN
import com.ydl.ydlcommon.base.config.YDL_DOMAIN_JAVA
import com.ydl.ydlcommon.data.http.BaseResponse
import com.yidianling.ydl_pay.bean.*
import com.yidianling.ydl_pay.common.bean.*
import com.yidianling.ydl_pay.pay.bean.RechargeBean
import io.reactivex.Observable
import okhttp3.RequestBody
import retrofit2.http.*
......@@ -75,4 +76,14 @@ interface PayServices {
@FormUrlEncoded
@POST("pay/vcount-pay")
fun pay(@FieldMap params: Map<String, String>): Observable<BaseResponse<Any>>
//获得充值单号
@FormUrlEncoded
@POST("pay/recharge")
fun recharge(@FieldMap params: Map<String, String>): Observable<BaseResponse<RechargeBean>>
//微信充值
@FormUrlEncoded
@POST("pay/recharge-wx-option")
fun wxRecharge(@FieldMap params: Map<String, String>): Observable<BaseResponse<CommonWXPayBean>>
}
\ No newline at end of file
package com.yidianling.ydl_pay.http.log;
package com.yidianling.ydl_pay.common.http.log;
import android.util.Log;
......
package com.yidianling.ydl_pay.http.utils;
package com.yidianling.ydl_pay.common.http.utils;
import com.yidianling.ydl_pay.BuildConfig;
......
package com.yidianling.ydl_pay.http.utils;
package com.yidianling.ydl_pay.common.http.utils;
import android.content.Context;
import android.content.Intent;
......
package com.yidianling.ydl_pay.http.utils;
package com.yidianling.ydl_pay.common.http.utils;
import android.app.Activity;
import android.app.KeyguardManager;
......
package com.yidianling.ydl_pay.toast
package com.yidianling.ydl_pay.common.toast
import android.content.Context
import android.support.annotation.StringRes
......@@ -24,11 +24,13 @@ class ToastHelper private constructor() {
}
fun show(context: Context, text: String) {
getInstance().show(context.applicationContext, text)
getInstance()
.show(context.applicationContext, text)
}
fun show(context: Context, @StringRes resId: Int) {
getInstance().show(context.applicationContext, resId)
getInstance()
.show(context.applicationContext, resId)
}
}
......
package com.yidianling.ydl_pay.widget
package com.yidianling.ydl_pay.common.widget
import android.annotation.SuppressLint
import android.content.Context
......@@ -7,7 +7,7 @@ import android.view.View
import android.view.ViewGroup
import android.widget.RelativeLayout
import com.yidianling.ydl_pay.R
import com.yidianling.ydl_pay.bean.CommonCouponBean
import com.yidianling.ydl_pay.common.bean.CommonCouponBean
import kotlinx.android.synthetic.main.view_coupon_info_detail.view.*
import java.lang.Float
import java.math.BigDecimal
......
package com.yidianling.ydl_pay.widget;
package com.yidianling.ydl_pay.common.widget;
import android.content.Context;
import android.support.v4.view.ViewPager;
......
package com.yidianling.ydl_pay.widget
package com.yidianling.ydl_pay.common.widget
import android.content.Context
import android.os.Handler
......@@ -13,14 +13,14 @@ import android.view.inputmethod.InputMethodManager
import android.widget.EditText
import android.widget.LinearLayout
import android.widget.TextView
import com.yidianling.ydl_pay.adapter.SelectCouponAdapter
import com.yidianling.ydl_pay.http.HttpUtils
import com.yidianling.ydl_pay.toast.ToastHelper
import com.yidianling.ydl_pay.common.adapter.SelectCouponAdapter
import com.yidianling.ydl_pay.common.http.HttpUtils
import com.yidianling.ydl_pay.common.toast.ToastHelper
import com.yidianling.ydl_pay.R
import com.yidianling.ydl_pay.bean.AllCouponListBean
import com.yidianling.ydl_pay.bean.CommonCouponBean
import com.yidianling.ydl_pay.bean.params.CheckRequestCouponBean
import com.yidianling.ydl_pay.http.utils.NetUtils
import com.yidianling.ydl_pay.common.bean.AllCouponListBean
import com.yidianling.ydl_pay.common.bean.CommonCouponBean
import com.yidianling.ydl_pay.common.bean.params.CheckRequestCouponBean
import com.yidianling.ydl_pay.common.http.utils.NetUtils
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.head_course_code_view.view.*
......
package com.yidianling.ydl_pay.widget
package com.yidianling.ydl_pay.common.widget
import android.annotation.SuppressLint
import android.content.Context
......@@ -6,8 +6,8 @@ import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import com.yidianling.ydl_pay.R
import com.yidianling.ydl_pay.bean.CommonCouponBean
import com.yidianling.ydl_pay.bean.OrderInfoBean
import com.yidianling.ydl_pay.common.bean.CommonCouponBean
import com.yidianling.ydl_pay.common.bean.OrderInfoBean
import kotlinx.android.synthetic.main.view_pay_info_detail.view.*
import java.math.BigDecimal
......
package com.yidianling.ydl_pay.pay
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Intent
import android.graphics.Point
import android.support.v7.app.AlertDialog
import android.text.Spannable
import android.text.SpannableStringBuilder
import android.text.TextUtils
import android.text.style.ForegroundColorSpan
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import com.ydl.ydlcommon.base.BaseActivity
import com.ydl.ydlcommon.data.PlatformDataManager
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.data.http.ThrowableConsumer
import com.ydl.ydlcommon.utils.log.LogHelper
import com.yidianling.common.tools.ToastUtil
import com.yidianling.ydl_pay.R
import com.yidianling.ydl_pay.common.bean.params.AliPayParam
import com.yidianling.ydl_pay.common.bean.params.BalanceParam
import com.yidianling.ydl_pay.common.bean.params.ChargePayParam
import com.yidianling.ydl_pay.common.bean.params.WxPayParam
import com.yidianling.ydl_pay.common.http.HttpUtils
import com.yidianling.ydl_pay.pay.PayParams.CREATOR.INLET_NORMAL
import com.yidianling.ydl_pay.pay.PayParams.CREATOR.INLET_TEST
import com.yidianling.ydl_pay.pay.bean.*
import com.yidianling.ydl_pay.pay.redpacket.RedPacketBean
import com.yidianling.ydl_pay.pay.redpacket.RedPacketPayBean
import com.yidianling.ydl_pay.pay.redpacket.RedPacketPopWindow
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.functions.Consumer
import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.activity_pay.*
import kotlinx.android.synthetic.main.pay_fragment_loading_dialog.view.*
import java.text.DecimalFormat
/**
* 付款
* Created by softrice on 15/11/25.
* Updated by Zhangwenchao on 18/4/19
* Updated by yuanWai on 18/10/25 rxJava 简直太恶心了(只是界面逻辑重新梳理了一下,理想状态是拆分成两个fragment来做 然后把rxJava替换掉,但是时间不够,先这样吧)
*/
class PayActivity : BaseActivity() {
companion object {
/**
* 入参
* params 支付订单信息 正常入口传递
* params_redPacket 红包列表数据+支付金额 测评入口传递
*/
private const val PARAMS = "params"
private const val PARAMS_RED = "params_redPacket"
/**
* 支付类型
* 1.微信支付 2.支付宝支付
*/
private const val PAY_WECHAT = 1
private const val PAY_ALI = 2
//传递订单号 目前除测评入口使用
fun newIntent(activity: Activity, payParams: PayParams): Intent {
LogHelper.getInstance().writeLogSync("跳转到支付界面")
val intent = Intent(activity, PayActivity::class.java)
intent.putExtra(PARAMS, payParams)
return intent
}
//传递红包列表数据 目前只有测评入口使用 这个入口进来的调支付时 会先调订单生成接口--再调微信、支付宝支付(串联的行为)
fun newIntent(activity: Activity, redPacketPayBean: RedPacketPayBean): Intent {
LogHelper.getInstance().writeLogSync("跳转到支付界面")
val intent = Intent(activity, PayActivity::class.java)
intent.putExtra(PARAMS_RED, redPacketPayBean)
return intent
}
}
//订单信息数据
private var payParams: PayParams? = null
//红包列表数据+支付金额
private var redPacketPayBean: RedPacketPayBean? = null
//入口
private var inlet = PayParams.INLET_NORMAL
//红包列表弹窗
private var redPacketPopWindow: RedPacketPopWindow? = null
//加载中弹窗
private var dialog: AlertDialog? = null
private var dialogContentView: View? = null
//红包id 默认为0
private var redPacketId: String? = "0"
//使用红包金额
private var redPacketMoney: Float = 0f
//使用红包文案
private var redPacketMoneyContent: String = ""
//账户余额
private var balanceMoney: Float = 0f
//支付金额
private var payMoney: Float = 0F
//可使用余额
private var canBalanceMoney = 0F
//支付类型
private var payType = PAY_ALI
//测评下单数据bean
private var testAddOrderBean: TestAddOrderBean? = null
override fun layoutResId(): Int {
return R.layout.activity_pay
}
//获取参数
private fun getParam() {
if (null == intent) {
return
}
if (intent.hasExtra(PARAMS)) {
//订单信息数据
payParams = intent.getParcelableExtra(PARAMS)
if (null != payParams && null != payParams!!.coupon_money && 0f != payParams!!.coupon_money) {
inlet = payParams!!.inlet
redPacketMoney = payParams!!.coupon_money
val sb = StringBuffer()
sb.append("-").append("¥").append(numFormat(payParams!!.coupon_money))
redPacketMoneyContent = sb.toString()
}
} else if (intent.hasExtra(PARAMS_RED)) {
//红包列表数据
redPacketPayBean = intent.getParcelableExtra(PARAMS_RED)
if (null != redPacketPayBean) {
if (null != redPacketPayBean!!.payParams) {
inlet = redPacketPayBean!!.payParams.inlet
}
if (null != redPacketPayBean!!.data && !redPacketPayBean!!.data.isEmpty()) {
redPacketMoney = redPacketPayBean!!.data[0].coupon_money!!
redPacketId = redPacketPayBean!!.data[0].id
val sb = StringBuffer()
sb.append("-").append("¥").append(numFormat(redPacketMoney))
redPacketMoneyContent = sb.toString()
}
}
}
}
override fun initDataAndEvent() {
//获取参数
getParam()
//界面初始化
initView()
//设置是否显示付款保障文案
setPaymentVisible()
//设置付款保障文案
setPaymentText()
}
//初始化界面
private fun initView() {
//设置是否显示红包
setRedPacketVisible()
when (inlet) {
INLET_NORMAL -> {
//正常入口
if (null == payParams) {
return
}
//设置类型标题
setTypeTitle(payParams!!.title)
//设置支付金额
setTypeMoney(payParams!!.needPay)
//底部支付按钮文案
setPayBtnText(payParams!!.btnPayText)
if (payParams!!.type == PayParams.RECHARGE) {
//界面类型 充值
ll_select_pay.visibility = View.VISIBLE
ll_Balance.visibility = View.GONE
tvRestPay.text = payParams!!.needPay.toString()
//是否显示余额和红包之间 的间隔View
isVisibleBalanceTop()
} else {
//界面类型 付款
//请求余额接口
requestMyBalance()
}
}
INLET_TEST -> {
//测评入口 付款
//请求余额接口
requestMyBalance()
//设置支付金额
if (null == redPacketPayBean || null == redPacketPayBean!!.payParams) {
return
}
setTypeTitle(redPacketPayBean!!.payParams.title)
setTypeMoney(redPacketPayBean!!.payParams.needPay)
setPayBtnText(redPacketPayBean!!.payParams.btnPayText)
}
}
//客服
ll_kefu.setOnClickListener {
// ModularServiceManager.provide(IMServiceImpl::class.java).startP2PXiaoYi(this)
//todo
// ModularServiceManager.provide(IImService::class.java).startP2PXiaoYi(this)
}
//选择红包
ll_redPacket.setOnClickListener {
showRedPacketPopupWindow()
}
//默认选择微信支付
selectPayType(0)
//选择微信支付
ll_wechat.setOnClickListener { selectPayType(0) }
//选择支付宝支付
ll_alipay.setOnClickListener { selectPayType(1) }
//去支付
rcb_pay.setOnClickListener { onClickPay() }
}
/**
* 设置标题
*/
private fun setTypeTitle(title: String) {
tvType.text = title
}
/**
* 设置支付金额
*/
private fun setTypeMoney(needPay: Float) {
val sb = StringBuffer()
sb.append("¥").append(numFormat(needPay))
tvTypeMoney.text = sb.toString()
}
/**
* 设置是否显示红包
*/
private fun setRedPacketVisible() {
if (TextUtils.isEmpty(redPacketMoneyContent)) {
ll_redPacket.visibility = View.GONE
} else {
//如果 为 正常入口 且 有红包数额 那么说明 该订单 已锁定 就不能更改红包 故隐藏箭头
if (inlet == INLET_NORMAL) {
tvRedPacketMore.visibility = View.GONE
} else {
tvRedPacketMore.visibility = View.VISIBLE
}
ll_redPacket.visibility = View.VISIBLE
}
}
/**
* 设置支付按钮文本
*/
private fun setPayBtnText(text: String) {
rcb_pay.text = text
}
/**
* 请求账户余额接口
*/
@SuppressLint("CheckResult")
private fun requestMyBalance() {
HttpUtils.getMyBalance(BalanceParam())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doOnSubscribe { showProgressDialog() }
.doAfterTerminate { dismissProgressDialog() }
.subscribe(Consumer {
setData(it.data.balance)
LogHelper.getInstance().writeLogSync(
// "付款界面信息:金额 = " + payParams!!.needPay +
// ", id = " + payParams!!.payId +
// ", 类型 = " + payParams!!.title +
"余额 = " + it.data.balance
)
}, object : ThrowableConsumer() {
override fun accept(msg: String) {
ToastUtil.toastShort(msg)
}
})
}
/**
* 设置 是否显示付款保障文案
*/
private fun setPaymentVisible() {
when (inlet) {
INLET_NORMAL -> {
//正常入口
//设置是否显示付款保障
if (null != payParams && payParams!!.visibleIndemnity) {
tv_hint_title.visibility = View.VISIBLE
tv_hint_content.visibility = View.VISIBLE
}
}
INLET_TEST -> {
//测评入口
//设置是否显示付款保障
if (null != redPacketPayBean && redPacketPayBean!!.payParams.visibleIndemnity) {
tv_hint_title.visibility = View.VISIBLE
tv_hint_content.visibility = View.VISIBLE
}
}
}
}
/**
* 设置付款保障文案
*/
private fun setPaymentText() {
val globalInfo = PlatformDataManager.getRam().getGlobalInfo()
if (globalInfo != null) {
tv_hint_title.text = globalInfo.info.pay_notice.title
tv_hint_content.text = globalInfo.info.pay_notice.content.replace("<br>", "\n")
}
}
private var select = 0
private fun selectPayType(i: Int) {
if (select == i)
return
select = i
when (i) {
0 -> {
iv_wechat.setImageResource(R.drawable.pay_img_select)
iv_alipay.setImageResource(R.drawable.pay_img_no_select)
payType = PAY_WECHAT
}
1 -> {
iv_alipay.setImageResource(R.drawable.pay_img_select)
iv_wechat.setImageResource(R.drawable.pay_img_no_select)
payType = PAY_ALI
}
}
}
/**
* 设置余额
* @param balance 账户余额
*/
private fun setData(balance: Float) {
this.balanceMoney = balance
when (inlet) {
INLET_NORMAL -> {
//正常入口
if (null == payParams) {
return
}
//如果没有红包 并且 没有余额 那么隐藏掉这条线
if (0F == balance && TextUtils.isEmpty(redPacketMoneyContent)) {
v_redPacketAndBalance.visibility = View.GONE
} else {
v_redPacketAndBalance.visibility = View.VISIBLE
}
resetPayMoney()
}
INLET_TEST -> {
//测评入口
if (null == redPacketPayBean) {
return
}
resetPayMoney()
}
}
}
/**
* 重新计算 红包优惠 使用余额 还需支付
*/
private fun resetPayMoney() {
//设置红包文案
tvRedPacketMoney.text = redPacketMoneyContent
//如果 可使用的余额 大于 付款金额 - 红包金额
when (inlet) {
INLET_NORMAL -> {
//正常入口
//如果 有红包 说明 是待支付过来的
if (redPacketMoney > 0) {
calculation(payParams!!.needPay)
} else {
if (balanceMoney > payParams!!.needPay) {
//可使用余额 = 付款金额
canBalanceMoney = payParams!!.needPay
payMoney = 0F
ll_select_pay.visibility = View.GONE
} else {
canBalanceMoney = balanceMoney
payMoney = payParams!!.needPay - balanceMoney
ll_select_pay.visibility = View.VISIBLE
}
}
}
INLET_TEST -> {
//测评入口
calculation(redPacketPayBean?.payParams!!.needPay)
}
}
//如果没有可用余额 则隐藏
if (balanceMoney == 0f) {
ll_Balance.visibility = View.GONE
} else {
ll_Balance.visibility = View.VISIBLE
}
//设置 使用余额(可用¥X.XX)
val balanceBuffer = StringBuffer()
balanceBuffer.append("使用余额(可用¥").append(balanceMoney).append(")")
val balanceBuilder = SpannableStringBuilder(balanceBuffer.toString())
balanceBuilder.setSpan(
ForegroundColorSpan(resources.getColor(R.color.platform_color_999999)),
4,
balanceBuffer.toString().length,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
)
tvBalanceTitle.text = balanceBuilder
//设置 可用余额
val useBalanceBuffer = StringBuffer()
useBalanceBuffer.append("-¥").append(numFormat(canBalanceMoney))
tvUseBalance.text = useBalanceBuffer.toString()
//设置 还需支付
tvRestPay.text = numFormat(payMoney)
//如果没有可用余额 并且 没有红包 则隐藏还需支付
if (balanceMoney == 0F && (null == redPacketPayBean || null == redPacketPayBean!!.data || redPacketPayBean!!.data.isEmpty())) {
rl_RestPay.visibility = View.GONE
} else {
rl_RestPay.visibility = View.VISIBLE
}
//是否显示余额和红包之间 的间隔View
isVisibleBalanceTop()
//设置 底部支付按钮文案
val payBuffer = StringBuffer()
payBuffer.append("(¥").append(numFormat(payMoney)).append(")确认付款")
setPayBtnText(payBuffer.toString())
}
private fun isVisibleBalanceTop() {
if (ll_redPacket.visibility == View.GONE && ll_Balance.visibility == View.GONE) {
v_balanceTop.visibility = View.GONE
} else {
v_balanceTop.visibility = View.VISIBLE
}
}
/**
* 计算可使用余额
*/
private fun calculation(needPay: Float) {
when {
redPacketMoney >= needPay -> {
//如果红包金额 大于等于 付款金额
canBalanceMoney = 0F
payMoney = 0F
ll_select_pay.visibility = View.GONE
}
balanceMoney > needPay - redPacketMoney -> {
//可使用余额 = 付款金额 - 使用的红包金额
canBalanceMoney = needPay - redPacketMoney
payMoney = 0F
ll_select_pay.visibility = View.GONE
}
else -> {
canBalanceMoney = balanceMoney
payMoney = needPay - redPacketMoney - balanceMoney
ll_select_pay.visibility = View.VISIBLE
}
}
}
/**
* 显示红包弹窗
*/
private fun showRedPacketPopupWindow() {
if (null == redPacketPayBean || null == redPacketPayBean!!.data || redPacketPayBean!!.data.isEmpty()) {
return
}
if (null == redPacketPopWindow) {
redPacketPopWindow = RedPacketPopWindow(
PayActivity@ this,
redPacketPayBean!!.data,
object : RedPacketPopWindow.OnSelectListener {
override fun select(bean: RedPacketBean?) {
val sb = StringBuffer()
if (null == bean) {
sb.append(redPacketPayBean!!.data.size).append("个可用")
redPacketId = "0"
redPacketMoney = 0F
} else {
sb.append("-").append("¥").append(numFormat(bean.coupon_money!!))
redPacketId = bean.id
redPacketMoney = bean.coupon_money
}
redPacketMoneyContent = sb.toString()
resetPayMoney()
}
})
} else {
redPacketPopWindow!!.bindData()
}
redPacketPopWindow!!.showBottom(rcb_pay)
}
/**
* 格式化价格
*/
private fun numFormat(money: Float): String {
val decimalFormat = DecimalFormat("0.00")//构造方法的字符格式这里如果小数不足2位,会以0补足.
return decimalFormat.format(money)
}
/**
* 隐藏红包弹窗
*/
private fun hideRedPacketPopupWindow() {
if (null != redPacketPopWindow) {
redPacketPopWindow!!.dismiss()
}
}
/**
* 点击支付
*/
private fun onClickPay() {
when (inlet) {
INLET_NORMAL -> {
//正常入口
if (null == payParams) {
return
}
when (payParams!!.type) {
PayParams.RECHARGE -> {
//充值
recharge()
}
PayParams.PAY -> {
//付款
choicePayment()
}
}
}
INLET_TEST -> {
//测评入口
addOrder()
}
}
}
//选择支付方式
private fun choicePayment() {
//支付金额为0 说明都抵扣了或者订单金额为0 使用余额支付
if (payMoney == 0F) {
balancePay()
} else {
//使用微信 支付宝 支付
appPay()
}
}
//测评下单
private fun addOrder() {
// if (null == redPacketPayBean || null == redPacketPayBean!!.payParams) {
// return
// }
// YdlDataManager.getHttp().addOrder(AddOrderParam(redPacketPayBean!!.payParams.payId, redPacketId!!))
// .compose(RxUtils.resultData())
// .observeOn(AndroidSchedulers.mainThread())
// .doOnSubscribe { showProgressDialog() }
// .doAfterTerminate { dismissProgressDialog() }
// .subscribe(Consumer {
// testAddOrderBean = it
// LogHelper.getInstance().writeLogSync("测评下单成功")
// choicePayment()
// }, object : ThrowableConsumer() {
// override fun accept(msg: String) {
// ToastUtil.toastShort(msg)
// LogHelper.getInstance().writeLogSync("测评下单失败:$msg")
// }
// })
}
var rechargeId: String? = null
// 充值
@SuppressLint("CheckResult")
private fun recharge() {
if (null == payParams) {
return
}
HttpUtils.recharge(RechargeParam(payParams!!.needPay.toInt().toString()))
.subscribeOn(Schedulers.io())
.flatMap {
rechargeId = it.data.rechargeId
when (select) {
0 ->
HttpUtils.wxRecharge(WXRechargeIdParam(it.data.rechargeId))
.compose(RxUtils.resultData())
.observeOn(AndroidSchedulers.mainThread())
.doOnNext { dismissProgressDialog() }
.flatMap { RxPay.wxPay(this, it.option) }
else -> RxPay.aliPay(this, it.data.aliSign)
}
}
.observeOn(AndroidSchedulers.mainThread())
.doOnSubscribe { showProgressDialog("") }
.doAfterTerminate { dismissProgressDialog() }
.subscribe(Consumer {
LogHelper.getInstance().writeLogSync("支付成功")
ToastUtil.toastShort("支付成功")
var intent = Intent()
intent.putExtra("rechargeId", rechargeId)
setResult(Activity.RESULT_OK, intent)
finish()
}, object : ThrowableConsumer() {
override fun accept(msg: String) {
ToastUtil.toastShort(msg)
LogHelper.getInstance().writeLogSync("支付失败$msg")
}
})
}
// 余额支付
private fun balancePay() {
when (inlet) {
INLET_NORMAL -> {
//正常入口
balancePayById(payParams!!.payId)
}
INLET_TEST -> {
//测评入口
balancePayById(testAddOrderBean!!.payId!!)
}
else -> {
balancePayById(payParams!!.payId)
}
}
}
/**
* 余额支付
* @param payId 支付Id
*/
@SuppressLint("CheckResult")
private fun balancePayById(payId: String) {
var bean = ChargePayParam()
bean.payId = payId
HttpUtils.payByCharge(bean)
.compose(RxUtils.resultData())
.observeOn(AndroidSchedulers.mainThread())
.doOnSubscribe { showProgressDialog() }
.doAfterTerminate { dismissProgressDialog() }
.subscribe(Consumer {
LogHelper.getInstance().writeLogSync("支付成功")
ToastUtil.toastShort("支付成功")
setResult(Activity.RESULT_OK)
finish()
}, object : ThrowableConsumer() {
override fun accept(msg: String) {
ToastUtil.toastShort(msg)
LogHelper.getInstance().writeLogSync("支付失败:$msg")
}
})
}
/**
* app 支付,微信或支付宝
*/
@SuppressLint("CheckResult")
private fun appPay() {
Observable.just(select)
.subscribeOn(Schedulers.io())
.flatMap {
when (it) {
0 -> {
wxPay()
}
else -> {
aliPay()
}
}
}
.observeOn(AndroidSchedulers.mainThread())
.doOnSubscribe { showProgressDialog("") }
.doAfterTerminate { dismissProgressDialog() }
.subscribe(Consumer {
LogHelper.getInstance().writeLogSync("支付成功")
setResult(Activity.RESULT_OK)
finish()
}, object : ThrowableConsumer() {
override fun accept(msg: String) {
ToastUtil.toastShort(msg)
LogHelper.getInstance().writeLogSync("支付失败:$msg")
}
})
}
/**
* 微信支付
*/
private fun wxPay(): Observable<PayStatus>? {
return when (inlet) {
INLET_NORMAL -> {
//正常入口
wxPayById(payParams!!.payId)
}
INLET_TEST -> {
//测评入口
if (null != testAddOrderBean && !TextUtils.isEmpty(testAddOrderBean!!.payId!!)) {
wxPayById(testAddOrderBean!!.payId!!)
} else {
null
}
}
else -> {
wxPayById(payParams!!.payId)
}
}
}
/**
* 微信支付
* @param payId 支付id
*/
private fun wxPayById(payId: String): Observable<PayStatus> {
val bean = WxPayParam(payId, 1)
return HttpUtils.wxPay(bean)
.compose(RxUtils.resultData())
.observeOn(AndroidSchedulers.mainThread())
.doOnNext { dismissProgressDialog() }
.flatMap { RxPay.wxPay(this, it.option) }
}
/**
* 支付宝支付
*/
private fun aliPay(): Observable<PayStatus>? {
return when (inlet) {
INLET_NORMAL -> {
//正常入口
aliPayById(payParams!!.payId)
}
INLET_TEST -> {
//测评入口
if (null != testAddOrderBean && !TextUtils.isEmpty(testAddOrderBean!!.payId!!)) {
aliPayById(testAddOrderBean!!.payId!!)
} else {
null
}
}
else -> {
aliPayById(payParams!!.payId)
}
}
}
/**
* 支付宝支付
* @param payId 支付Id
*/
private fun aliPayById(payId: String): Observable<PayStatus> {
var bean = AliPayParam(payId, 1)
return HttpUtils.getAliPayOrderId(bean)
.compose(RxUtils.resultData())
.flatMap {
when (inlet) {
INLET_NORMAL -> {
RxPay.aliPay(this, it.aliSign)
}
INLET_TEST -> {
RxPay.aliPay(this, it.aliSign)
}
else -> {
RxPay.aliPay(this, it.aliSign)
}
}
}
}
/**
* 显示加载中弹窗
*/
override fun showProgressDialog(str: String?) {
if (dialog != null && dialog!!.isShowing) {
return
}
if (dialog == null) {
dialog = AlertDialog.Builder(PayActivity@ this)
.create()
}
if (dialogContentView == null) {
dialogContentView = LayoutInflater.from(this).inflate(R.layout.pay_fragment_loading_dialog, null)
dialogContentView?.tvMsg?.visibility = View.GONE
}
dialog?.show()
dialog?.window?.setContentView(dialogContentView)
dialog?.window?.setGravity(Gravity.CENTER)
val p = dialog?.window!!.attributes //获取对话框当前的参数值
var point = Point()
windowManager.defaultDisplay.getSize(point)// 获取屏幕宽、高用
p.height = (point.y * 0.2).toInt()
p.width = (point.x * 0.35).toInt()
dialog?.window!!.attributes = p //设置生效
}
/**
* 隐藏加载中弹窗
*/
override fun dismissProgressDialog() {
if (dialog != null && dialog!!.isShowing) {
dialog!!.dismiss()
}
}
override fun onDestroy() {
super.onDestroy()
hideRedPacketPopupWindow()
}
}
package com.yidianling.ydl_pay.pay
import android.os.Parcel
import android.os.Parcelable
/**
* author : Zhangwenchao
* e-mail : zhangwch@yidianling.com
* time : 2018/04/24
* update : yuanWai 2018/10/29
*/
data class PayParams(
var inlet : Int = INLET_NORMAL,
/**
* 类型 1 -> 充值,2 -> 付款
*/
var type: Int = PAY,
/**
* 类型标题
*/
var title: String = "",
/**
* 是否显示付款保障
*/
var visibleIndemnity: Boolean = false,
/**
* 支付按钮显示的文本
*/
var btnPayText: String = "确认",
/**
* 需要支付的金额
*/
var needPay: Float = 0F,
/**
* 订单id(如果是测评入口的话 就是测试题Id)
*/
var payId: String = "",
/**
* 已使用的红包金额(代付款列表入口 使用)
*/
var coupon_money: Float = 0F
) : Parcelable {
constructor(parcel: Parcel) : this(
parcel.readInt(),
parcel.readInt(),
parcel.readString(),
parcel.readByte() != 0.toByte(),
parcel.readString(),
parcel.readFloat(),
parcel.readString(),
parcel.readFloat())
override fun writeToParcel(parcel: Parcel, flags: Int) {
parcel.writeInt(inlet)
parcel.writeInt(type)
parcel.writeString(title)
parcel.writeByte(if (visibleIndemnity) 1 else 0)
parcel.writeString(btnPayText)
parcel.writeFloat(needPay)
parcel.writeString(payId)
parcel.writeFloat(coupon_money)
}
override fun describeContents(): Int {
return 0
}
companion object CREATOR : Parcelable.Creator<PayParams> {
/**
* 1.充值 2.付款
*/
const val RECHARGE = 1
const val PAY = 2
/**
* 入口类型
* 1.正常入口(默认) 2.测评入口
*/
const val INLET_NORMAL = 1
const val INLET_TEST = 2
override fun createFromParcel(parcel: Parcel): PayParams {
return PayParams(parcel)
}
override fun newArray(size: Int): Array<PayParams?> {
return arrayOfNulls(size)
}
}
}
\ No newline at end of file
package com.yidianling.ydl_pay.pay
import io.reactivex.Observable
import io.reactivex.subjects.PublishSubject
import io.reactivex.subjects.Subject
/**
* author : Zhangwenchao
* e-mail : zhangwch@yidianling.com
* time : 2018/04/18
*/
class RxBus private constructor(){
companion object {
fun getInstance(): RxBus {
return Holder.INSTANCE
}
}
private val mBus: Subject<Any>
init {
mBus = PublishSubject.create()
}
fun <T>toObservable(tClass: Class<T>): Observable<T> {
return mBus.ofType(tClass)
}
fun post(any: Any) {
mBus.onNext(any)
}
private object Holder {
val INSTANCE = RxBus()
}
}
\ No newline at end of file
package com.yidianling.ydl_pay.pay
import android.app.Activity
import android.content.Context
import com.alipay.sdk.app.PayTask
import com.yidianling.ydl_pay.pay.bean.PayStatus
import com.tencent.mm.opensdk.constants.Build
import com.tencent.mm.opensdk.modelpay.PayReq
import com.tencent.mm.opensdk.openapi.WXAPIFactory
import com.yidianling.ydl_pay.pay.bean.WXPayEvent
import com.ydl.ydlcommon.data.http.CustomThrowable
import com.yidianling.ydl_pay.common.bean.PayResult
import de.greenrobot.event.EventBus
import io.reactivex.Emitter
import io.reactivex.Observable
import io.reactivex.schedulers.Schedulers
/**
* author : Zhangwenchao
* e-mail : zhangwch@yidianling.com
* time : 2018/04/18
*/
object RxPay {
init {
EventBus.getDefault().register(this)
}
private var emitter: Emitter<PayStatus>? = null
// 微信支付
fun wxPay(context: Context, option: WXPay.WXOption): Observable<PayStatus> {
return Observable.create<PayStatus> { e ->
val api = WXAPIFactory.createWXAPI(context, null)
if (api.wxAppSupportAPI < Build.PAY_SUPPORTED_SDK_INT) {
e.onError(CustomThrowable("目前您的微信版本过低或未安装微信,需要安装微信才能使用"))
e.onComplete()
}
emitter = e
api.registerApp(option.appid)
val request = PayReq()
request.appId = option.appid
request.partnerId = option.partnerid
request.prepayId = option.prepayid
request.packageValue = "Sign=WXPay"
request.nonceStr = option.noncestr
request.timeStamp = option.timestamp
request.sign = option.sign
api.sendReq(request)
}.subscribeOn(Schedulers.io())
}
// 支付宝支付
fun aliPay(activity: Activity, aliSign: String): Observable<PayStatus> {
return Observable.create<PayStatus> {
val alipay = PayTask(activity)
val result = alipay.payV2(aliSign, true)
val payResult = PayResult(result)
when {
"9000" == payResult.resultStatus -> it.onNext(PayStatus(true))
else -> it.onError(CustomThrowable(payResult.memo))
}
it.onComplete()
}
}
fun onEvent(event: WXPayEvent) {
if (event.status.success) {
emitter?.onNext(event.status)
} else {
emitter?.onError(Throwable("支付失败", null))
}
emitter?.onComplete()
}
}
\ No newline at end of file
package com.yidianling.ydl_pay.pay.bean
data class AliInfo(val alipayPartner: String,
val alipayKey: String,
val alipaySellerEmail: String,
val alipayNotifyUrl: String,
val alirsakey: String)
\ No newline at end of file
package com.yidianling.ydl_pay.pay.bean
/**
* author : Zhangwenchao
* e-mail : zhangwch@yidianling.com
* time : 2018/04/20
*/
open class PayParam(payId: String, val type: String) {
data class WxPayParam(val payId: String) : PayParam(payId, "wxapp_hz")
data class AliPayParam(val payId: String) : PayParam(payId, "aliapp")
}
\ No newline at end of file
package com.yidianling.ydl_pay.pay.bean
import android.support.annotation.Keep
/**
* author : Zhangwenchao
* e-mail : zhangwch@yidianling.com
* time : 2018/04/18
*
* 支付状态
*/
@Keep
data class PayStatus(val success: Boolean)
\ No newline at end of file
package com.yidianling.ydl_pay.pay.bean
import android.support.annotation.Keep
/**
* author : Zhangwenchao
* e-mail : zhangwch@yidianling.com
* time : 2018/04/19
*/
@Keep
data class RechargeBean(val rechargeId: String,
/**
* 支付金额
*/
val money : String,
val aliInfo: AliInfo,
/**
* 支付宝 加签
*/
val aliSign : String)
\ No newline at end of file
package com.yidianling.ydl_pay.pay.bean;
import com.ydl.ydlcommon.data.http.BaseCommand;
/**
* @author jiucheng
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2020/2/6
*/
public class RechargeParam extends BaseCommand {
public String money;
public RechargeParam(String money) {
this.money = money;
}
}
package com.yidianling.ydl_pay.pay.bean
/**
* @author yuanWai
* @描述:测评下单接口 数据接收bean
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/10/26
*/
data class TestAddOrderBean(
/**
* 支付ID
*/
val payId : String?,
/**
* 订单ID
*/
val orderId : String?,
/**
* 需支付金额
*/
val money : String?,
/**
* 商品名称
*/
val title : String?,
/**
* 用户 ID
*/
val uid : String?,
/**
* 支付成功跳转链接
*/
val succ : String?)
\ No newline at end of file
package com.yidianling.ydl_pay.pay.bean
/**
* @author : Zhangwenchao
* @e-mail : zhangwch@yidianling.com
* @time : 2018/6/4
*/
data class WXPayEvent(val status: PayStatus)
\ No newline at end of file
package com.yidianling.ydl_pay.pay.bean;
import com.ydl.ydlcommon.data.http.BaseCommand;
/**
* @author jiucheng
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2020/2/6
*/
public class WXRechargeIdParam extends BaseCommand {
public String rechargeId;
public WXRechargeIdParam(String rechargeId) {
this.rechargeId = rechargeId;
}
}
package com.yidianling.ydl_pay.pay.payDialog
/**
* 倾诉支付参数
*/
class ConfidePayParams{
var payTitle : String? = null
//订单金额
var orderPrice : Double? = null
//优惠金额
var coupnPrice : Double? = null
//可用余额
var avliableMoney : Double? = null
//支付id
var payId : String? = null
//支付成功跳转地址
var confideUrl : String? = null
constructor(payTitle: String?, orderPrice: Double?, coupnPrice: Double?, avliableMoney: Double?, payId: String?, confideUrl: String?) {
this.payTitle = payTitle
this.orderPrice = orderPrice
this.coupnPrice = coupnPrice
this.avliableMoney = avliableMoney
this.payId = payId
this.confideUrl = confideUrl
}
}
\ No newline at end of file
package com.yidianling.ydl_pay.pay.payDialog
import android.annotation.SuppressLint
import android.app.Activity
import android.app.Dialog
import android.graphics.Point
import android.os.Bundle
import android.support.v7.app.AlertDialog
import android.view.*
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.utils.StringUtils
import com.ydl.ydlcommon.utils.log.LogHelper
import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.yidianling.ydl_pay.R
import com.yidianling.ydl_pay.common.bean.params.AliPayParam
import com.yidianling.ydl_pay.common.bean.params.WxPayParam
import com.yidianling.ydl_pay.common.http.HttpUtils
import com.yidianling.ydl_pay.pay.RxPay
import com.yidianling.ydl_pay.pay.bean.PayStatus
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.pay_dialog_pay.*
import kotlinx.android.synthetic.main.pay_fragment_loading_dialog.view.*
import java.util.concurrent.TimeUnit
import kotlin.properties.Delegates
@SuppressLint("ValidFragment")
//新的支付弹窗
class PayDialog : Dialog {
//回调函数
private var callBack: CallBack? = null
/**
* 支付类型
* 1.微信支付 2.支付宝支付
*/
private val PAY_WECHAT = 1
private val PAY_ALI = 2
//加载中弹窗
private var dialog: AlertDialog? = null
private var dialogContentView: View? = null
/**
* 已选择支付方式
*/
private var payType = PAY_WECHAT
private var data: ConfidePayParams? = null
private var activity: Activity by Delegates.notNull()
constructor(context: Activity) : super(context) {
this.activity = context
}
override fun onStart() {
super.onStart()
//设置 dialog 的宽高
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
//设置 dialog 的背景为 null
window.setBackgroundDrawable(null)
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
//去除标题栏
requestWindowFeature(Window.FEATURE_NO_TITLE)
val lp = window.attributes
lp.gravity = Gravity.BOTTOM //底部
lp.width = WindowManager.LayoutParams.MATCH_PARENT
// lp.windowAnimations = R.style.BottomDialogAnimation
window.attributes = lp
setContentView(R.layout.pay_dialog_pay)
initView()
if (data != null) {
text_title.text = data!!.payTitle ?: "倾诉服务"
setFoodPrice("¥${StringUtils.save2Double(data?.orderPrice ?: 0.00)}")
setSaleText("-¥${StringUtils.save2Double(data?.coupnPrice ?: 0.00)}")
setAvliableMoney("-¥${StringUtils.save2Double(data?.avliableMoney ?: 0.00)}")
setPayMoney()
}
}
fun initView() {
//确定支付
text_pay.setOnClickListener {
appPay()
}
//切换支付方式
ll_wechat.setOnClickListener {
payType = PAY_WECHAT
iv_wechat.setImageResource(R.drawable.pay_img_select)
iv_alipay.setImageResource(R.drawable.pay_img_no_select)
}
ll_alipay.setOnClickListener {
payType = PAY_ALI
iv_wechat.setImageResource(R.drawable.pay_img_no_select)
iv_alipay.setImageResource(R.drawable.pay_img_select)
}
}
//设置回调函数
fun setCallback(callBack: CallBack): PayDialog {
this.callBack = callBack
return this
}
//设置数据
fun show(data: ConfidePayParams?) {
this.data = data
show()
}
//设置三方支付是否显示
fun setOtherPayVisibity(visibity: Int) {
text_paytip.visibility = visibity
lin_pay.visibility = visibity
}
//设置商品价格
fun setFoodPrice(moeny: String) {
text_oldmoney.text = moeny
}
//设置可用余额
fun setAvliableMoney(moeny: String) {
text_yu_e.text = moeny
}
//设置优惠信息
fun setSaleText(money: String) {
text_youhui.text = money
}
//设置应支付金额
fun setPayMoney() {
if (data != null && data!!.orderPrice != null && data!!.coupnPrice != null && data!!.avliableMoney != null) {
var price: Double = data!!.orderPrice!! - data!!.coupnPrice!! - data!!.avliableMoney!!
if (price < 0.00) {
price = 0.00
}
text_money.text = "¥${StringUtils.save2Double(price)}"
} else {
text_money.text = "--"
}
}
/**
* app 支付,微信或支付宝
*/
@SuppressLint("CheckResult")
private fun appPay() {
if (data?.payId == null) {
ToastHelper.show("支付id有误,请返回重试")
return
}
Observable.just(payType)
.subscribeOn(Schedulers.io())
.flatMap {
when (it) {
0, 1 -> {
wxPayById(data?.payId!!)
}
else -> {
aliPayById(data?.payId!!)
}
}
}
.observeOn(AndroidSchedulers.mainThread())
.doOnSubscribe { showProgressDialog("") }
.doAfterTerminate { if (!activity.isFinishing) dismissProgressDialog() }
.subscribe({
//防止支付后支付端和服务端通知同步延迟 , 1.5秒后回调callback
Observable.timer(1500, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
if (activity != null && !activity.isFinishing) dismissProgressDialog()
this.callBack?.onSuccess()
}
LogHelper.getInstance().writeLogSync("支付成功")
this.callBack?.onSuccess()
dismiss()
}, {
ToastHelper.show(it.message ?: "支付失败")
LogHelper.getInstance().writeLogSync("支付失败:${it.message}")
})
}
/**
* 微信支付
* @param payId 支付id
*/
private fun wxPayById(payId: String): Observable<PayStatus> {
val bean = WxPayParam(payId, 1)
return HttpUtils.wxPay(bean)
.compose(RxUtils.resultData())
.observeOn(AndroidSchedulers.mainThread())
.flatMap { RxPay.wxPay(activity, it.option) }
}
/**
* 支付宝支付
* @param payId 支付Id
*/
private fun aliPayById(payId: String): Observable<PayStatus> {
var bean = AliPayParam(payId, 1)
return HttpUtils.getAliPayOrderId(bean)
.compose(RxUtils.resultData())
.flatMap {
RxPay.aliPay(activity, it.aliSign)
}
}
/**
* 显示加载中弹窗
*/
private fun showProgressDialog(str: String?) {
if (activity == null || activity.isFinishing) {
return
}
if (dialog != null && dialog!!.isShowing) {
return
}
if (dialog == null) {
dialog = AlertDialog.Builder(activity)
.create()
}
if (dialogContentView == null) {
dialogContentView = LayoutInflater.from(activity).inflate(R.layout.pay_fragment_loading_dialog, null)
dialogContentView?.tvMsg?.visibility = View.GONE
}
dialog?.show()
dialog?.window?.setContentView(dialogContentView)
dialog?.window?.setGravity(Gravity.CENTER)
val p = dialog?.window!!.attributes //获取对话框当前的参数值
var point = Point()
activity.windowManager.defaultDisplay.getSize(point)// 获取屏幕宽、高用
p.height = (point.y * 0.2).toInt()
p.width = (point.x * 0.35).toInt()
dialog?.window!!.attributes = p //设置生效
}
/**
* 隐藏加载中弹窗
*/
private fun dismissProgressDialog() {
if (dialog != null && dialog!!.isShowing) {
dialog!!.dismiss()
}
}
}
/**
* 支付成功回调函数
*/
interface CallBack {
fun onSuccess()
fun onError()
}
\ No newline at end of file
package com.yidianling.ydl_pay.pay.redpacket
import android.os.Parcel
import android.os.Parcelable
/**
* @author yuanwai
* @描述:红包数据bean
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/10/23
*/
data class RedPacketBean(
/**
* 红包 ID
*/
val id : String? = "",
/**
* 红包金额
*/
val coupon_money : Float? = 0F,
/**
* 用户 ID
*/
val uid : String? = "",
/**
* 红包标题
*/
val title : String? = "",
/**
* 红包说明
*/
val explain : String? = "",
/**
* 使用类型 1永久使用 2 有效期内使用
*/
val use_type : Int? = 2,
/**
* 是否选中
*/
val selected : Boolean? = false,
/**
* 截止日期
*/
val use_time_end : String? = ""): Parcelable {
constructor(parcel: Parcel) : this(
parcel.readString(),
parcel.readFloat(),
parcel.readString(),
parcel.readString(),
parcel.readString(),
parcel.readInt(),
parcel.readByte() != 0.toByte(),
parcel.readString()) {
}
override fun writeToParcel(parcel: Parcel, flags: Int) {
parcel.writeString(id)
parcel.writeFloat(coupon_money!!)
parcel.writeString(uid)
parcel.writeString(title)
parcel.writeString(explain)
parcel.writeInt(use_type!!)
parcel.writeByte(if (selected!!) 1 else 0)
parcel.writeString(use_time_end)
}
override fun describeContents(): Int {
return 0
}
companion object CREATOR : Parcelable.Creator<RedPacketBean> {
override fun createFromParcel(parcel: Parcel): RedPacketBean {
return RedPacketBean(parcel)
}
override fun newArray(size: Int): Array<RedPacketBean?> {
return arrayOfNulls(size)
}
}
}
\ No newline at end of file
package com.yidianling.ydl_pay.pay.redpacket
/**
* @author yuanWai
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/10/25
*/
data class RedPacketParam(val p : String)
\ No newline at end of file
package com.yidianling.ydl_pay.pay.redpacket
import android.os.Parcel
import android.os.Parcelable
import com.yidianling.ydl_pay.pay.PayParams
/**
* @author yuanWai
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/10/25
*/
data class RedPacketPayBean(val payParams: PayParams,
val data: ArrayList<RedPacketBean>): Parcelable {
constructor(parcel: Parcel) : this(
parcel.readParcelable(PayParams::class.java.classLoader),
parcel.createTypedArrayList(RedPacketBean.CREATOR)) {
}
override fun writeToParcel(parcel: Parcel, flags: Int) {
parcel.writeParcelable(payParams, flags)
parcel.writeTypedList(data)
}
override fun describeContents(): Int {
return 0
}
companion object CREATOR : Parcelable.Creator<RedPacketPayBean> {
override fun createFromParcel(parcel: Parcel): RedPacketPayBean {
return RedPacketPayBean(parcel)
}
override fun newArray(size: Int): Array<RedPacketPayBean?> {
return arrayOfNulls(size)
}
}
}
\ No newline at end of file
package com.yidianling.ydl_pay.pay.redpacket
import android.annotation.SuppressLint
import android.app.Activity
import android.graphics.drawable.BitmapDrawable
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.RelativeLayout
import com.ydl.ydlcommon.utils.Utils
import com.yidianling.common.tools.RxImageTool
import com.yidianling.common.view.popupwindow.BasePopupWindow
import com.yidianling.ydl_pay.R
@Suppress("DEPRECATION")
/**
* @author yuanWai
* @描述:红包弹窗
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/10/23
*/
class RedPacketPopWindow : BasePopupWindow {
//红包集合
var list : ArrayList<RedPacketBean>? = null
//选中红包监听器
var listener : OnSelectListener? = null
//选中的索引
private var selectIndex : Int = 0
constructor(mActivity: Activity, dataList : ArrayList<RedPacketBean>?, onSelectListener: OnSelectListener) : super(mActivity){
if (null == list){
list = ArrayList()
}else{
list!!.clear()
}
if (dataList != null) {
list!!.addAll(dataList)
}
initPopupwindow()
this.listener = onSelectListener
}
@SuppressLint("InflateParams")
override fun initPopupwindow() {
super.initPopupwindow()
mView = LayoutInflater.from(mContext).inflate(R.layout.pay_redpacket_pop_layout, null, false)
popupWindow!!.width = ViewGroup.LayoutParams.MATCH_PARENT
popupWindow!!.height = (Utils.getScreenHeight(mContext) * 0.66).toInt()
popupWindow!!.setBackgroundDrawable(BitmapDrawable())
popupWindow!!.setOnDismissListener(this)
popupWindow!!.contentView = mView
//创建view
createView(mView!!)
//填充数据
bindData()
mView?.findViewById<RelativeLayout>(R.id.rl_notUse)?.setOnClickListener {
selectRedPacket(null,-1)
}
}
/**
* 根据数据创建红包View
* 如果原有的view少于数据的个数 那就add
* 如果原有的view大于数据的个数 那就remove
*/
private fun createView(view : View){
val llContent = view.findViewById<LinearLayout>(R.id.ll_content)
if (llContent.childCount - 1 < list!!.size){
//如果数据源个数大于view个数 则add
for (index in 0 until list!!.size){
val marginTop = if (index == 0){
RxImageTool.dip2px(20f)
}else{
0
}
if (index+1 > llContent.childCount - 1){
val redPacketView = RedPacketView(mContext!!,marginTop)
llContent.addView(redPacketView)
}
}
}else{
//如果数据源个数小于view个数 则remove
val count = llContent.childCount - 1 - list!!.size
if (count == 0){
return
}
val end = llContent.childCount - 1 - count
val start = llContent.childCount - 1 - 1
for (index in start..end){
llContent.removeViewAt(index)
}
}
}
/**
* 根据现有的view个数进行数据填充
*/
fun bindData(){
if (selectIndex == -1){
mView!!.findViewById<ImageView>(R.id.imgCheck).visibility = View.VISIBLE
}else{
mView!!.findViewById<ImageView>(R.id.imgCheck).visibility = View.INVISIBLE
}
val llContent = mView!!.findViewById<LinearLayout>(R.id.ll_content)
for (index in 0 until list!!.size){
val redPacketView = llContent.getChildAt(index + 1)
if (redPacketView is RedPacketView){
redPacketView.initData(list!![index],index,object : RedPacketView.ICheckedListener {
override fun checked(bean: RedPacketBean, position : Int) {
selectRedPacket(bean,position)
}
})
redPacketView.checked(selectIndex == index)
}
}
}
/**
* 选择红包
* @param bean 红包数据 如果为null 就是不使用红包
* @param position 选择红包的索引
*/
private fun selectRedPacket(bean: RedPacketBean?, position : Int){
listener?.select(bean)
selectIndex = position
dismiss()
}
interface OnSelectListener {
//选中的红包
fun select(bean: RedPacketBean?)
}
}
\ No newline at end of file
package com.yidianling.ydl_pay.pay.redpacket
import android.annotation.SuppressLint
import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.RelativeLayout
import com.yidianling.common.tools.RxImageTool
import com.yidianling.ydl_pay.R
import kotlinx.android.synthetic.main.pay_redpacket_view.view.*
/**
* @author yuanWai
* @描述:红包View
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/10/24
*/
class RedPacketView : RelativeLayout{
private var listener : ICheckedListener? = null
constructor(mContext : Context):super(mContext){
initView(0)
}
constructor(mContext : Context,marginTop : Int):super(mContext){
initView(marginTop)
}
constructor(mContext : Context, attrs : AttributeSet) : super(mContext,attrs){
initView(0)
}
constructor(mContext: Context,attrs : AttributeSet,defStyleAttr : Int) : super(mContext,attrs,defStyleAttr){
initView(0)
}
private fun initView(marginTop : Int){
View.inflate(context, R.layout.pay_redpacket_view,this)
var params = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,RxImageTool.dip2px(90f))
val dp15 = RxImageTool.dip2px(15f)
params.setMargins(dp15,marginTop,dp15,RxImageTool.dip2px(20f))
layoutParams = params
setBackgroundResource(R.drawable.pay_redpacket_item_bg)
}
@SuppressLint("SimpleDateFormat")
fun initData(data : RedPacketBean?, position: Int, listener : ICheckedListener){
this.listener = listener
if (null == data){
visibility = View.GONE
return
}
visibility = View.VISIBLE
val sb = StringBuffer()
// val nf = NumberFormat.getInstance()
sb.append("¥").append(if (null == data.coupon_money) 0 else data.coupon_money.toInt())
//红包说明
tv_title.text = data.title
//截止日期
val timeBuffer = StringBuffer()
if (1 == data.use_type){
//永久使用
timeBuffer.append("永久有效")
}else{
//有效期内使用
timeBuffer.append("有效期至").append(data.use_time_end)
}
tvTimeEnd.text = timeBuffer.toString()
//红包金额
tvMoney.text = sb.toString()
//选择红包监听
setOnClickListener {
if (null != this.listener){
this.listener!!.checked(data,position)
}
}
}
fun checked(isChecked: Boolean){
if (isChecked){
imgCheck.visibility = View.VISIBLE
}else{
imgCheck.visibility = View.GONE
}
}
interface ICheckedListener{
fun checked(bean : RedPacketBean, position : Int)
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:topRightRadius="10dp" android:topLeftRadius="10dp" />
<solid android:color="@color/white" />
<stroke
android:width="1dp"
android:color="@color/white" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle" >
<stroke
android:width="0.5dp"
android:color="#F0F0F0" />
</shape>
</item>
<item
android:bottom="1dp"
android:right="1dp"
android:top="1dp">
<!-- 在实际使用中我发现1dp达不到显示效果,而2dp正好可以显示边框 -->
<shape android:shape="rectangle" >
<solid android:color="@color/white" />
</shape>
</item>
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="6dp"/>
<stroke android:color="#F0F0F0" android:width="0.5dp"/>
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.ydl.ydlcommon.view.TitleBar
android:id="@+id/title_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/title_bar_height"
android:background="@color/white"
app:pa_left_start_icon="@drawable/platform_common_back"
app:pa_title_text="付款"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="45dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!--类型+付款金额-->
<LinearLayout
android:id="@+id/ll_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="horizontal">
<TextView
android:id="@+id/tvType"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_marginBottom="11.5dp"
android:layout_marginStart="15dp"
android:layout_marginTop="28dp"
android:layout_weight="1"
android:textColor="@color/platform_color_333333"
android:textSize="15dp"
android:textStyle="bold"
tools:text="心理测试"/>
<TextView
android:id="@+id/tvTypeMoney"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_marginBottom="11.5dp"
android:layout_marginEnd="20dp"
android:layout_marginTop="28dp"
android:layout_weight="1"
android:gravity="right"
android:textColor="@color/platform_color_333333"
android:textSize="15dp"
tools:ignore="RtlHardcoded"
tools:text="¥39.00"/>
</LinearLayout>
<View
android:id="@+id/first_line"
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginStart="15dp"
android:background="@color/platform_color_E0E0E0"
tools:ignore="RtlSymmetry"/>
<!--红包优惠-->
<LinearLayout
android:id="@+id/ll_redPacket"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="horizontal"
android:paddingTop="16dp">
<TextView
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:layout_weight="1"
android:text="红包优惠"
android:textColor="@color/platform_color_333333"
android:textSize="14dp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_marginEnd="20dp"
android:orientation="horizontal">
<TextView
android:id="@+id/tvRedPacketMoney"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:gravity="center_vertical"
android:textColor="@color/platform_color_FF4650"
android:textSize="14dp"
tools:ignore="RtlHardcoded"
tools:text="-¥3.00"/>
<ImageView
android:id="@+id/tvRedPacketMore"
android:layout_width="6dp"
android:layout_height="10dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="4dp"
android:layout_marginTop="1.5dp"
android:background="@drawable/pay_redpacket_more"/>
</LinearLayout>
</LinearLayout>
<View
android:id="@+id/v_balanceTop"
android:layout_width="match_parent"
android:layout_height="16dp"
android:background="@color/white"/>
<!--使用余额-->
<LinearLayout
android:id="@+id/ll_Balance"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="horizontal">
<TextView
android:id="@+id/tvBalanceTitle"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginStart="15dp"
android:layout_weight="1"
android:textColor="@color/platform_color_333333"
android:textSize="14dp"
tools:text="使用余额(可用¥100.00)"/>
<TextView
android:id="@+id/tvUseBalance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginEnd="20dp"
android:gravity="center_vertical"
android:textColor="@color/platform_color_333333"
android:textSize="14dp"
tools:ignore="RtlHardcoded"
tools:text="-¥36.00"/>
</LinearLayout>
<View
android:id="@+id/v_redPacketAndBalance"
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginStart="15dp"
android:background="@color/platform_color_E0E0E0"/>
<!--还需支付-->
<RelativeLayout
android:id="@+id/rl_RestPay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:background="@color/white">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="59.5dp"
android:layout_alignParentEnd="true"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="还需支付"
android:textColor="@color/platform_color_333333"
android:textSize="14dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="20dp"
android:text="¥"
android:textColor="@color/platform_color_333333"
android:textSize="16dp"
android:textStyle="bold"/>
<TextView
android:id="@+id/tvRestPay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="20dp"
android:layout_marginStart="2dp"
android:textColor="@color/platform_color_333333"
android:textSize="24sp"
android:textStyle="bold"
tools:text="34.00"/>
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id="@+id/ll_select_pay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/platform_color_F6F6F6"
android:orientation="vertical"
android:visibility="gone">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="15dp"
android:layout_marginTop="15dp"
android:text="请选择支付方式"
android:textColor="@color/platform_color_666666"
android:textSize="12sp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical">
<LinearLayout
android:id="@+id/ll_wechat"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:src="@drawable/pay_wechat_for_pay"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="微信支付"
android:textColor="@color/platform_color_333333"
android:textSize="14dp"/>
<ImageView
android:id="@+id/iv_wechat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:src="@drawable/pay_img_select"/>
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="@dimen/divide_line_stroke_width"
android:background="#EDEDED"/>
<LinearLayout
android:id="@+id/ll_alipay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:src="@drawable/pay_zhifubao_for_pay"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="支付宝支付"
android:textColor="@color/platform_color_333333"
android:textSize="14dp"/>
<ImageView
android:id="@+id/iv_alipay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:src="@drawable/pay_img_no_select"/>
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="@dimen/divide_line_stroke_width"
android:background="#EDEDED"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/platform_color_F6F6F6"
android:orientation="vertical"
android:visibility="visible">
<TextView
android:id="@+id/tv_hint_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:lineSpacingMultiplier="1.5"
android:paddingLeft="15dp"
android:paddingTop="25dp"
android:textColor="#999999"
android:textSize="14sp"
android:visibility="gone"
tools:text="付款保障"/>
<TextView
android:id="@+id/tv_hint_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="25dp"
android:lineSpacingMultiplier="1.5"
android:paddingLeft="15dp"
android:paddingTop="10dp"
android:textColor="#999999"
android:textSize="14sp"
android:visibility="gone"
tools:text="我们可以设置每行的行间距,aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
可以通过属性android:lineSpacingExtra或android:lineSpacingMultiplier来做。 "/>
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="@+id/bottom_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/ll_kefu"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight="1"
android:background="@color/white"
android:gravity="center">
<ImageView
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_marginRight="5dp"
android:src="@drawable/pay_home_kefu"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:text="客服"
android:textColor="#666666"
android:textSize="17sp"/>
</LinearLayout>
<com.ydl.ydlcommon.view.RoundCornerButton
android:id="@+id/rcb_pay"
style="?android:attr/borderlessButtonStyle"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight="2"
android:text="支付"
android:gravity="center_vertical|center_horizontal"
android:includeFontPadding="false"
android:textColor="@color/white"
android:textSize="17sp"
app:pa_round_btn_bg="#1BD75E"/>
</LinearLayout>
</RelativeLayout>
\ No newline at end of file
......@@ -23,7 +23,7 @@
</RelativeLayout>
<com.yidianling.ydl_pay.widget.NoScrollViewPager
<com.yidianling.ydl_pay.common.widget.NoScrollViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="425dp"
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="15dp"
android:background="@drawable/pay_bg_radius_top_white_10"
android:paddingRight="15dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp">
<TextView
android:id="@+id/text_title"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="倾诉服务"
android:gravity="center|left"
android:textStyle="bold"
android:textColor="@color/platform_color_242424"
android:textSize="17sp"
android:layout_weight="1"/>
<TextView
android:id="@+id/text_oldmoney"
android:layout_width="wrap_content"
android:layout_height="match_parent"
tools:text="129.00"
android:textColor="@color/platform_color_242424"
android:textStyle="bold"
android:textSize="16sp"
android:gravity="center_vertical"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@color/platform_color_E0E0E0"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="优惠"
android:textSize="15sp"
android:textColor="@color/platform_color_242424"
android:gravity="center|left"
android:layout_weight="1"/>
<TextView
android:id="@+id/text_youhui"
android:layout_width="wrap_content"
android:layout_height="match_parent"
tools:text="50"
android:textSize="15sp"
android:textColor="@color/platform_color_666666"
android:drawablePadding="5dp"
android:gravity="center_vertical"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@color/platform_color_E0E0E0"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="使用余额"
android:textSize="15sp"
android:textColor="@color/platform_color_242424"
android:gravity="center|left"
android:layout_weight="1"/>
<TextView
android:id="@+id/text_yu_e"
android:layout_width="wrap_content"
android:layout_height="match_parent"
tools:text="-9.00"
android:textSize="15sp"
android:textColor="@color/platform_color_666666"
android:gravity="center_vertical"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@color/platform_color_E0E0E0"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="还需支付"
android:textSize="15sp"
android:textColor="@color/platform_color_242424"
android:gravity="center|left"
android:layout_weight="1"/>
<TextView
android:id="@+id/text_money"
android:layout_width="wrap_content"
android:layout_height="match_parent"
tools:text="129.00"
android:textSize="20dp"
android:textColor="@color/platform_color_FF5A4C"
android:gravity="center_vertical"/>
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/text_paytip"
android:layout_width="match_parent"
android:layout_height="30dp"
android:text="选择支付方式"
android:textSize="12dp"
android:paddingLeft="15dp"
android:gravity="center_vertical"
android:textColor="@color/platform_color_999999"
android:background="@color/platform_color_F7F7F7"/>
<LinearLayout
android:id="@+id/lin_pay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:orientation="vertical">
<LinearLayout
android:id="@+id/ll_wechat"
android:layout_width="match_parent"
android:layout_height="55dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/pay_wechat_for_pay" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="微信支付"
android:textColor="@color/platform_color_242424"
android:textSize="15sp" />
<ImageView
android:id="@+id/iv_wechat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/pay_img_select" />
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="@dimen/divide_line_stroke_width"
android:background="#EDEDED" />
<LinearLayout
android:id="@+id/ll_alipay"
android:layout_width="match_parent"
android:layout_height="55dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/pay_zhifubao_for_pay" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="支付宝支付"
android:textColor="@color/platform_color_242424"
android:textSize="15sp" />
<ImageView
android:id="@+id/iv_alipay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/pay_img_no_select" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/text_pay"
android:layout_width="match_parent"
android:layout_height="55dp"
android:text="确认付款"
android:gravity="center"
android:textColor="@color/white"
android:textSize="17dp"
android:background="#FF3D9EFF"/>
</LinearLayout>
\ No newline at end of file
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal"
android:padding="24dp">
<ProgressBar
style="?android:attr/progressBarStyleSmall"
android:layout_width="32dp"
android:layout_height="32dp"/>
<TextView
android:id="@+id/tvMsg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:textColor="#ff666666"
android:text="加载中…"/>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/ll_layout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="17dp"
android:textSize="16dp"
android:textColor="@color/color_3D3D3D"
android:text="可使用红包"/>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginTop="16dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="#F0F0F0"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/ll_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:orientation="vertical">
<!--这样写是因为 padding不好用了 调UI好烦-->
<RelativeLayout
android:id="@+id/rl_notUse"
android:layout_width="match_parent"
android:layout_height="48dp"
android:orientation="horizontal"
android:layout_marginTop="19.5dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:background="@drawable/pay_redpacket_tv_bg">
<TextView
android:layout_width="wrap_content"
android:layout_height="48dp"
android:gravity="center_vertical"
android:textColor="@color/platform_color_666666"
android:textSize="14sp"
android:text="不使用红包"
android:layout_marginStart="15dp"
tools:ignore="RtlSymmetry" />
<ImageView
android:id="@+id/imgCheck"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_centerVertical="true"
android:layout_marginRight="12dp"
android:layout_alignParentRight="true"
android:visibility="invisible"
android:background="@drawable/pay_img_select"/>
</RelativeLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout
android:id="@+id/ll_Red"
android:layout_width="114dp"
android:layout_height="90dp"
android:background="@drawable/pay_redpacket_icon"
android:orientation="vertical">
<TextView
android:id="@+id/tvMoney"
android:layout_width="114dp"
android:layout_height="90dp"
android:gravity="center"
android:textColor="@color/white"
android:textSize="38dp"
android:textStyle="bold"
tools:text="¥3"/>
</LinearLayout>
<TextView
android:id="@+id/tv_title"
android:layout_toEndOf="@+id/ll_Red"
android:layout_marginTop="17dp"
android:layout_marginStart="12dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textColor="@color/platform_color_666666"
android:textStyle="bold"
tools:text="心理测试专属红包"
tools:ignore="SpUsage" />
<TextView
android:id="@+id/tvTimeEnd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/ll_Red"
android:layout_alignParentBottom="true"
android:layout_marginStart="12dp"
android:layout_marginBottom="16dp"
android:textSize="10sp"
android:textColor="@color/platform_color_999999"
tools:text="有效期至2018-08-31"/>
<ImageView
android:id="@+id/imgCheck"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginTop="16dp"
android:layout_marginRight="12dp"
android:layout_alignParentRight="true"
android:background="@drawable/pay_img_select"/>
</merge>
\ No newline at end of file
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