StorePayPropView.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. using System;
  2. using System.Threading.Tasks;
  3. using ET;
  4. using FairyGUI;
  5. using UI.Store;
  6. namespace GFGGame
  7. {
  8. public class StorePayPropView : BaseWindow
  9. {
  10. private UI_StorePayPropUI _ui;
  11. //商品id
  12. private int _goodsId;
  13. //临时订单id
  14. private long _tempOrderId;
  15. //订单金额
  16. private long _price;
  17. public override void Dispose()
  18. {
  19. if (_ui != null)
  20. {
  21. _ui.Dispose();
  22. }
  23. _ui = null;
  24. base.Dispose();
  25. }
  26. protected override void OnHide()
  27. {
  28. base.OnHide();
  29. }
  30. protected override void OnInit()
  31. {
  32. base.OnInit();
  33. packageName = UI_StorePayPropUI.PACKAGE_NAME;
  34. _ui = UI_StorePayPropUI.Create();
  35. this.viewCom = _ui.target;
  36. this.viewCom.Center();
  37. this.modal = true;
  38. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  39. _ui.m_payVxBtn.onClick.Add(OnVxBtnBuyClick);
  40. _ui.m_payAliBtn.onClick.Add(OnAliBtnBuyClick);
  41. _ui.m_payClose.onClick.Add(OnCloseClick);
  42. }
  43. protected override void OnShown()
  44. {
  45. base.OnShown();
  46. _goodsId = (int)(this.viewData as object[])[0];
  47. _tempOrderId = long.Parse((this.viewData as object[])[1].ToString());
  48. _price = (long)(this.viewData as object[])[2];
  49. ShopCfg cfg = ShopCfgArray.Instance.GetCfg(_goodsId);
  50. _ui.m_txtTotal.text = _price + "元";
  51. _ui.m_txtShopName.text = cfg.productName;
  52. _ui.m_txtXzf.text = _price + "元";
  53. }
  54. private async void OnVxBtnBuyClick()
  55. {
  56. string timestamp = ((long)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds).ToString();
  57. string APP_ID = "wxd9772f42f126413f";
  58. string MCH_ID = "200768907612";
  59. string prepayid = "wx201411101639507cbf6ffd8b0779950874";
  60. string packageValue = "Sign=WXPay";
  61. string noncestr = "5K8264ILTKCH16CQ2502SI8ZNMI4POJ5";
  62. string sign = "C380BEC2BFD727A4B6845133519F3AD6";
  63. AliManagerr.Instance.PayVx(APP_ID, MCH_ID, prepayid, packageValue,
  64. noncestr, timestamp, sign);
  65. }
  66. private async void OnAliBtnBuyClick()
  67. {
  68. S2C_CreateAliOrder response = await ShopSProxy.ReqCreateAliOrder(_tempOrderId);
  69. if (response == null || string.IsNullOrEmpty(response.AliOrderStr))
  70. {
  71. //TODO 提示调起支付宝失败
  72. return;
  73. }
  74. AliManagerr.Instance.Pay(response.AliOrderStr);
  75. }
  76. private async void OnCloseClick()
  77. {
  78. }
  79. }
  80. }