import { _decorator, Component, Label, Node, Sprite, UIOpacity } from 'cc'; import { base_ui } from '../../fw/base_ui'; import { car_item_data, car_type } from '../../data'; import { imageCacheManager } from '../../manager/imageCacheManager'; import { userDataManager } from '../../manager/userDataManager'; import { car_info_shuxing } from './car_info_shuxing'; import { dataManager } from '../../manager/dataManager'; import { car_info_get_suipian } from './car_info_get_suipian'; const { ccclass, property } = _decorator; @ccclass('car_info') export class car_info extends base_ui { @property(Node) public_bg:Node = null @property(Node) btn_close:Node = null @property(Node) lab_xiangcha_score:Node = null @property(Node) img_car:Node = null @property(Node) lab_car_name:Node = null @property(Node) lab_score:Node = null @property(Node) img_suo:Node = null @property(Node) shuxing_info:Node = null @property(Node) operate_btn_node:Node = null @property(Node) btn_zhuangbei:Node = null @property(Node) btn_duihuan:Node = null @property(Node) get_suipian_node:Node = null private m_data:car_item_data = null private m_is_jiesuo:boolean = false private m_zhuangbei_cb = null private m_duihuan_cb = null private m_look_video_cb = null private m_share_cb = null start() { this.onButtonListen(this.public_bg, ()=>{ this.close() }) this.onButtonListen(this.btn_close, ()=>{ this.close() }) this.onButtonListen(this.btn_zhuangbei, ()=>{ this.close() this.m_zhuangbei_cb && this.m_zhuangbei_cb(this) }) this.onButtonListen(this.btn_duihuan, ()=>{ this.m_duihuan_cb && this.m_duihuan_cb(this) }) this.get_suipian_node.getComponent(car_info_get_suipian).initView(()=>{ this.m_look_video_cb && this.m_look_video_cb(this) }, ()=>{ this.m_share_cb && this.m_share_cb(this) }) this.setCarSuipianData() } public initView(data:car_item_data, is_jiesuo:boolean) { this.m_data = data this.m_is_jiesuo = is_jiesuo if(is_jiesuo) { this.img_suo.active = false this.lab_car_name.active = false this.lab_xiangcha_score.getComponent(Label).string = data.name this.lab_score.getComponent(Label).string = userDataManager.user_data.license_code } else { if(data.stype==car_type.score) { let xiangcha_score = data.unlock_points - userDataManager.user_car_list.max_integral if(xiangcha_score<0) { xiangcha_score = 0 } this.lab_xiangcha_score.getComponent(Label).string = `距离解锁还差 ${xiangcha_score} 分` this.lab_score.getComponent(Label).string = data.unlock_points + '分解锁' } else { let cur_count = data.temp_bag_list_item_data.quantity let xiangcha_score = data.unlock_points - cur_count if(xiangcha_score<0) { xiangcha_score = 0 } this.lab_xiangcha_score.getComponent(Label).string = `距离解锁还差 ${xiangcha_score} 碎片` this.lab_score.getComponent(Label).string = `已集齐 ${cur_count} / ${data.unlock_points}碎片` } this.img_suo.active = true this.lab_car_name.active = true this.lab_car_name.getComponent(Label).string = data.name } this.img_car.getComponent(Sprite).spriteFrame = imageCacheManager.getRankCarImageById(data.id) this.shuxing_info.getComponent(car_info_shuxing).initView(data) this.operate_btn_node.active = false this.get_suipian_node.active = false if(is_jiesuo) { this.showOperateNode(true) if(userDataManager.user_car_list.default_car_id==data.id) { this.btn_zhuangbei.active = false } else { this.btn_zhuangbei.active = true } this.btn_duihuan.active = false } else { if(data.stype==car_type.suipian) { if(dataManager.userCarListHavCar(data.id)) { this.showOperateNode(true) this.btn_zhuangbei.active = true this.btn_duihuan.active = false } else { let cur_count = data.temp_bag_list_item_data.quantity if(cur_count-data.unlock_points>=0) { this.showOperateNode(true) this.btn_zhuangbei.active = false this.btn_duihuan.active = true } else { // 看视频/分享 碎片 this.showOperateNode(false) } } } } } public initOperateNodeCallback(zhuangbei_cb, duihuan_cb) { this.m_zhuangbei_cb = zhuangbei_cb this.m_duihuan_cb = duihuan_cb } public initGetSuipianNodeCallback(look_video_cb, share_cb) { this.m_look_video_cb = look_video_cb this.m_share_cb = share_cb } public setCarSuipianData() { this.get_suipian_node.getComponent(car_info_get_suipian).setData() } public closeSelf() { this.close() } public getData():car_item_data { return this.m_data } public getIsJiesuo():boolean { return this.m_is_jiesuo } private showOperateNode(is_show:boolean) { if(is_show) { this.operate_btn_node.active = true this.get_suipian_node.active = false } else { this.operate_btn_node.active = false this.get_suipian_node.active = true } } }