feedback.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. import { SdkUtil } from '../../sdkUtil';
  9. const { ccclass, property } = _decorator;
  10. @ccclass('feedback')
  11. export class feedback extends base_ui {
  12. @property(Node) btn_close:Node = null
  13. @property(Node) img_title:Node = null
  14. @property(SpriteFrame) sf_feedback_title:SpriteFrame = null
  15. @property(Node) submit_bottom:Node = null
  16. @property(Node) btn_submit_up:Node = null
  17. @property(Node) btn_submit_true:Node = null
  18. @property(Node) selected_node:Node = null
  19. @property(Node) submit_node:Node = null
  20. start() {
  21. this.onButtonListen(this.btn_close, ()=>{
  22. this.close()
  23. })
  24. this.onButtonListen(this.btn_submit_up, ()=>{
  25. this.selected_node.active = true
  26. this.submit_bottom.active = false
  27. this.submit_node.active = false
  28. this.img_title.getComponent(Sprite).spriteFrame = this.sf_feedback_title
  29. })
  30. this.onButtonListen(this.btn_submit_true, ()=>{
  31. this.onClickSubmit()
  32. })
  33. this.selected_node.getComponent(feedback_selected).initView((r)=>{
  34. this.img_title.getComponent(Sprite).spriteFrame = r.sf
  35. this.selected_node.active = false
  36. this.submit_bottom.active = true
  37. this.submit_node.active = true
  38. this.submit_node.getComponent(feedback_submit).initView(r)
  39. })
  40. }
  41. onClickSubmit() {
  42. let data = this.submit_node.getComponent(feedback_submit).getData()
  43. // console.log('submit data=',data)
  44. if(data!=null) {
  45. uiManager.Instance().showLoading('正在提交...')
  46. http.post(config.API.feedback, data, (err,d)=>{
  47. uiManager.Instance().hideLoading()
  48. if(!err){
  49. let nd = JSON.parse(d)
  50. if(nd.code === config.status.SUCCESS){
  51. SdkUtil.showToast('意见反馈已提交')
  52. this.close()
  53. }
  54. }
  55. })
  56. }
  57. }
  58. }