RedBagCashData.ts 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. gData.cashNormal.getRecord();// 请求新的提现记录
  75. }
  76. /**
  77. * 排序
  78. * - 已提条目放最后
  79. */
  80. private sortList() {
  81. const l_count = this.c_data.length;
  82. let index = 0;
  83. for (let i = 0; i < l_count; i++) {
  84. if (this.c_data[index].index <= gData.redBagCash.cash_bar) {
  85. let item_data = this.c_data.splice(index, 1);
  86. this.c_data.push(item_data[0]);
  87. index--;
  88. }
  89. index++;
  90. }
  91. }
  92. /**
  93. * 获取条目,通过index
  94. * @param cash_index 对应id
  95. * @returns
  96. */
  97. public getItemDataByIndex(cash_index: number): CDataType {
  98. const l_count = this.c_data.length;
  99. for (let i = 0; i < l_count; i++) {
  100. if (this.c_data[i].index === cash_index) {
  101. return this.c_data[i]
  102. }
  103. }
  104. }
  105. /** 客户端造的假数据 */
  106. private initCData() {
  107. for (let i = 0; i < 20; i++) {
  108. const id = i + 1;
  109. let obj = {
  110. index: id,
  111. /** 毛币数量? */
  112. money: id,
  113. /** 红包数量 */
  114. type_value: id * 1000,
  115. time: id,
  116. directVideoTime: id,
  117. delayVideoTimes: id,
  118. money_type: id,
  119. num: id,
  120. moneyshow: id,
  121. summoney: id
  122. };
  123. this.c_data.push(obj)
  124. }
  125. this.init_list = true;
  126. }
  127. }
  128. /** 配置表数据内容 */
  129. export type CDataType = {
  130. /** id */
  131. index: number,
  132. /** 毛币数量,单位分 */
  133. money: number,
  134. /** 红包币数量 */
  135. type_value: number,
  136. time: number,
  137. directVideoTime: number,
  138. delayVideoTimes: number,
  139. money_type: number,
  140. num: number,
  141. moneyshow: number,
  142. summoney: number
  143. }