searchList.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. // pages/searchList/searchList.js
  2. const app = getApp()
  3. var host = app.globalData.host;
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. act:0,
  10. data:[],
  11. keyword:'',
  12. type:''
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad: function (options) {
  18. // options.keyword='科学'
  19. this.setData({
  20. keyword: options.keyword,
  21. type: options.type ? options.type:''
  22. })
  23. this.getData()
  24. },
  25. getData:function(){
  26. wx.showNavigationBarLoading()
  27. wx.request({
  28. url: host + '/api/search',
  29. method: 'GET',
  30. data: {
  31. keyword: this.data.keyword,
  32. type: this.data.type
  33. },
  34. success: res => {
  35. wx.hideNavigationBarLoading();
  36. this.setData({
  37. data: res.data.data
  38. })
  39. },
  40. fail: function () {
  41. wx.hideLoading();
  42. wx.showToast({
  43. title: '服务器开小差啦!',
  44. icon: 'none'
  45. })
  46. }
  47. })
  48. },
  49. inputChange:function(e){
  50. this.setData({
  51. keyword:e.detail.value
  52. })
  53. this.getData();
  54. },
  55. tab:function(e){
  56. var i=e.target.dataset.id;
  57. var array = ['', 'organizer', 'article', 'conference', 'journal','subject'];
  58. this.setData({
  59. type: array[i],
  60. act:i
  61. })
  62. // this.getData()
  63. },
  64. more: function (e) {
  65. var value = e.target.dataset.id;
  66. this.setData({
  67. type: value,
  68. act: e.target.dataset.index
  69. })
  70. },
  71. /**organizer/article/conference/journal/subject
  72. * 生命周期函数--监听页面初次渲染完成
  73. */
  74. onReady: function () {
  75. },
  76. /**
  77. * 生命周期函数--监听页面显示
  78. */
  79. onShow: function () {
  80. },
  81. /**
  82. * 生命周期函数--监听页面隐藏
  83. */
  84. onHide: function () {
  85. },
  86. /**
  87. * 生命周期函数--监听页面卸载
  88. */
  89. onUnload: function () {
  90. },
  91. /**
  92. * 页面相关事件处理函数--监听用户下拉动作
  93. */
  94. onPullDownRefresh: function () {
  95. },
  96. /**
  97. * 页面上拉触底事件的处理函数
  98. */
  99. onReachBottom: function () {
  100. },
  101. /**
  102. * 用户点击右上角分享
  103. */
  104. onShareAppMessage: function () {
  105. }
  106. })