search.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // pages/search/search.js
  2. const getReq = require('../../config.js').getReq
  3. import recordSource from '../../utils/recordSource'
  4. let app = getApp()
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. special_datas: {},
  11. summery: [],
  12. fromSource: '',
  13. firstLoad: true
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad: function (options) {
  19. wx.setNavigationBarTitle({
  20. title: '搜索',
  21. });
  22. wx.showLoading({
  23. title: '加载中'
  24. });
  25. let self = this;
  26. let fromSource = recordSource(app, `act=search&op=history&curpage=1&client_type=mini`)
  27. this.setData({
  28. fromSource: app.globalData.fromSource
  29. })
  30. getReq({
  31. act: 'search',
  32. op: 'history',
  33. curpage: 1,
  34. from: fromSource
  35. }, function (res) {
  36. if (res.code == 200) {
  37. self.setData({
  38. special_datas: res.datas,
  39. summery: res.datas.summary,
  40. firstLoad: false
  41. });
  42. }
  43. setTimeout(function () {
  44. wx.hideLoading()
  45. }, 1000)
  46. })
  47. },
  48. /**
  49. * 生命周期函数--监听页面初次渲染完成
  50. */
  51. onReady: function () {
  52. },
  53. /**
  54. * 生命周期函数--监听页面显示
  55. */
  56. onShow: function () {
  57. if(!this.data.firstLoad) {
  58. app.setFromSource(this.data.fromSource)
  59. }
  60. },
  61. /**
  62. * 生命周期函数--监听页面隐藏
  63. */
  64. onHide: function () {
  65. },
  66. /**
  67. * 生命周期函数--监听页面卸载
  68. */
  69. onUnload: function () {
  70. },
  71. /**
  72. * 页面相关事件处理函数--监听用户下拉动作
  73. */
  74. onPullDownRefresh: function () {
  75. },
  76. /**
  77. * 页面上拉触底事件的处理函数
  78. */
  79. onReachBottom: function () {
  80. }
  81. })