| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- /*
- * @Author: mojunshou 1637302775@qq.com
- * @Date: 2025-03-20 18:39:37
- * @LastEditors: mojunshou 1637302775@qq.com
- * @LastEditTime: 2025-04-29 16:28:24
- * @Description: 红包列表item
- */
- import { _decorator, Label, Node, ProgressBar, Sprite } from 'cc';
- import { oops } from 'db://oops-framework/core/Oops';
- import { GameComponent } from 'db://oops-framework/module/common/GameComponent';
- import { smc } from '../common/SingletonModuleComp';
- import { TableLevelConfig } from '../common/table/TableLevelConfig';
- import { ServerHandler } from '../common/manager/ServerHandler';
- import { DCHandler } from '../common/manager/DCHandler';
- const { ccclass, property } = _decorator;
- /** 显示对象控制 */
- @ccclass('RedPackeItemView')
- export class RedPackeItemView extends GameComponent {
- @property(Node)
- private receiveNode: Node = null!;
- @property(Node)
- private receivedNode: Node = null!;
- @property(Node)
- private unReceiveNode: Node = null!;
- @property(Label)
- private lab_title: Label = null!;
- @property(Label)
- private lab_progress: Label = null!;
- @property(ProgressBar)
- private pro_progress: ProgressBar = null!;
- private sp_icon: Sprite = null!;
- @property(Label)
- private lab_num: Label = null!;
- data: any = {
- id: 0,
- title_num: 0,
- cur_num: 0,
- total_num: 0,
- status: 0,
- reward: [],
- level: 0
- }
- protected start() {
- this.setButton();
- }
- setItem(data: any, idx: number) {
- this.data.id = data.id;
- this.data.level = data.level;
- this.data.title_num = data.target;
- this.data.cur_num = smc.account.AccountModel.xcCount;
- this.data.total_num = data.target;
- this.data.status = data.status;
- this.data.reward = data.reward;
- this.updateData();
- }
- //更新数据
- private updateData() {
- this.unReceiveNode.active = this.data.status == 0;
- this.receiveNode.active = this.data.status == 1;
- this.receivedNode.active = this.data.status == 2;
- this.lab_title.string = this.data.title_num + "次";
- this.lab_num.string = this.data.reward[0].propNum + "元";
- this.lab_progress.string = `${this.data.cur_num}/${this.data.total_num}`;
- const loadNum = this.data.cur_num / this.data.total_num > 1 ? 1 : this.data.cur_num / this.data.total_num;
- this.pro_progress.progress = loadNum;
- }
- //进行中按钮
- private btn_none() {
- oops.gui.toast("完成任务即可领取红包~");
- }
- //可领取按钮
- private btn_receive() {
- //发送领取红包请求
- if (this.data.status == 1) {
- console.log("发送领取红包请求");
- ServerHandler.inst.getDailyReward(this.data.level);
- DCHandler.inst.reportData(3000902, this.data.level);
- }
- }
- }
|