index.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. const app = getApp()
  2. import { examine_status } from '../../utils/dict';
  3. import WxValidate from '../../utils/wxValidate';
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. frameStyle: { useTop: true, name: '话题', leftArrow: false, useBar: true },
  10. searchInfo: {},
  11. list: [],
  12. },
  13. // 跳转菜单
  14. tabPath(e) {
  15. let { route } = e.detail.detail;
  16. if (route) wx.redirectTo({ url: `/${route}` })
  17. },
  18. // 跳转菜单
  19. back(e) {
  20. wx.navigateBack({ delta: 1 })
  21. },
  22. // 查询
  23. search: function (e) { console.log('查询'); },
  24. /**
  25. * 生命周期函数--监听页面加载
  26. */
  27. onLoad: function (options) {
  28. const that = this;
  29. that.watchLogin();
  30. },
  31. // 监听用户是否登录
  32. watchLogin: function () {
  33. const that = this;
  34. let searchInfo = that.data.searchInfo;
  35. wx.getStorage({
  36. key: 'user',
  37. success: async (res) => {
  38. let info = { skip: 0, limit: 1000 };
  39. if (searchInfo && searchInfo.title) info.title = searchInfo.title;
  40. const arr = await app.$get(`/newCourt/api/topic`, { ...info });
  41. if (arr.errcode == '0') {
  42. that.setData({ list: arr.data })
  43. console.log(arr.data);
  44. }
  45. else { wx.showToast({ title: `${res.errMsg}`, icon: 'fail', duration: 2000 }); }
  46. },
  47. fail: async (res) => {
  48. wx.redirectTo({ url: '/pages/index/index' });
  49. },
  50. });
  51. },
  52. /**
  53. * 生命周期函数--监听页面初次渲染完成
  54. */
  55. onReady: function () {
  56. },
  57. /**
  58. * 生命周期函数--监听页面显示
  59. */
  60. onShow: function () {
  61. },
  62. /**
  63. * 生命周期函数--监听页面隐藏
  64. */
  65. onHide: function () {
  66. },
  67. /**
  68. * 生命周期函数--监听页面卸载
  69. */
  70. onUnload: function () {
  71. },
  72. /**
  73. * 页面相关事件处理函数--监听用户下拉动作
  74. */
  75. onPullDownRefresh: function () {
  76. },
  77. /**
  78. * 页面上拉触底事件的处理函数
  79. */
  80. onReachBottom: function () {
  81. },
  82. /**
  83. * 用户点击右上角分享
  84. */
  85. onShareAppMessage: function () {
  86. }
  87. })