家政小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 971B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. const $ = global;
  2. new $.Page({
  3. data: {
  4. comment: ''
  5. },
  6. onLoad(e) {
  7. const id = e.id || '';
  8. const type = e.type || '';
  9. this.setData({
  10. id,
  11. type
  12. });
  13. },
  14. inputComment(e) {
  15. this.setData({
  16. comment: e.detail.value
  17. })
  18. },
  19. submit() {
  20. const {
  21. id,
  22. type,
  23. comment
  24. } = this.data;
  25. if (!id) return;
  26. if (!comment) {
  27. return $.wx.showToast({
  28. title: '内容不能为空'
  29. });
  30. }
  31. $.wx.showToast({
  32. title: '加载中'
  33. }, 'loading');
  34. $.request(`${type}/${id}/comment`, 'POST', {
  35. content: comment
  36. }).then(res => {
  37. $.wx.showToast({
  38. title: '提交成功'
  39. });
  40. setTimeout(function () {
  41. $.router.back();
  42. }, 2000);
  43. })
  44. }
  45. });