tj
2025-03-28 dde2eeddbaf07246da7c2c352e7d49ec63fddcd2
app/src/main/java/com/example/firstapp/ui/notifications/NotificationsFragment.kt
@@ -131,37 +131,37 @@
    private fun setupClickListeners() {
        // 支付插件
        binding.payPlugin.setOnClickListener {
            // 跳转到支付插件页面
            lifecycleScope.launch {
                try {
                    val response = RetrofitClient.apiService.getPayOrderInfo()
                    var orderInfo=response.data
                    Log.d("AliPayHelper","获取订单信息时: ${response}")
                    // 这里调用支付宝
                    PayAbility.aliPay(requireActivity(), orderInfo, Observer {
                        when (it.resultStatus) {
                            "9000" -> {
//                                Snackbar.make(binding.root, "支付成功", Snackbar.LENGTH_LONG).show()
                                requireActivity().runOnUiThread {
                                    Toast.makeText(requireContext(), "支付成功", Toast.LENGTH_LONG).show()
                                }
                            }
                            else -> {
//                                Snackbar.make(binding.root, "支付失败", Snackbar.LENGTH_LONG).show()
                                requireActivity().runOnUiThread {
                                    Toast.makeText(requireContext(), "支付失败", Toast.LENGTH_LONG).show()
                                }
                            }
                        }
                    })
                } catch (e: Exception) {
                    Log.d("AliPayHelper","获取订单信息时发生错误: ${e.message}")
                }
            }
        }
//        binding.payPlugin.setOnClickListener {
//            // 跳转到支付插件页面
//            lifecycleScope.launch {
//                try {
//                    val response = RetrofitClient.apiService.getPayOrderInfo()
//                    var orderInfo=response.data
//                    Log.d("AliPayHelper","获取订单信息时: ${response}")
//                    // 这里调用支付宝
//                    PayAbility.aliPay(requireActivity(), orderInfo, Observer {
//                        when (it.resultStatus) {
//                            "9000" -> {
////                                Snackbar.make(binding.root, "支付成功", Snackbar.LENGTH_LONG).show()
//                                requireActivity().runOnUiThread {
//                                    Toast.makeText(requireContext(), "支付成功", Toast.LENGTH_LONG).show()
//                                }
//                            }
//                            else -> {
////                                Snackbar.make(binding.root, "支付失败", Snackbar.LENGTH_LONG).show()
//                                requireActivity().runOnUiThread {
//                                    Toast.makeText(requireContext(), "支付失败", Toast.LENGTH_LONG).show()
//                                }
//
//                            }
//                        }
//                    })
//
//                } catch (e: Exception) {
//                    Log.d("AliPayHelper","获取订单信息时发生错误: ${e.message}")
//                }
//            }
//        }
        // 设置提醒