detail.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. const util = require('../../../utils/util.js');
  2. const api = require('../../../utils/api.js');
  3. const app = getApp()
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. id: '',
  10. info: '',
  11. responseVal: '',
  12. userInfo: ''
  13. },
  14. getInfo: function(e) {
  15. const that = this;
  16. util.httpRequest(api.getSuggestionDetail, {
  17. id: that.data.id
  18. }, 'post').then(res => {
  19. that.setData({
  20. info: res.data.data.data
  21. })
  22. })
  23. },
  24. response: function(e) {
  25. this.setData({
  26. responseVal: e.detail.value
  27. })
  28. },
  29. apply: function(e) {
  30. const that = this;
  31. if (that.data.responseVal == '') {
  32. wx.showToast({
  33. title: '回复不能为空',
  34. icon: 'none'
  35. })
  36. } else {
  37. util.httpRequest(api.getSuggestionResponse, {
  38. loginId: that.data.userInfo.loginId,
  39. id: that.data.id,
  40. answer: that.data.responseVal
  41. }, 'post').then(res => {
  42. wx.showToast({
  43. title: '提交成功',
  44. })
  45. setTimeout(function() {
  46. wx.navigateBack({
  47. })
  48. }, 500)
  49. })
  50. }
  51. },
  52. /**
  53. * 生命周期函数--监听页面加载
  54. */
  55. onLoad: function(options) {
  56. const that = this;
  57. let userInfo = wx.getStorageSync('user');
  58. that.setData({
  59. id: options.id,
  60. userInfo: userInfo
  61. })
  62. that.getInfo();
  63. },
  64. /**
  65. * 生命周期函数--监听页面初次渲染完成
  66. */
  67. onReady: function() {
  68. },
  69. /**
  70. * 生命周期函数--监听页面显示
  71. */
  72. onShow: function() {
  73. },
  74. /**
  75. * 生命周期函数--监听页面隐藏
  76. */
  77. onHide: function() {
  78. },
  79. /**
  80. * 生命周期函数--监听页面卸载
  81. */
  82. onUnload: function() {
  83. },
  84. /**
  85. * 页面相关事件处理函数--监听用户下拉动作
  86. */
  87. onPullDownRefresh: function() {
  88. },
  89. /**
  90. * 页面上拉触底事件的处理函数
  91. */
  92. onReachBottom: function() {
  93. }
  94. })