123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- import { _decorator, Color, color, Component, Label, Node, Sprite, SpriteFrame } from 'cc';
- import { base_ui } from '../../fw/base_ui';
- import { sign_reward_data } from '../../data';
- import { tools } from '../../tools';
- const { ccclass, property } = _decorator;
- @ccclass('sign_reward_item')
- export class sign_reward_item extends base_ui {
- @property(Node) img_state:Node = null
- @property(Node) img_bg:Node = null
- @property(Node) lab_xingqi:Node = null
- @property(Node) lab_days:Node = null
- @property(Node) img_icon:Node = null
- @property(Node) lab_count:Node = null
- @property(Node) lab_name:Node = null
- @property(Node) img_mask:Node = null
- @property(SpriteFrame) sf_icon_lq:SpriteFrame = null
- @property(SpriteFrame) sf_icon_bq:SpriteFrame = null
- @property(SpriteFrame) sf_item_default:SpriteFrame = null
- @property(SpriteFrame) sf_item_current:SpriteFrame = null
-
- private color_default = new Color().fromHEX("#6a70e9") //蓝色
- private color_current = new Color().fromHEX("#ef941d") //橘黄色
- private m_data:sign_reward_data = null
- private m_cb = null
- start() {
- this.onButtonListen(this.node,()=>{
- this.m_cb && this.m_cb(this)
- })
- }
- initView(data:sign_reward_data, cb) {
- this.setData(data)
- this.m_cb = cb
- }
- public getData():sign_reward_data {
- return this.m_data
- }
- public setData(data:sign_reward_data) {
- this.m_data = data
- this.lab_days.getComponent(Label).string = `${data.index+1}`
- tools.loadRemoteImg(data.icon, (d)=>{
- this.img_icon.getComponent(Sprite).spriteFrame = d.sf
- })
- this.lab_count.getComponent(Label).string = `x${data.quantity}`
- this.lab_name.getComponent(Label).string = data.name
- this.img_state.active = false
- if(data.receive_status==1) {
- // 已领取
- this.img_mask.active = true
- this.setState(true)
- } else {
- // 未领取
- this.img_mask.active = false
- // 当前今天
- if(data.current_sign_status==1) {
- this.img_state.active = true
- this.img_state.getComponent(Sprite).spriteFrame = this.sf_icon_lq
- this.setState(false)
- } else {
- // 补签
- if(data.repair_sign_status==1) {
- this.img_state.active = true
- this.img_state.getComponent(Sprite).spriteFrame = this.sf_icon_bq
- }
- }
- }
- }
- private setState(is_default:boolean) {
- if(is_default) {
- this.img_bg.getComponent(Sprite).spriteFrame = this.sf_item_default
- this.lab_xingqi.getComponent(Label).color = this.color_default
- this.lab_days.getComponent(Label).color = this.color_default
- this.lab_name.getComponent(Label).color = this.color_default
- } else {
- this.img_bg.getComponent(Sprite).spriteFrame = this.sf_item_current
- this.lab_xingqi.getComponent(Label).color = this.color_current
- this.lab_days.getComponent(Label).color = this.color_current
- this.lab_name.getComponent(Label).color = this.color_current
- }
- }
-
- }
|