兼容win7版应用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.4 KiB

using AIK.Models.ApiModels.Payment;
using AIK.ViewModels.Integral;
using CommunityToolkit.Mvvm.DependencyInjection;
using System;
using System.Windows;
namespace AIK.Views.MenuPages.Integral
{
public partial class PaymentQrCodeWindow : Window
{
private readonly PaymentQrCodeViewModel _viewModel;
public PaymentQrCodeWindow(PaymentParametersPC payment, decimal amount, byte[]? qrCodeBytes)
{
InitializeComponent();
_viewModel = Ioc.Default.GetRequiredService<PaymentQrCodeViewModel>();
_viewModel.PaymentSucceeded += OnPaymentSucceeded;
DataContext = _viewModel;
_viewModel.Start(payment, amount, qrCodeBytes ?? Array.Empty<byte>());
#if !(CN || TEST)
PaymentTitleText.Text = "PayPal支付";
QrCodeBorder.Visibility = Visibility.Collapsed;
PaypalHintBorder.Visibility = Visibility.Visible;
#endif
}
protected override void OnClosed(EventArgs e)
{
_viewModel.Stop();
_viewModel.PaymentSucceeded -= OnPaymentSucceeded;
base.OnClosed(e);
}
private void OnPaymentSucceeded()
{
DialogResult = true;
Close();
}
private void CloseButton_Click(object sender, RoutedEventArgs e)
{
#if CN || TEST
Close();
#else
_viewModel.ReopenPaypal();
#endif
}
}
}