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.
55 lines
2.0 KiB
55 lines
2.0 KiB
using AIK.Common.Language;
|
|
using AIK.Models.ApiModels.Integral;
|
|
using AIK.Models.ApiModels.Record;
|
|
using AIK.Service.IService;
|
|
using AIK.ViewModels.UserKeyRecord;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using Microsoft.Extensions.Logging;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace AIK.ViewModels.Integral
|
|
{
|
|
public partial class IntegralViewModel : ObservableObject
|
|
{
|
|
private readonly IAikDataService _aikDataService;
|
|
private readonly IDataCacheService _dataCacheService;
|
|
private readonly ILogger<IntegralViewModel> _logger;
|
|
[ObservableProperty]
|
|
private ObservableCollection<IntegralRecord> _records = new();
|
|
[ObservableProperty]
|
|
private bool isShowLoadMore = true;
|
|
[ObservableProperty]
|
|
private string notMoreTip = "没有更多记录了~";
|
|
|
|
public IntegralViewModel(IAikDataService aikDataService, IDataCacheService dataCacheService, ILogger<IntegralViewModel> logger)
|
|
{
|
|
_aikDataService = aikDataService;
|
|
_dataCacheService = dataCacheService;
|
|
_logger = logger;
|
|
_ = LoadRecordsAsync();
|
|
}
|
|
private async Task LoadRecordsAsync()
|
|
{
|
|
var token = await _dataCacheService.GetLatestUserTokenAsync();
|
|
if (!string.IsNullOrEmpty(token))
|
|
{
|
|
var result = await _aikDataService.GetUserIntegralHistroy(token);
|
|
if (result != null)
|
|
{
|
|
if (result.Total == result.Records.Count)
|
|
{
|
|
IsShowLoadMore = false;
|
|
NotMoreTip = AiKLanguage.LanguageKey.GetValueOrDefault("NotMoreTips");
|
|
}
|
|
Records = new ObservableCollection<IntegralRecord>(result.Records);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|