withdraw.ts 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. // Learn TypeScript:
  2. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
  7. import HTTPS, { NetGet, NetPost } from "./HTTPS";
  8. import Tips from "./Tips";
  9. const { ccclass, property } = cc._decorator;
  10. @ccclass
  11. export default class withdraw extends cc.Component {
  12. @property(cc.Node)
  13. RuleContent: cc.Node = null;
  14. @property(cc.Node)
  15. withdrawContent: cc.Node = null;
  16. @property(cc.Node)
  17. HistoryContent: cc.Node = null;
  18. @property(cc.Node)
  19. HistoryItem: cc.Node = null;
  20. // LIFE-CYCLE CALLBACKS:
  21. onLoad() {
  22. this.RuleContent.active = false
  23. let Close = this.node.getChildByName("Close")
  24. vv.deleteBtnEvent(Close, this)
  25. vv.addBtnEvent(Close, () => {
  26. this.node.active = false
  27. }, this)
  28. }
  29. protected onEnable(): void {
  30. this.getRule()
  31. }
  32. getRule() {
  33. let withdraw = this.node.getChildByName("withdraw")
  34. let history = this.node.getChildByName("history")
  35. withdraw.active = false
  36. history.active = false
  37. let Rule = this.node.getChildByName("Rule")
  38. Rule.active = true
  39. HTTPS.Instance.get(NetGet.rule).then(res => {
  40. if (res.code != 200) {
  41. Tips.Instance.show(res.msg)
  42. return
  43. }
  44. this.RuleContent.children[0].getChildByName("title").getComponent(cc.Label).string = '最小提现金额'
  45. this.RuleContent.children[0].getChildByName("reward").getComponent(cc.Label).string = res.data.min_amount
  46. this.RuleContent.children[1].getChildByName("title").getComponent(cc.Label).string = '最大提现金额'
  47. this.RuleContent.children[1].getChildByName("reward").getComponent(cc.Label).string = res.data.max_amount
  48. this.RuleContent.children[2].getChildByName("title").getComponent(cc.Label).string = '手续费率'
  49. this.RuleContent.children[2].getChildByName("reward").getComponent(cc.Label).string = res.data.fee_rate + '%'
  50. this.RuleContent.children[3].getChildByName("title").getComponent(cc.Label).string = '每日最大提现次数'
  51. this.RuleContent.children[3].getChildByName("reward").getComponent(cc.Label).string = res.data.daily_times
  52. this.RuleContent.children[4].getChildByName("title").getComponent(cc.Label).string = '今日已提现次数'
  53. this.RuleContent.children[4].getChildByName("reward").getComponent(cc.Label).string = res.data.today_times
  54. this.RuleContent.children[5].getChildByName("title").getComponent(cc.Label).string = '剩余提现次数'
  55. this.RuleContent.children[5].getChildByName("reward").getComponent(cc.Label).string = res.data.remain_times
  56. this.RuleContent.children[6].getChildByName("title").getComponent(cc.Label).string = '用户余额'
  57. this.RuleContent.children[6].getChildByName("reward").getComponent(cc.Label).string = res.data.balance
  58. this.RuleContent.active = true
  59. })
  60. }
  61. getwithdraw() {
  62. let Rule = this.node.getChildByName("Rule")
  63. let history = this.node.getChildByName("history")
  64. Rule.active = false
  65. history.active = false
  66. let withdraw = this.node.getChildByName("withdraw")
  67. withdraw.active = true
  68. }
  69. btnwithdraw() {
  70. let total = this.node.getComponentsInChildren(cc.EditBox)
  71. if (!total[0]?.string) {
  72. Tips.Instance.show('提现金额不能未空')
  73. return
  74. }
  75. if (!total[1].string) {
  76. Tips.Instance.show('提现方式不能未空')
  77. return
  78. }
  79. if (!total[2].string) {
  80. Tips.Instance.show('提现账号不能未空')
  81. return
  82. }
  83. if (!total[3].string) {
  84. Tips.Instance.show('真实姓名不能未空')
  85. return
  86. }
  87. HTTPS.Instance.post(NetPost.withdraw, {
  88. amount: total[0].string,//提现金额
  89. withdraw_type: total[1].string,//提现方式(alipay/wxpay/bank)
  90. account: total[2].string,//提现账号
  91. real_name:total[3].string,// 真实姓名
  92. }).then(res => {
  93. if (res.code != 200) {
  94. Tips.Instance.show(res.msg)
  95. return
  96. }
  97. Tips.Instance.show(res.msg)
  98. })
  99. }
  100. getwHistory() {
  101. let Rule = this.node.getChildByName("Rule")
  102. let withdraw = this.node.getChildByName("withdraw")
  103. Rule.active = false
  104. withdraw.active = false
  105. let history = this.node.getChildByName("history")
  106. history.active = true
  107. HTTPS.Instance.get(NetGet.withdrawHistory).then(res => {
  108. if (res.code != 200) {
  109. Tips.Instance.show(res.msg)
  110. return
  111. }
  112. this.HistoryContent.children.forEach(e => {
  113. e.active = false
  114. })
  115. for (let index = 0; index < res.data.list.length; index++) {
  116. const Data = res.data.list[index];
  117. let Node = this.HistoryContent[index] as cc.Node;
  118. if (!Node) {
  119. Node = cc.instantiate(this.HistoryItem) as cc.Node
  120. Node.parent = this.HistoryContent
  121. }
  122. let title = Node.getChildByName("title").getComponent(cc.Label)
  123. let type = Node.getChildByName("type").getComponent(cc.Label)
  124. let reward = Node.getChildByName("reward").getComponent(cc.Label)
  125. title.string = Data.withdraw_type_text + Data.actual_amount.toString()
  126. type.string = Data.status_text
  127. reward.string = Data.createtime
  128. Node.active = true
  129. }
  130. })
  131. }
  132. // update (dt) {}
  133. }