comment.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. const util = require('../../utils/util.js')
  2. var app = getApp()
  3. Page({
  4. data: {
  5. id: 0,
  6. content: '',
  7. loading: false,
  8. title:'点评',
  9. ty:'',
  10. oid:''
  11. },
  12. onLoad: function(options) {
  13. let id = options.id;
  14. let oid = options.oid;
  15. this.setData({
  16. id: id,
  17. oid: oid
  18. })
  19. },
  20. inputComment: function(e) {
  21. this.setData({
  22. content: e.detail.value
  23. })
  24. },
  25. submit: function() {
  26. wx.hideLoading()
  27. let that = this
  28. if (that.data.loading) return
  29. if (that.data.content.length < 5 || that.data.content.length > 256) {
  30. wx.showToast({
  31. title: '点评内容需要 5 ~ 256 个字符',
  32. icon: 'none',
  33. duration: 3000
  34. })
  35. return
  36. }
  37. that.setData({
  38. loading: true
  39. })
  40. let id = that.data.id;
  41. let comments = that.data.content;
  42. let openid = app.globalData.openid;
  43. let oid = that.data.oid;
  44. console.log("oid==" + oid);
  45. wx.request({
  46. url: app.data.resturl + '/comment.action',
  47. method: 'post',
  48. header: {
  49. 'content-type': 'application/x-www-form-urlencoded'
  50. },
  51. data: {
  52. openid: openid,
  53. id:id,
  54. contents: comments,
  55. oid:oid
  56. },
  57. success: function (res) {
  58. wx.showToast({
  59. title: '发表点评成功',
  60. })
  61. wx.navigateBack({
  62. })
  63. that.setData({
  64. loading: false
  65. })
  66. }
  67. })
  68. }
  69. })