|
|
@@ -12,18 +12,20 @@ export class RedBagCashData extends Data {
|
|
|
* 数据初始化
|
|
|
*/
|
|
|
public init() {
|
|
|
+ // 签到进度
|
|
|
+ this.cash_bar = gData.gameData.getProp(GameProp.redBag_cash_bar);// 自定义测试数据
|
|
|
+ // this.cash_bar = gData.gameData.gameData.cashIndex;// 服务端数据
|
|
|
// 签到配置表
|
|
|
- this.initCData();
|
|
|
- if (gData.gameData.configs.cashcfg) {
|
|
|
- gData.gameData.configs.cashcfg.forEach(item_data => {
|
|
|
+ if (gData.gameData.configs.CashCfg) {
|
|
|
+ gData.gameData.configs.CashCfg.forEach(item_data => {
|
|
|
for (const key in item_data) {
|
|
|
item_data[key] = parseInt(item_data[key])
|
|
|
}
|
|
|
});
|
|
|
- this.c_data = gData.gameData.configs.cashcfg;
|
|
|
+ this.c_data = gData.gameData.configs.CashCfg;
|
|
|
+ this.sortList();
|
|
|
this.init_list = true;
|
|
|
}
|
|
|
- this.cash_bar = gData.gameData.getProp(GameProp.redBag_cash_bar);
|
|
|
}
|
|
|
/** 标志位:初始化列表 */
|
|
|
public init_list: boolean = false;
|
|
|
@@ -31,40 +33,91 @@ export class RedBagCashData extends Data {
|
|
|
/** 配置表数据 */
|
|
|
public c_data: Array<CDataType> = [];
|
|
|
|
|
|
- /** 标志位:初始化指定列表 */
|
|
|
+ private _cash_bar: number = 0;
|
|
|
/** 提现进度 */
|
|
|
- cash_bar: number = 0;
|
|
|
+ set cash_bar(value: number) {
|
|
|
+ this._cash_bar = value;
|
|
|
+ this.init_list = true;
|
|
|
+ }
|
|
|
+ get cash_bar() {
|
|
|
+ return this._cash_bar;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 提现操作
|
|
|
*/
|
|
|
public cashOP() {
|
|
|
+ /** 提现档位 */
|
|
|
+ const cash_index = this.cash_bar;
|
|
|
this.cash_bar++;
|
|
|
gData.gameData.setProp(GameProp.redBag_cash_bar, this.cash_bar);
|
|
|
+
|
|
|
+ // 扣除红包
|
|
|
+ this.sortList();
|
|
|
+ let item_data = this.getItemDataByIndex(cash_index);
|
|
|
+ gData.gameData.gameData.redMoney -= item_data.type_value;
|
|
|
+
|
|
|
+ // 打开提现到账界面
|
|
|
+ gData.receiptNotice.receip_rmb = item_data.money;
|
|
|
+ gData.cashNormal.receip_total_rmb += gData.receiptNotice.receip_rmb;
|
|
|
+ mk.ui.openPanel('module/receiptNotice/receiptNotice');
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 排序
|
|
|
+ * - 已提条目放最后
|
|
|
+ */
|
|
|
+ private sortList() {
|
|
|
+ const l_count = this.c_data.length;
|
|
|
+ let index = 0;
|
|
|
+ for (let i = 0; i < l_count; i++) {
|
|
|
+ if (this.c_data[index].index <= gData.redBagCash.cash_bar) {
|
|
|
+ let item_data = this.c_data.splice(index, 1);
|
|
|
+ this.c_data.push(item_data[0]);
|
|
|
+ index--;
|
|
|
+ }
|
|
|
+ index++;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- /** 客户端造的假数据 */
|
|
|
- private initCData() {
|
|
|
- for (let i = 0; i < 20; i++) {
|
|
|
- const id = i + 1;
|
|
|
- let obj = {
|
|
|
- index: id,
|
|
|
- /** 毛币数量? */
|
|
|
- money: id,
|
|
|
- /** 红包数量 */
|
|
|
- type_value: id * 10000,
|
|
|
- time: id,
|
|
|
- directVideoTime: id,
|
|
|
- delayVideoTimes: id,
|
|
|
- money_type: id,
|
|
|
- num: id,
|
|
|
- moneyshow: id,
|
|
|
- summoney: id
|
|
|
- };
|
|
|
- this.c_data.push(obj)
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取条目,通过index
|
|
|
+ * @param cash_index 对应id
|
|
|
+ * @returns
|
|
|
+ */
|
|
|
+ private getItemDataByIndex(cash_index: number): CDataType {
|
|
|
+ const l_count = this.c_data.length;
|
|
|
+ for (let i = 0; i < l_count; i++) {
|
|
|
+ if (this.c_data[i].index === cash_index) {
|
|
|
+ return this.c_data[i]
|
|
|
+ }
|
|
|
}
|
|
|
- this.init_list = true;
|
|
|
}
|
|
|
+
|
|
|
+ // /** 客户端造的假数据 */
|
|
|
+ // private initCData() {
|
|
|
+ // for (let i = 0; i < 20; i++) {
|
|
|
+ // const id = i + 1;
|
|
|
+ // let obj = {
|
|
|
+ // index: id,
|
|
|
+ // /** 毛币数量? */
|
|
|
+ // money: id,
|
|
|
+ // /** 红包数量 */
|
|
|
+ // type_value: id * 1000,
|
|
|
+ // time: id,
|
|
|
+ // directVideoTime: id,
|
|
|
+ // delayVideoTimes: id,
|
|
|
+ // money_type: id,
|
|
|
+ // num: id,
|
|
|
+ // moneyshow: id,
|
|
|
+ // summoney: id
|
|
|
+ // };
|
|
|
+ // this.c_data.push(obj)
|
|
|
+ // }
|
|
|
+ // this.init_list = true;
|
|
|
+ // }
|
|
|
}
|
|
|
/** 配置表数据内容 */
|
|
|
export type CDataType = {
|