applyListInfoItem.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. snbAmount: {
  5. default: null,
  6. type: cc.Label,
  7. serializable: true,
  8. },
  9. applyItem: {
  10. default: null,
  11. serializable: false,
  12. visible: false
  13. },
  14. applyButton: {
  15. default: null,
  16. type: cc.Node,
  17. serializable: true,
  18. },
  19. parentScript: {
  20. default: null,
  21. visible: false
  22. },
  23. isTrans: false
  24. },
  25. setInfo(context) {
  26. let { item, parentScript } = context;
  27. this.applyItem = item;
  28. this.snbAmount.string = item.snb;
  29. if (1 === item.isState) {
  30. this.applyButton.active = true;
  31. }else{
  32. this.applyButton.active = false;
  33. }
  34. this.parentScript = parentScript;
  35. },
  36. /**
  37. * 提现cnt
  38. */
  39. onApplyTranCnt() {
  40. //限制相关人员交易
  41. if (1 === GlobalD.UserInfo.limitTran) {
  42. GlobalD.GameData.showToast(
  43. cc.find('Canvas/UICamera'),
  44. '转换CNT通道关闭,请联系相关管理人员!',
  45. 1
  46. )
  47. return
  48. }
  49. if (0 === Number(this.applyItem.snb) || 0 != Number(this.applyItem.snb) % 5) {
  50. GlobalD.GameData.showToast(
  51. cc.find('Canvas/UICamera'),
  52. '请输入5的倍数兑换!',
  53. 1
  54. )
  55. return
  56. }
  57. // console.log('发起兑换:' + Number(this.applyItem.snb));
  58. console.log('this.applyItem', this.applyItem);
  59. //todo 这里先判断一次,对应的snb是否是审查的snb凭证
  60. if (this.isTrans) return;
  61. GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), "兑换中", 10);
  62. this.isTrans = true;
  63. GlobalD.GameData.onCheckApplySnbToCnt(this.applyItem.id, (checkRes) => {
  64. this.isTrans = false;
  65. if (0 === checkRes.code) {
  66. console.log('发起兑换:' + Number(this.applyItem.snb),"== checkRes.data.snb:",checkRes.data.snb);
  67. GlobalD.GameData.onSnbToCnt(checkRes.data.snb, (data) => {
  68. //更新数据
  69. // console.log('res=', data)
  70. //更新审核列表
  71. this.parentScript.onchildrenUpdate();
  72. })
  73. } else {
  74. this.parentScript.onchildrenUpdate();
  75. GlobalD.GameData.showToast(cc.find("Canvas/UICamera"), checkRes.msg, 3);
  76. }
  77. })
  78. }
  79. });