const $ = global; new $.Page({ data: { comment: '' }, onLoad(e) { const id = e.id || ''; const type = e.type || ''; this.setData({ id, type }); }, inputComment(e) { this.setData({ comment: e.detail.value }) }, submit() { const { id, type, comment } = this.data; if (!id) return; if (!comment) { return $.wx.showToast({ title: '内容不能为空' }); } $.wx.showToast({ title: '加载中' }, 'loading'); $.request(`${type}/${id}/comment`, 'POST', { content: comment }).then(res => { $.wx.showToast({ title: '提交成功' }); setTimeout(function () { $.router.back(); }, 2000); }) } });