| | |
| | | import com.sinata.xqmuse.utils.interfaces.StringCallback |
| | | import com.sinata.xqmuse.utils.pay.PayListener |
| | | import kotlinx.android.synthetic.main.activity_buy_course.* |
| | | import org.jetbrains.anko.browse |
| | | import org.jetbrains.anko.startActivity |
| | | import org.jetbrains.anko.toast |
| | | |
| | |
| | | private val fromDetail by lazy { intent.getBooleanExtra("fromDetail",true) } |
| | | private val id by lazy { intent.getStringExtra("id") } |
| | | private var data:ConfirmOrder? = null |
| | | private var orderId = "" |
| | | |
| | | override fun initClick() { |
| | | tv_buy_rule.clickDelay { |
| | |
| | | private fun pay(way:Int) { |
| | | tv_action.isEnabled = false |
| | | showDialog() |
| | | HttpManager.placeOrder(1,way,if (rb_balance.isChecked) 1 else 2,null,null,data?.id?:"",null).request(this,success = {_,data-> |
| | | onPaySuccess() |
| | | HttpManager.placeOrder(1,way,if (rb_balance.isChecked) 1 else 2,null,null,data?.id?:"",null,data?.orderId).request(this,success = {_,data-> |
| | | tv_action.isEnabled = true |
| | | orderId = data?.orderId?:"" |
| | | if (way == 1) |
| | | data?.jumpToWx(this) |
| | | else |
| | | browse(data?.qrcodeUrl?:"") |
| | | }){_,_-> |
| | | tv_action.isEnabled = true |
| | | } |
| | |
| | | tv_total.text = generalPrice |
| | | val s = "余额抵扣 当前可用 ¥$balance" |
| | | rb_balance.text = SpanBuilder(s).size(4,s.length,11).color(this@BuyVoiceActivity,4,s.length,R.color.textColor99).build() |
| | | rb_balance.isChecked = !(balance.isNullOrEmpty()||balance.toDouble() == 0.0) |
| | | } |
| | | } |
| | | } |
| | |
| | | tv_total.text = generalPrice |
| | | val s = "余额抵扣 当前可用 ¥$balance" |
| | | rb_balance.text = SpanBuilder(s).size(4,s.length,11).color(this@BuyVoiceActivity,4,s.length,R.color.textColor99).build() |
| | | rb_balance.isChecked = !(balance.isNullOrEmpty()||balance.toDouble() == 0.0) |
| | | } |
| | | } |
| | | } |
| | | |
| | | private fun checkPayStatus(){ |
| | | if (!orderId.isNullOrEmpty()){ |
| | | HttpManager.queryPayment(orderId).request(this){_,data-> |
| | | when(data){ |
| | | "pending"->{ |
| | | toast("未查询到支付结果,如已付款请忽略") |
| | | } |
| | | "succeeded"->{ |
| | | toast("支付成功") |
| | | onPaySuccess() |
| | | } |
| | | "failed"->{ |
| | | toast("支付失败") |
| | | } |
| | | } |
| | | } |
| | | orderId = "" |
| | | } |
| | | } |
| | | |
| | | override fun onResume() { |
| | | super.onResume() |
| | | checkPayStatus() |
| | | } |
| | | |
| | | override fun onPaySuccess() { |
| | | setResult(RESULT_OK) |
| | | startActivity<PaySuccessActivity>("data" to data,"fromDetail" to fromDetail,"isAudio" to true) |