import {getDataSet, getEventParam, throttle, toast} from "../../../../utils/utils"; import Api from "../../../../model/api"; import Config from "../../../../model/config"; Component({ properties: { categoryData: Array, }, data: { type: '', msg: '', attachmentType: '', attachmentUrl: '', uploadPath: Config.UPLOAD_PATH.COMMUNITY_EXAMPLE }, methods: { changeInfo(e) { let eventParam = getEventParam(e); this.setData({ ...eventParam }) }, onChange(e) { const field = getDataSet(e, "field"); this.setData({ [field]: getEventParam(e) }) }, handleUpload(e) { const fileType = getEventParam(e, "fileType"); const fileList = getEventParam(e, "fileList"); const urls = fileList.map(item => item.url); const attachmentUrl = JSON.stringify(urls); this.setData({ attachmentType: fileType, attachmentUrl }) }, publish: throttle(async function (e) { if (!this.data.type.trim()) { toast('请选择典型分类') return; } if (!this.data.msg.trim()) { toast('请输入要分享的内容') return; } const params = { type: this.data.type, details: this.data.msg, attachmentType: this.data.attachmentType, attachmentUrl: this.data.attachmentUrl } await Api.ReleaseExamples(params, true); this.triggerEvent("postFinish"); }) } })