feedback_submit.ts 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import { _decorator, Component, EditBox, Label, Node, Sprite, SpriteFrame } from 'cc';
  2. import { base_ui } from '../../fw/base_ui';
  3. import { SdkUtil } from '../../sdkUtil';
  4. import { http } from '../../http';
  5. import { config } from '../../config';
  6. import { tools } from '../../tools';
  7. import { uiManager } from '../../manager/uiManager';
  8. const { ccclass, property } = _decorator;
  9. @ccclass('feedback_submit')
  10. export class feedback_submit extends base_ui {
  11. @property(Node) lab_title:Node = null
  12. @property(Node) btn_add_img:Node = null
  13. @property(EditBox) editbox_content:EditBox = null
  14. @property(EditBox) editbox_contact:EditBox = null
  15. private m_data = null
  16. private img_url:string = ''
  17. start() {
  18. this.onButtonListen(this.btn_add_img, ()=>{
  19. this.onClickAddImg()
  20. })
  21. this.editbox_content.node.on(EditBox.EventType.EDITING_DID_ENDED, ()=>{
  22. console.log('this.editbox_content=',this.editbox_content.string)
  23. })
  24. this.editbox_contact.node.on(EditBox.EventType.EDITING_DID_ENDED, ()=>{
  25. console.log('this.editbox_contact=',this.editbox_contact.string)
  26. })
  27. }
  28. initView(data) {
  29. this.m_data = data
  30. this.lab_title.getComponent(Label).string = '-- ' + data.title +'内容'
  31. }
  32. private onClickAddImg() {
  33. SdkUtil.choosSystemImage((filePath)=>{
  34. http.uploadFile(config.API.up_feedback_img,filePath,null,(err,d)=>{
  35. if(!err){
  36. let data = JSON.parse(d)
  37. if(data.code===config.status.SUCCESS){
  38. // console.log('data=',data.content)
  39. this.img_url = data.content.surl
  40. tools.loadRemoteImg(this.img_url, (res)=>{
  41. this.btn_add_img.getComponent(Sprite).spriteFrame = res.sf
  42. })
  43. }
  44. }
  45. })
  46. })
  47. }
  48. public getData() {
  49. if(this.editbox_content.string.length<=0) {
  50. uiManager.showToast('请填写内容')
  51. return null
  52. }
  53. if(this.editbox_contact.string.length<=0) {
  54. uiManager.showToast('请填写联系方式')
  55. return null
  56. }
  57. let data = {'title': this.m_data.title,
  58. 'describe':this.editbox_content.string,
  59. 'img_url':this.img_url,
  60. 'mobile':this.editbox_contact.string,
  61. }
  62. return data
  63. }
  64. }