index.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. toJoin(e) {
  19. let { id } = e.currentTarget.dataset;
  20. wx.navigateTo({ url: `/pages/topic/info?id=${id}` })
  21. },
  22. // 跳转菜单
  23. back(e) {
  24. wx.navigateBack({ delta: 1 })
  25. },
  26. // 查询
  27. search: function (e) {
  28. const that = this;
  29. that.setData({ 'searchInfo.title': e.detail.value });
  30. that.watchLogin()
  31. },
  32. /**
  33. * 生命周期函数--监听页面加载
  34. */
  35. onLoad: function (options) {
  36. const that = this;
  37. that.watchLogin();
  38. },
  39. // 监听用户是否登录
  40. watchLogin: function () {
  41. const that = this;
  42. let searchInfo = that.data.searchInfo;
  43. wx.getStorage({
  44. key: 'user',
  45. success: async (res) => {
  46. let info = { skip: 0, limit: 1000 };
  47. if (searchInfo && searchInfo.title) info.title = searchInfo.title;
  48. const arr = await app.$get(`/newCourt/api/topic`, { ...info });
  49. if (arr.errcode == '0') {
  50. that.setData({ list: arr.data })
  51. console.log(arr.data);
  52. }
  53. else { wx.showToast({ title: `${res.errMsg}`, icon: 'fail', duration: 2000 }); }
  54. },
  55. fail: async (res) => {
  56. wx.redirectTo({ url: '/pages/index/index' });
  57. },
  58. });
  59. },
  60. /**
  61. * 生命周期函数--监听页面初次渲染完成
  62. */
  63. onReady: function () {
  64. },
  65. /**
  66. * 生命周期函数--监听页面显示
  67. */
  68. onShow: function () {
  69. },
  70. /**
  71. * 生命周期函数--监听页面隐藏
  72. */
  73. onHide: function () {
  74. },
  75. /**
  76. * 生命周期函数--监听页面卸载
  77. */
  78. onUnload: function () {
  79. },
  80. /**
  81. * 页面相关事件处理函数--监听用户下拉动作
  82. */
  83. onPullDownRefresh: function () {
  84. },
  85. /**
  86. * 页面上拉触底事件的处理函数
  87. */
  88. onReachBottom: function () {
  89. },
  90. /**
  91. * 用户点击右上角分享
  92. */
  93. onShareAppMessage: function () {
  94. }
  95. })