message.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. // pages/message/message.js
  2. const app = getApp()
  3. var host = app.globalData.host;
  4. const $api = require('../../utils/api.js').API;
  5. var timer;
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. focus:false
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad: function (options) {
  17. this.getData()
  18. },
  19. getData(){
  20. var _this=this;
  21. f()
  22. timer=setInterval(f,10000)
  23. function f(){
  24. $api.getconsult().then(res=>{
  25. _this.setData({
  26. list:res.data.data.list
  27. })
  28. })
  29. }
  30. },
  31. inputchange(e) {
  32. this.setData({
  33. comment: e.detail.value
  34. })
  35. },
  36. post(){
  37. var data={
  38. cotent:this.data.comment
  39. }
  40. if(!data.cotent){
  41. return
  42. }
  43. $api.consult(data).then(res=>{
  44. this.getData()
  45. this.setData({
  46. comment:''
  47. })
  48. })
  49. },
  50. /**
  51. * 生命周期函数--监听页面初次渲染完成
  52. */
  53. onReady: function () {
  54. },
  55. /**
  56. * 生命周期函数--监听页面显示
  57. */
  58. onShow: function () {
  59. },
  60. /**
  61. * 生命周期函数--监听页面隐藏
  62. */
  63. onHide: function () {
  64. },
  65. /**
  66. * 生命周期函数--监听页面卸载
  67. */
  68. onUnload: function () {
  69. clearInterval(timer)
  70. },
  71. /**
  72. * 页面相关事件处理函数--监听用户下拉动作
  73. */
  74. onPullDownRefresh: function () {
  75. },
  76. /**
  77. * 页面上拉触底事件的处理函数
  78. */
  79. onReachBottom: function () {
  80. },
  81. /**
  82. * 用户点击右上角分享
  83. */
  84. onShareAppMessage: function () {
  85. }
  86. })