| | |
| | | import com.sinata.xqmuse.ui.TransparentStatusBarActivity |
| | | import com.sinata.xqmuse.utils.extention.clickDelay |
| | | 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.startActivity |
| | | import org.jetbrains.anko.toast |
| | | |
| | | class BuyCourseActivity:TransparentStatusBarActivity() { |
| | | class BuyCourseActivity:TransparentStatusBarActivity(),PayListener { |
| | | override fun setContentView() = R.layout.activity_buy_course |
| | | |
| | | private val isSend by lazy { intent.getBooleanExtra("isSend",false) } |
| | | private val fromDetail by lazy { intent.getBooleanExtra("fromDetail",true) } |
| | | private val data by lazy { intent.getParcelableExtra<ConfirmOrder>("data") } |
| | | private var receiveId:String? = null |
| | | |
| | | override fun initClick() { |
| | | tv_search.setOnClickListener { |
| | |
| | | toast("手机号输入有误") |
| | | }else{ |
| | | HttpManager.getUserByPhone(phone).request(this){_,data-> |
| | | receiveId = data?.id |
| | | iv_avatar.setImageURI(data?.avatar) |
| | | tv_name.text = data?.nickname |
| | | tv_phone.text = data?.cellPhone |
| | |
| | | buyRuleDialog.showAllowingStateLoss(supportFragmentManager,"rule") |
| | | } |
| | | } |
| | | |
| | | tv_action.setOnClickListener { |
| | | if (cb_rule.isChecked){ |
| | | if (rb_ali.isChecked){ |
| | | pay(2) |
| | | }else if (rb_wx.isChecked){ |
| | | pay(1) |
| | | } else if (rb_balance.isChecked&&((data?.balance?:"0.0").toDouble()>(data?.generalPrice?:"0.0").toDouble())){ |
| | | payBalance() |
| | | }else{ |
| | | |
| | | } |
| | | }else |
| | | toast("请阅读并同意《购买协议》") |
| | | } |
| | | } |
| | | |
| | | private fun pay(way:Int) { |
| | | tv_action.isEnabled = false |
| | | showDialog() |
| | | HttpManager.placeOrder(2,way,2,null,receiveId,data?.id?:"",null).request(this,success = {_,data-> |
| | | onPaySuccess() |
| | | |
| | | }){_,_-> |
| | | tv_action.isEnabled = true |
| | | } |
| | | } |
| | | |
| | | private fun payBalance() { |
| | | tv_action.isEnabled = false |
| | | showDialog() |
| | | HttpManager.gvieCourse(data?.id?:"",2,receiveId).request(this,success = {_,_-> |
| | | onPaySuccess() |
| | | }){_,_-> |
| | | tv_action.isEnabled = true |
| | | } |
| | | } |
| | | |
| | | override fun initView() { |
| | |
| | | } |
| | | } |
| | | |
| | | override fun onPaySuccess() { |
| | | setResult(RESULT_OK) |
| | | startActivity<PaySuccessActivity>("data" to data,"fromDetail" to fromDetail) |
| | | finish() |
| | | } |
| | | |
| | | override fun onPayCancel() { |
| | | } |
| | | |
| | | override fun onPayError(msg: String) { |
| | | } |
| | | } |