feedback.ts 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { _decorator, Component, Node, Sprite, SpriteFrame } from 'cc';
  2. import { base_ui } from '../../fw/base_ui';
  3. import { feedback_selected } from './feedback_selected';
  4. import { feedback_submit } from './feedback_submit';
  5. import { http } from '../../http';
  6. import { config } from '../../config';
  7. import { uiManager } from '../../manager/uiManager';
  8. const { ccclass, property } = _decorator;
  9. @ccclass('feedback')
  10. export class feedback extends base_ui {
  11. @property(Node) btn_close:Node = null
  12. @property(Node) img_title:Node = null
  13. @property(SpriteFrame) sf_feedback_title:SpriteFrame = null
  14. @property(Node) submit_bottom:Node = null
  15. @property(Node) btn_submit_up:Node = null
  16. @property(Node) btn_submit_true:Node = null
  17. @property(Node) selected_node:Node = null
  18. @property(Node) submit_node:Node = null
  19. start() {
  20. this.onButtonListen(this.btn_close, ()=>{
  21. this.close()
  22. })
  23. this.onButtonListen(this.btn_submit_up, ()=>{
  24. this.selected_node.active = true
  25. this.submit_bottom.active = false
  26. this.submit_node.active = false
  27. this.img_title.getComponent(Sprite).spriteFrame = this.sf_feedback_title
  28. })
  29. this.onButtonListen(this.btn_submit_true, ()=>{
  30. this.onClickSubmit()
  31. })
  32. this.selected_node.getComponent(feedback_selected).initView((r)=>{
  33. this.img_title.getComponent(Sprite).spriteFrame = r.sf
  34. this.selected_node.active = false
  35. this.submit_bottom.active = true
  36. this.submit_node.active = true
  37. this.submit_node.getComponent(feedback_submit).initView(r)
  38. })
  39. }
  40. onClickSubmit() {
  41. let data = this.submit_node.getComponent(feedback_submit).getData()
  42. // console.log('submit data=',data)
  43. if(data!=null) {
  44. uiManager.Instance().showLoading()
  45. http.post(config.API.feedback, data, (err,d)=>{
  46. uiManager.Instance().hideLoading()
  47. if(!err){
  48. let nd = JSON.parse(d)
  49. if(nd.code === config.status.SUCCESS){
  50. this.close()
  51. }
  52. }
  53. })
  54. }
  55. }
  56. }