PigBankData.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import { Data } from "../../../mk/data/Data";
  2. /**
  3. * 存钱罐数据
  4. * - 提现描述显示:
  5. * 1.判断是否可提,
  6. * 可提显示“直接提现”
  7. * 不可提判断存款是否满足提现最低限制
  8. * 满足显示:“明日提现”,
  9. * 不满足显示:“满x可提”
  10. * @author 薛鸿潇
  11. */
  12. export class PigBankData extends Data {
  13. /**
  14. * 数据初始化
  15. */
  16. public init() {
  17. // 提现状态
  18. this.cash_enable = gData.gameData.gameData.isWithdrawable;
  19. // 存款金额
  20. this._cur_cash_count = gData.gameData.gameData.piggyBank;
  21. }
  22. /** 标志位:是否需要刷新数据 */
  23. public init_data: boolean = true;
  24. /** 是否可提现 */
  25. private _cash_enable: number = 0;
  26. set cash_enable(bool: number) {
  27. if (this._cash_enable != bool) {
  28. this._cash_enable = bool;
  29. this.init_data = true;
  30. }
  31. }
  32. get cash_enable(): number {
  33. return this._cash_enable;
  34. }
  35. /** 当前存款 */
  36. private _cur_cash_count: number = 0;
  37. set cur_cash_count(value: number) {
  38. if (this._cur_cash_count != value) {
  39. this._cur_cash_count = value;
  40. this.init_data = true;
  41. }
  42. }
  43. get cur_cash_count(): number {
  44. return this._cur_cash_count;
  45. }
  46. /** 提现最低限制 */
  47. public cash_min_limit: number = 0.3;
  48. /**
  49. * 提现操作
  50. * - 此处需要对接服务端数据
  51. */
  52. public async cashOP() {
  53. let data = {};
  54. let response = await mk.http.sendRequest('piggyBankCash', 'POST', JSON.stringify(data));
  55. // let response = await mk.http.sendRequest('readyCash', 'POST', JSON.stringify(data));
  56. if (response.errcode != 0) {
  57. mk.tip.pop('系统异常');
  58. return;
  59. }
  60. if (response.CashMode == 0) {//星云打款
  61. // mk.tip.pop('')
  62. }
  63. else if (response.CashMode == 1) {//公众号打款
  64. }
  65. this.cash_enable = 0;
  66. // 打开提现到账界面
  67. gData.receiptNotice.receip_rmb = this._cur_cash_count;
  68. gData.cashNormal.receip_total_rmb += gData.receiptNotice.receip_rmb;
  69. mk.ui.openPanel('module/receiptNotice/receiptNotice');
  70. }
  71. }