update: 调整支付接口, 记录成功后的属性
parent
23a2616b95
commit
852853629e
|
|
@ -13,7 +13,7 @@ namespace Guru
|
||||||
{
|
{
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
GuruSDKModel.Instance.PurchasedCount++; // 记录成功购买次数
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@ namespace Guru
|
||||||
public int b_level = 0;
|
public int b_level = 0;
|
||||||
public int b_play = 0;
|
public int b_play = 0;
|
||||||
public int buy_count = 0;
|
public int buy_count = 0;
|
||||||
public bool is_iap_user = false;
|
|
||||||
|
|
||||||
public List<PurchasedProduct> purchased;
|
public List<PurchasedProduct> purchased;
|
||||||
//-------------- data ---------------
|
//-------------- data ---------------
|
||||||
|
|
@ -93,19 +92,8 @@ namespace Guru
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsIapUser
|
public bool IsIapUser => PurchasedCount > 0;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if(_isIapUser == null) InitProperties();
|
|
||||||
return _isIapUser.Value;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if(_isIapUser == null) InitProperties();
|
|
||||||
_isIapUser.Value = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private BindableProperty<int> _successLevel;
|
private BindableProperty<int> _successLevel;
|
||||||
|
|
@ -160,7 +148,6 @@ namespace Guru
|
||||||
_totalPlayed = new BindableProperty<int>(b_play, OnPlayedChanged);
|
_totalPlayed = new BindableProperty<int>(b_play, OnPlayedChanged);
|
||||||
_purchasedCount = new BindableProperty<int>(buy_count, OnPurchasedNumChanged);
|
_purchasedCount = new BindableProperty<int>(buy_count, OnPurchasedNumChanged);
|
||||||
_uid = new BindableProperty<string>(uid, OnUidChanged);
|
_uid = new BindableProperty<string>(uid, OnUidChanged);
|
||||||
_isIapUser = new BindableProperty<bool>(is_iap_user, OnIsIapUserChanged);
|
|
||||||
|
|
||||||
purchased = new List<PurchasedProduct>(20);
|
purchased = new List<PurchasedProduct>(20);
|
||||||
}
|
}
|
||||||
|
|
@ -206,11 +193,6 @@ namespace Guru
|
||||||
Save();
|
Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnIsIapUserChanged(bool value)
|
|
||||||
{
|
|
||||||
is_iap_user = value;
|
|
||||||
Save();
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 启动配置
|
#region 启动配置
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,6 @@ namespace Guru
|
||||||
private static void OnIAPInitResult(bool success)
|
private static void OnIAPInitResult(bool success)
|
||||||
{
|
{
|
||||||
LogI($"IAP init result: {success}");
|
LogI($"IAP init result: {success}");
|
||||||
|
|
||||||
IsIAPReady = success;
|
IsIAPReady = success;
|
||||||
Callbacks.IAP._onIAPInitComplete?.Invoke(success);
|
Callbacks.IAP._onIAPInitComplete?.Invoke(success);
|
||||||
}
|
}
|
||||||
|
|
@ -182,6 +181,7 @@ namespace Guru
|
||||||
/// <param name="success"></param>
|
/// <param name="success"></param>
|
||||||
private static void OnBuyEnd(string productName, bool success)
|
private static void OnBuyEnd(string productName, bool success)
|
||||||
{
|
{
|
||||||
|
if (success) Model.PurchasedCount++;
|
||||||
_onPurchaseCallback?.Invoke(productName, success);
|
_onPurchaseCallback?.Invoke(productName, success);
|
||||||
Callbacks.IAP._onPurchaseEnd?.Invoke(productName, success);
|
Callbacks.IAP._onPurchaseEnd?.Invoke(productName, success);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue