ui_manifestations.ts 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import { _decorator, Component, Node } from 'cc';
  2. import { zhao_xi_jie_data, zhao_xi_jie_item_data } from '../../../data/data';
  3. import { config } from '../../config';
  4. import { tip_type_single } from './tip_type_single';
  5. import { tip_type_all } from './tip_type_all';
  6. import { shouji_item } from './shouji_item';
  7. import { ClientEvent } from '../../clientEvent';
  8. import { gameManager } from '../gameManager';
  9. import { SdkUtil } from '../../sdkUtil';
  10. const { ccclass, property } = _decorator;
  11. @ccclass('ui_manifestations')
  12. export class ui_manifestations extends Component {
  13. @property(Node) tip_type_single:Node = null;
  14. @property(Node) tip_type_all:Node = null;
  15. @property(Node) btn_single_click_hide_tip:Node = null;
  16. private tipsMap:Map<string,boolean> = new Map;
  17. private mData:zhao_xi_jie_data = null;
  18. public initView(data:zhao_xi_jie_data){
  19. this.mData = data;
  20. if(this.mData.tip_type===config.zhao_xi_jie_tip_type.select_tips){
  21. this.tip_type_single.active = true;
  22. this.btn_single_click_hide_tip.active = false;
  23. this.btn_single_click_hide_tip.on(Node.EventType.TOUCH_END,()=>{
  24. this.btn_single_click_hide_tip.active = false;
  25. this.tip_type_single.getComponent(tip_type_single).hideTipBtn()
  26. })
  27. this.tip_type_all.active = false;
  28. this.tip_type_single.getComponent(tip_type_single).initView(data,this.onItemClick.bind(this),this.onItemTips.bind(this))
  29. }else{
  30. this.tip_type_all.active = true;
  31. this.tip_type_single.active = false;
  32. this.tip_type_all.getComponent(tip_type_all).initView(data,this.onShowTips.bind(this))
  33. }
  34. ClientEvent.on(config.EventRun.SHOW_ZHAO_BU_TONG_FINISH_STATUS,this.on_zhao_bu_tong_finish.bind(this),this)
  35. }
  36. on_zhao_bu_tong_finish(widget:zhao_xi_jie_item_data){
  37. if(this.mData.tip_type===config.zhao_xi_jie_tip_type.select_tips){
  38. this.tip_type_single.getComponent(tip_type_single).showFinishIcon(widget.widget_id)
  39. }else{
  40. this.tip_type_all.getComponent(tip_type_all).showFinishIcon(widget.widget_id)
  41. }
  42. }
  43. onItemClick(){
  44. this.btn_single_click_hide_tip.active = true;
  45. }
  46. public onItemTips(data:zhao_xi_jie_item_data){
  47. if(this.tipsMap.get(data.tips_res)){
  48. ClientEvent.dispatchEvent(config.EventRun.SHOW_TIPS,data.tips_res)
  49. }else{
  50. SdkUtil.showVideoAd(config.TT_REWARD.LOOK_TIPS,(res)=>{
  51. if(res.isEnded){
  52. this.tipsMap.set(data.tips_res,true)
  53. ClientEvent.dispatchEvent(config.EventRun.SHOW_TIPS,data.tips_res)
  54. }
  55. })
  56. }
  57. }
  58. public onShowTips(){
  59. gameManager.Singleton.showTips()
  60. }
  61. }