widget_not_have_interact.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { _decorator, Component, Node, SpriteFrame } from 'cc';
  2. import { not_have_interact_data } from '../../../data/data';
  3. import { receive_widget_item } from './receive_widget_item';
  4. import { Attributes } from '../Attributes';
  5. import { tools } from '../../tools';
  6. import { ClientEvent } from '../../clientEvent';
  7. import { config } from '../../config';
  8. const { ccclass, property } = _decorator;
  9. @ccclass('widget_not_have_interact')
  10. export class widget_not_have_interact extends Component {
  11. @property(Node) bg_widget_info:Node = null;
  12. @property(Node) btn_original_size:Node = null;
  13. private m_data:not_have_interact_data = null;
  14. protected start(): void {
  15. this.btn_original_size.on(Node.EventType.TOUCH_END, ()=>{
  16. if(this.m_data.bg.res.length==0) {
  17. return tools.showToast('还没有图片')
  18. }
  19. tools.loadUrl(this.m_data.bg.res,null,(sf:SpriteFrame)=>{
  20. this.m_data.bg.width = sf.originalSize.width
  21. this.m_data.bg.height = sf.originalSize.height
  22. this.updateStatus()
  23. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,Attributes.Singleton.get_cur_att_data(),config.attributes_list_type.top)
  24. })
  25. })
  26. }
  27. public initView(data:not_have_interact_data){
  28. this.m_data = data;
  29. this.updateStatus()
  30. }
  31. private updateStatus() {
  32. this.bg_widget_info.getComponent(receive_widget_item).updateView(this.m_data.bg)
  33. }
  34. }