RedBagCashData.ts 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. import { Data } from "../../../mk/data/Data";
  2. import JsbSystem from "../../../mk/system/JsbSystem";
  3. import { GameProp } from "../GameData";
  4. /**
  5. * 红包提现数据
  6. * - 跨Index不可提现,提示:请按顺序提现。
  7. * @author 薛鸿潇
  8. */
  9. export class RedBagCashData extends Data {
  10. /**
  11. * 数据初始化
  12. */
  13. public init() {
  14. // 提现进度
  15. // this.cash_bar = gData.gameData.getProp(GameProp.redBag_cash_bar);// 自定义测试数据
  16. this.cash_bar = gData.gameData.gameData.cashIndex;// 服务端数据
  17. // this.initCData();// 假数据列表
  18. // 签到配置表
  19. if (gData.gameData.configs.CashCfg) {
  20. gData.gameData.configs.CashCfg.forEach(item_data => {
  21. for (const key in item_data) {
  22. item_data[key] = parseInt(item_data[key])
  23. }
  24. });
  25. this.c_data = gData.gameData.configs.CashCfg;
  26. this.sortList();
  27. this.init_list = true;
  28. }
  29. }
  30. /** 标志位:初始化列表 */
  31. public init_list: boolean = false;
  32. /** 配置表数据 */
  33. public c_data: Array<CDataType> = [];
  34. private _cash_bar: number = 0;
  35. /** 提现进度 */
  36. set cash_bar(value: number) {
  37. this._cash_bar = value;
  38. this.init_list = true;
  39. }
  40. get cash_bar() {
  41. return this._cash_bar;
  42. }
  43. /**
  44. * 提现操作
  45. */
  46. public async cashOP() {
  47. if (!gData.loginData.isAuth) {
  48. JsbSystem.WxAuth();
  49. return;
  50. }
  51. /** 提现档位 */
  52. const cash_index = this.cash_bar;
  53. let data = { index: cash_index };
  54. let response = await mk.http.sendData('cashUsual', data);
  55. if (response.errcode != 0) {
  56. mk.tip.pop(response.errmsg);
  57. return;
  58. }
  59. let r_data = response.data;
  60. if (r_data.CashMode == 0) {//星云打款
  61. }
  62. else if (r_data.CashMode == 1) {//公众号打款
  63. }
  64. this.cash_bar++;
  65. gData.gameData.gameData.cashIndex++;
  66. // 扣除红包
  67. let item_data = this.getItemDataByIndex(cash_index);
  68. gData.gameData.gameData.redMoney -= item_data.type_value;
  69. // 打开提现到账界面
  70. gData.receiptNotice.receip_rmb = r_data.CashStatusList[0].amount;
  71. gData.cashNormal.receip_total_rmb += gData.receiptNotice.receip_rmb;
  72. mk.ui.openPanel('module/receiptNotice/receiptNotice');
  73. this.sortList();
  74. }
  75. /**
  76. * 排序
  77. * - 已提条目放最后
  78. */
  79. private sortList() {
  80. const l_count = this.c_data.length;
  81. let index = 0;
  82. for (let i = 0; i < l_count; i++) {
  83. if (this.c_data[index].index <= gData.redBagCash.cash_bar) {
  84. let item_data = this.c_data.splice(index, 1);
  85. this.c_data.push(item_data[0]);
  86. index--;
  87. }
  88. index++;
  89. }
  90. }
  91. /**
  92. * 获取条目,通过index
  93. * @param cash_index 对应id
  94. * @returns
  95. */
  96. public getItemDataByIndex(cash_index: number): CDataType {
  97. const l_count = this.c_data.length;
  98. for (let i = 0; i < l_count; i++) {
  99. if (this.c_data[i].index === cash_index) {
  100. return this.c_data[i]
  101. }
  102. }
  103. }
  104. /** 客户端造的假数据 */
  105. private initCData() {
  106. for (let i = 0; i < 20; i++) {
  107. const id = i + 1;
  108. let obj = {
  109. index: id,
  110. /** 毛币数量? */
  111. money: id,
  112. /** 红包数量 */
  113. type_value: id * 1000,
  114. time: id,
  115. directVideoTime: id,
  116. delayVideoTimes: id,
  117. money_type: id,
  118. num: id,
  119. moneyshow: id,
  120. summoney: id
  121. };
  122. this.c_data.push(obj)
  123. }
  124. this.init_list = true;
  125. }
  126. }
  127. /** 配置表数据内容 */
  128. export type CDataType = {
  129. /** id */
  130. index: number,
  131. /** 毛币数量,单位分 */
  132. money: number,
  133. /** 红包币数量 */
  134. type_value: number,
  135. time: number,
  136. directVideoTime: number,
  137. delayVideoTimes: number,
  138. money_type: number,
  139. num: number,
  140. moneyshow: number,
  141. summoney: number
  142. }