question_btn_info.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { _decorator, Component, Node } from 'cc';
  2. import { ui_att_item } from '../../../data/data';
  3. import { receive_res_item } from '../uiWidget/receive_res_item';
  4. import { receive_widget_item } from '../uiWidget/receive_widget_item';
  5. import { tools } from '../../tools';
  6. import { config } from '../../config';
  7. const { ccclass, property } = _decorator;
  8. @ccclass('question_btn_info')
  9. export class question_btn_info extends Component {
  10. @property(Node) res_node:Node = null;
  11. @property(Node) att_node:Node = null;
  12. @property(Node) btn_delete:Node = null;
  13. private m_data:ui_att_item = null;
  14. private m_index:number = 0;
  15. private m_call_back = null;
  16. public initView(data:ui_att_item,index:number,call,type){
  17. this.m_data =data;
  18. this.m_call_back = call;
  19. this.m_index = index;
  20. if(type===config.attributes_list_type.question_select){
  21. this.btn_delete.active = true;
  22. }else{
  23. this.btn_delete.active = false;
  24. }
  25. this.res_node.getComponent(receive_res_item).initView(this.m_data,type)
  26. this.att_node.getComponent(receive_widget_item).updateView(this.m_data,type)
  27. this.btn_delete.off(Node.EventType.TOUCH_END)
  28. this.btn_delete.on(Node.EventType.TOUCH_END,()=>{
  29. if(this.m_call_back!=null){
  30. tools.show_dialog("确定删除此按钮?",()=>{
  31. this.m_call_back(this.m_index)
  32. this.node.destroy()
  33. this.node.removeFromParent()
  34. })
  35. }
  36. })
  37. }
  38. protected onDestroy(): void {
  39. this.res_node.destroy()
  40. this.att_node.destroy()
  41. }
  42. }