feedback_submit.ts 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. let fromdata = {'stype': 1}
  35. http.uploadFile(config.API.upload_img, filePath, fromdata, null,(err,d)=>{
  36. if(!err){
  37. let data = JSON.parse(d)
  38. if(data.code===config.status.SUCCESS){
  39. // console.log('data=',data.content)
  40. this.img_url = data.content.surl
  41. tools.loadRemoteImg(this.img_url, (res)=>{
  42. this.btn_add_img.getComponent(Sprite).spriteFrame = res.sf
  43. })
  44. }
  45. }
  46. })
  47. })
  48. }
  49. public getData() {
  50. if(this.editbox_content.string.length<10) {
  51. uiManager.showToast('问题描述小于10个字')
  52. return null
  53. }
  54. if(this.editbox_contact.string.length<=0) {
  55. uiManager.showToast('请填写联系方式')
  56. return null
  57. }
  58. let data = {'title': this.m_data.title,
  59. 'describe':this.editbox_content.string,
  60. 'img_url':this.img_url,
  61. 'mobile':this.editbox_contact.string,
  62. }
  63. return data
  64. }
  65. }