update: 更新 Product 接口, 返回本地化价格数据
parent
8a20783844
commit
3c2e68a6b8
|
|
@ -210,7 +210,7 @@ namespace Guru
|
|||
|
||||
if (_products.ContainsKey(item.definition.id))
|
||||
{
|
||||
_products[item.definition.id].Product = item;
|
||||
_products[item.definition.id].SetProduct(item);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -587,6 +587,18 @@ namespace Guru
|
|||
OnBuyFailed?.Invoke(info.Name, failureReason.ToString());
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取商品的本地化价格字符串
|
||||
/// 如果商品不存在或者 IAP 尚未初始化完成则显示 "Loading" 字样
|
||||
/// </summary>
|
||||
/// <param name="productName"></param>
|
||||
/// <returns></returns>
|
||||
public string GetLocalizedPriceString(string productName)
|
||||
{
|
||||
return GetInfo(productName)?.LocalizedPriceString ?? "Loading";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Log 输出
|
||||
|
|
|
|||
|
|
@ -66,8 +66,11 @@ namespace Guru
|
|||
[Serializable]
|
||||
public partial class ProductInfo
|
||||
{
|
||||
private Product _product;
|
||||
public ProductSetting Setting;
|
||||
public Product Product;
|
||||
public Product Product => _product;
|
||||
|
||||
public void SetProduct(Product product) => _product = product;
|
||||
|
||||
public string Name => Setting.ProductName;
|
||||
public string Id => Product.definition.id;
|
||||
|
|
@ -76,6 +79,7 @@ namespace Guru
|
|||
public string Category => Setting.Category;
|
||||
public string Type => Setting.Type == ProductType.Subscription ? "subscription" : "product";
|
||||
public bool IsFree => Setting.IsFree;
|
||||
public string LocalizedPriceString => Product?.metadata.localizedPriceString ?? $"$ {Setting.Price}";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue