hot.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import {getDataSet, getEventParam, throttle, toast} from "../../../../utils/utils";
  2. import Api from "../../../../model/api";
  3. import Config from "../../../../model/config";
  4. Component({
  5. properties: {},
  6. data: {
  7. msg: '',
  8. attachmentType: '',
  9. attachmentUrl: '',
  10. uploadPath: Config.UPLOAD_PATH.COMMUNITY_FOCUSISSUES
  11. },
  12. methods: {
  13. onChange(e) {
  14. const field = getDataSet(e, "field");
  15. this.setData({
  16. [field]: getEventParam(e)
  17. })
  18. },
  19. handleUpload(e) {
  20. const fileType = getEventParam(e, "fileType");
  21. const fileList = getEventParam(e, "fileList");
  22. const urls = fileList.map(item => item.url);
  23. const attachmentUrl = JSON.stringify(urls);
  24. this.setData({
  25. attachmentType: fileType, attachmentUrl
  26. })
  27. },
  28. publish: throttle(async function (e) {
  29. if (!this.data.msg.trim()) {
  30. toast('请输入内容')
  31. return;
  32. }
  33. const params = {
  34. issues: this.data.msg,
  35. attachmentType: this.data.attachmentType,
  36. attachmentUrl: this.data.attachmentUrl
  37. }
  38. await Api.ReleaseHot(params, true);
  39. this.triggerEvent("postFinish");
  40. })
  41. }
  42. })