feedback_submit.ts 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. const { ccclass, property } = _decorator;
  8. @ccclass('feedback_submit')
  9. export class feedback_submit extends base_ui {
  10. @property(Node) lab_title:Node = null
  11. @property(Node) btn_add_img:Node = null
  12. @property(EditBox) editbox_content:EditBox = null
  13. @property(EditBox) editbox_contact:EditBox = null
  14. private m_data = null
  15. private img_url:string = ''
  16. start() {
  17. this.onButtonListen(this.btn_add_img, ()=>{
  18. this.onClickAddImg()
  19. })
  20. this.editbox_content.node.on(EditBox.EventType.EDITING_DID_ENDED, ()=>{
  21. console.log('this.editbox_content=',this.editbox_content.string)
  22. })
  23. this.editbox_contact.node.on(EditBox.EventType.EDITING_DID_ENDED, ()=>{
  24. console.log('this.editbox_contact=',this.editbox_contact.string)
  25. })
  26. }
  27. initView(data) {
  28. this.m_data = data
  29. this.lab_title.getComponent(Label).string = '-- ' + data.title +'内容'
  30. }
  31. private onClickAddImg() {
  32. SdkUtil.choosSystemImage((filePath)=>{
  33. http.uploadFile(config.API.up_feedback_img,filePath,null,(err,d)=>{
  34. if(!err){
  35. let data = JSON.parse(d)
  36. if(data.code===config.status.SUCCESS){
  37. // console.log('data=',data.content)
  38. this.img_url = data.content.surl
  39. tools.loadRemoteImg(this.img_url, (res)=>{
  40. this.btn_add_img.getComponent(Sprite).spriteFrame = res.sf
  41. })
  42. }
  43. }
  44. })
  45. })
  46. }
  47. public getData() {
  48. if(this.editbox_content.string.length<=0) {
  49. return null
  50. }
  51. let data = {'title': this.m_data.title,
  52. 'describe':this.editbox_content.string,
  53. 'img_url':this.img_url,
  54. 'mobile':this.editbox_contact.string,
  55. }
  56. return data
  57. }
  58. }